• Hi,

    after updating UNI CPO and Woocommerce to the latest versions, the link of the uploaded file is nog visible anymore in the email. Is there a way to fix this?

    Now it only shows the title of the uploaded file. But i want the link to the file in de email.

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor mr.psiho

    (@mrpsiho)

    Hi!

    Sorry, not possible. WC escapes any html, so the link gets broken anyway. This changes were introduced recently by WC.

    Thanks for the quick reply!

    Is it maybe possible to attach the file-upload to the e-mail?

    Thanks!

    Plugin Contributor mr.psiho

    (@mrpsiho)

    Hi,

    No, sorry, it is not.

    Hi Mr.psiho,

    I’m sorry to bother you again. But do you have any tips on how I can manage to get the url of the image in the mail? It does not necessarily have to be a clickable link. If the full path is in the mail, then it’s okay.

    Or how can I ensure that the uploaded file is accessible via mail? I really need this feauture xD

    Thanks!

    Plugin Contributor mr.psiho

    (@mrpsiho)

    Hi,

    Do you know how to deal with WC hooks? Could you write your own function to grab an attachment ID, get URL from it and return this URL to WC via a hook?

    Hi psiho,

    I have tried it but I can not manage it. My php knowledge is minimum. Can you help me out and push me in the right direction?

    Plugin Contributor mr.psiho

    (@mrpsiho)

    Hi,

    What hook have you tried?

    I used the following code to get all info in the email:

    add_action( 'woocommerce_email_order_details', 'action_wc_email_order_details', 50, 4 );
    function action_wc_email_order_details( $order, $sent_to_admin, $plain_text, $email ){
        // Get the Order ID (WooCommerce retro-compatibility)
        $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
    
        // Get "serial" custom field value
        $serial = get_post_meta($order_id, $key = '', $single = false );
    
        // Display "serial" custom field value
        echo '<p>'.__('Serial', 'woocommerce') . $serial . '</p>';
        echo print_r( $serial );
      
      $order = wc_get_order( $order_id);
    
    // Loop through order line items
    foreach( $order->get_items() as $item ){
        // get order item data (in an unprotected array)
        $item_data = $item->get_data();
    
        // get order item meta data (in an unprotected array)
        $item_meta_data = $item->get_meta_data();
    
        // get only additional meta data (formatted in an unprotected array)
        $formatted_meta_data = $item->get_formatted_meta_data();
    
        // Display the raw outputs (for testing)
        echo '<pre>'; print_r($item_meta_data); echo '</pre>';
        echo '<pre>'; print_r($formatted_meta_data); echo '</pre>';
    }
    }

    This outputs the array with all the data of the order:

    [10395] => stdClass Object
    (
    [key] => _uni_cpo_foto_slagroomaanbieding
    [value] => 2983
    [display_key] => Upload hier uw foto
    [display_value] => rechts-3.jpg
    )

    The “rechts-3.jpg” needs to be “www.domain.nl/wp-contents/uploads/rechts-3.jpg”

    I have no idea if the code above is an hook… I just copied it from the internet 😛

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