• jusemora30

    (@jusemora30)


    Hello! Good day. Plugin was working great till the last update for me. It did never work for me unless I updated the code from “frontend-my-account-attachments.php” and that was working perfectly. I have this coded saved so when the plugin update, I replace the php and all keep working good. With this recent updated, I upload the code and gives me critical error on the website so now my code doesn’t work and it’s no displaying attachments at front

    <?php

    $wcoa_attachments = WCOA_Attachment::get_list(0, get_current_user_id());

    if (!$wcoa_attachments || count($wcoa_attachments) === 0) {

        _e('There are no attachments to display.', 'sld-wcoa');

        return;

    }

    // Define an array mapping file extensions to their corresponding icon URLs

    $file_icons = array(

        'vp3' => 'https://abdigitizing.com/wp-content/uploads/2024/06/VP3.png',

        'xxx' => 'https://abdigitizing.com/wp-content/uploads/2024/06/XXX.png',

        'zip' => 'https://abdigitizing.com/wp-content/uploads/2024/06/ZIP.png',

        'dst' => 'https://abdigitizing.com/wp-content/uploads/2024/06/DST.png',

        'emb' => 'https://abdigitizing.com/wp-content/uploads/2024/06/EMB.png',

        'exp' => 'https://abdigitizing.com/wp-content/uploads/2024/06/EXP.png',

        'hus' => 'https://abdigitizing.com/wp-content/uploads/2024/06/HUS.png',

        'jef' => 'https://abdigitizing.com/wp-content/uploads/2024/06/JEF.png',

        'pdf' => 'https://abdigitizing.com/wp-content/uploads/2024/06/PDF.png',

        'pes' => 'https://abdigitizing.com/wp-content/uploads/2024/06/PES.png',

    );

    echo '<h2>' . __('Order Attachments', 'woocommerce') . '</h2>';

    echo '<table class="order-attachments">';

    echo '<thead><tr><th>' . __('Icon', 'woocommerce') . '</th><th>' . __('File Name', 'woocommerce') . '</th><th>' . __('Order', 'woocommerce') . '</th><th class="date-column">' . __('Date', 'woocommerce') . '</th><th>' . __('Action', 'woocommerce') . '</th></tr></thead>';

    echo '<tbody>';

    foreach ($wcoa_attachments as $item) {

        $wcoa_order = wc_get_order($item['order_id']);

        $item['order_url'] = $wcoa_order->get_view_order_url();

        $file_url = $item['guid'];

        $file_name = basename($file_url);

        $file_extension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));

        $attachment_date = $item['post_date'];

        // Check if the file extension has a corresponding icon URL

        $file_icon = isset($file_icons[$file_extension]) ? $file_icons[$file_extension] : ''; // Add a default icon URL if needed

        echo '<tr>';

        echo '<td><img src="' . esc_url($file_icon) . '" alt="' . esc_attr($file_extension) . ' Icon" height="50px"></td>'; // Icon with 50px height

        echo '<td>' . esc_html($file_name) . '</td>'; // File name column

        echo '<td><a href="' . esc_url($item['order_url']) . '">#' . esc_html($item['order_id']) . '</a></td>';

        echo '<td class="date-column">' . esc_html($attachment_date) . '</td>'; // Date column

        echo '<td><a href="' . esc_url($file_url) . '" class="button" target="_blank" download>' . __('Download', 'woocommerce') . '</a></td>';

        echo '</tr>';

    }

    echo '</tbody>';

    echo '</table>';

    ?>

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Dominik

    (@sldesignpl)

    Hi,

    The latest update brings a lot of changes, including the organization of code and classes, so it’s very likely that your custom solution has stopped working. Unfortunately, we cannot assist you in resolving the issue if you are using an unofficial solution. Therefore, we recommend installing the latest official version. If problems persist, please try to include server logs and describe exactly what is not working.

    Thread Starter jusemora30

    (@jusemora30)

    Hey! Thank you for quick response. My only issue es that attachments are not being displayed on My Account / attachments tab, it says “There are no attachments to display.”

    I used to fix that issue with previous code. Is it normal that I don’t see attachments after update?

    Capture.PNG

    Plugin Author Dominik

    (@sldesignpl)

    Just to confirm, are you logged in as the customer who placed the order and to whose order an attachment was later added?
    If I understand correctly, there is nothing available under the “My Account – Attachments” tab, but when you view the specific order, the attachment is listed as added?
    Please also make sure that the customer in the order is indeed the user you are logging in as when accessing the “My Account – Attachments” tab, and not, for example, a guest or another user.
    The update does not affect previous attachments, so they should still be available.

    Thread Starter jusemora30

    (@jusemora30)

    I’m using a customer account with attachments added to an order, I screen recorded the process. It’s displaying on orders tab under the order ID but nothing displayed on attachments tab

    2024-08-24 09-24-17.mp4

    Plugin Author Dominik

    (@sldesignpl)

    But are you sure you are using the latest version of the plugin without any of your own customizations? I’m asking because I see that in the order details tab, there is a list of attachments, which our plugin does not provide, so I assume this is your own solution.

    Another question is whether the attachments are only not visible in the My Account tab for old orders, or for new ones as well? If it’s only for old ones, it’s possible that your modifications to the code may have affected something, like metadata of the attachment or order, which are considered when retrieving the appropriate data from the database.

    Thread Starter jusemora30

    (@jusemora30)

    Good day.
    I don’t know much about coding, this was with ChagGPT help, I’m using the latest version of your plugin and this php is the only customization I have. I didn’t have issues before the last update

    add_action('woocommerce_order_details_after_order_table', 'display_wc_order_attachments');
    function display_wc_order_attachments($order) {
    $order_id = $order->get_id();
    // Retrieve all attachment IDs associated with the order
    $attachments = get_post_meta($order_id, '_wcoa_attachment_id');

    // Define an array mapping file extensions to their corresponding icon URLs
    $file_icons = array(
    'vp3' => 'https://abdigitizing.com/wp-content/uploads/2024/06/VP3.png',
    'xxx' => 'https://abdigitizing.com/wp-content/uploads/2024/06/XXX.png',
    'zip' => 'https://abdigitizing.com/wp-content/uploads/2024/06/ZIP.png',
    'dst' => 'https://abdigitizing.com/wp-content/uploads/2024/06/DST.png',
    'emb' => 'https://abdigitizing.com/wp-content/uploads/2024/06/EMB.png',
    'exp' => 'https://abdigitizing.com/wp-content/uploads/2024/06/EXP.png',
    'hus' => 'https://abdigitizing.com/wp-content/uploads/2024/06/HUS.png',
    'jef' => 'https://abdigitizing.com/wp-content/uploads/2024/06/JEF.png',
    'pdf' => 'https://abdigitizing.com/wp-content/uploads/2024/06/PDF.png',
    'pes' => 'https://abdigitizing.com/wp-content/uploads/2024/06/PES.png',
    );

    if ($attachments && is_array($attachments)) {
    echo '<h2>' . __('Order Attachments', 'woocommerce') . '</h2>';
    echo '<table class="order-attachments">';
    echo '<thead><tr><th>' . __('Icon', 'woocommerce') . '</th><th>' . __('Name', 'woocommerce') . '</th><th>' . __('Date', 'woocommerce') . '</th><th>' . __('Action', 'woocommerce') . '</th></tr></thead>';
    echo '<tbody>';
    foreach ($attachments as $attachment_id) {
    $file_url = wp_get_attachment_url($attachment_id);
    $file_name = basename($file_url);
    $file_extension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
    $attachment_date = get_the_date('', $attachment_id);

    // Check if the file extension has a corresponding icon URL
    if (isset($file_icons[$file_extension])) {
    // Use the icon URL
    $file_icon = $file_icons[$file_extension];
    } else {
    // Use a default icon URL if no specific icon is found
    $file_icon = ''; // Add a default icon URL here
    }

    echo '<tr>';
    echo '<td><img src="' . esc_url($file_icon) . '" alt="' . esc_attr($file_extension) . ' Icon" height="50px"></td>'; // Icon with 50px height
    echo '<td>' . esc_html($file_name) . '</td>';
    echo '<td>' . esc_html($attachment_date) . '</td>';
    echo '<td><a href="' . esc_url($file_url) . '" class="button" download>' . __('Download', 'woocommerce') . '</a></td>';
    echo '</tr>';
    }
    echo '</tbody>';
    echo '</table>';
    } else {
    echo '<p>' . __('No attachments found for this order.', 'woocommerce') . '</p>';
    }
    }
    Plugin Author Dominik

    (@sldesignpl)

    As I mentioned earlier, the latest version introduces many changes in the code organization. If you’re making any custom modifications to the plugin’s functionality, you should be aware that this carries the risk of incompatibility with newer versions of the plugin. If problems with your solutions started to appear after the update, it’s likely that you need to update your modifications as well.

    Unfortunately, you also didn’t answer all of my questions, so I’m not sure how else I can assist you.

    Thread Starter jusemora30

    (@jusemora30)

    I’m sorry. I’m using the latest version of the plugin and disable the snippet that customized the plugin.

    I created a new account to try as new customer, and attachments are not being displayed on old or new accounts. I attached video for reference. Thank you!

    by the way the attachment is attached to the “order completed” email

    2024-08-25 18-31-46.mp4

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.