• Resolved psivel

    (@psivel)


    Hi,

    I use your plugin for a while now and it works perfectly for WP/WC emails as well as wit Pimwick’s Gift Card plugin for which I had to check “Use theme template if available.”

    But I’ve recently bought the SIP plugin and their emails have HTML tags rendered as text. If I deactivate your plugin it’s OK but I can’t do that since I use your great plugin for all my transactional emails.

    It seems that the SIP plugin doesn’t have any template that I could copy into my theme folder to bypass your plugin as I do with PWC Gift Card so I don’t see how to address this issue.

    Any idea ?

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

Viewing 15 replies - 1 through 15 (of 24 total)
  • Plugin Support Julian

    (@juliangk)

    Hello psivel,

    one solution would be to exclude these email by “subject” as described in our FAQ: disable template.

    Please let us know if this solution works for you.

    Best regards
    Julian

    Thread Starter psivel

    (@psivel)

    Hi,

    I use SIP to send follow-up emails to check if the clients have received their orders. Since the email subject contains customer’s name and comes in 5 languages I tried the following:

    add_filter( ‘haet_mail_use_template’, ‘customize_template_usage’, 10, 2 );

    function customize_template_usage( $use_template, $mail ){
    $strings = array(“avez-vous bien re?u votre commande ?”,”did you receive your order ?”,”has recibido bien tu pedido?”,”heb je je bestelling ontvangen?”,”Hast du deine Bestellung erhalten?”);
    foreach ($strings as $string) {
    if (strpos($string, $mail[‘subject’]) !== FALSE) {
    return false;
    }
    }

    return true;
    }

    but it doesn’t work, return false is never fired and I always get the header setup in your plugin.

    Anyway I’ve checked the box “Allow HTML code in plain text content type” in the settings and it solves the issue even if I have some side effects in SIP html code and would prefer to get rid of your plugin in SIP emails. But with some fine tuning it seems to be working.

    Thanks for your help.

    Thread Starter psivel

    (@psivel)

    Another question. After installing WC 4 I’ve noticed issues in transactional email formatting so I’ve downgraded to 3.9. I have a test website on the same domain which is the mirror of my prod website but I had to deactivate my WP HTML Mail licence from it since it only works on 1 subdomain. Is there a way to activate the licence on both subdomains for testing purpose ?

    Hey @psivel,
    1st question:
    change the order of parameters in strpos
    strpos ( $haystack , $needle )

    2nd question:
    which versions of our plugins do you use?
    best regards, Hannes

    Thread Starter psivel

    (@psivel)

    OK if I change the order of parameters it works. My mistake, Thank you.

    Versions:

    WP HTML Mail – 3.0
    WP HTML Mail – WooCommerce – 2.9.2

    Thank you for your help.

    Pierre

    Thread Starter psivel

    (@psivel)

    Hi,

    Another little question. I need to add some code to the .php file that outputs the ordered items table (with thumbnail) in the emails sent to the client and admin (on hold, processing and completed). I have a gift product plugin and for the gifted products I need to retrieve the correct variation image, if not the parent’s product thumbnail is displayed.

    I tried to override wocommerce’s email-order-items.php but it seems it’s not the good file. Shall I edit email-order-items.php in your theme instead ?

    Copy the file to your (child) theme in the correct folder (see WooCommerce docs about overriding templates)
    You can either copy and customize the original file from WooCommerce or the modified one from our plugin.
    I‘d suggest ours because it already contains some useful modifications.
    When you go the settings of WP HTML Mail WooCommerce it detects the template file and gives a new option to either use or ignore custom templates.

    Thread Starter psivel

    (@psivel)

    OK but is the right file /plugins/wp-html-mail-woocommerce/views/woocommerce/template/email-order-items.php ?

    I’m asking because when I edit the email source, the opening tag of the thumbnail is <td width=“70” style=“border-collapse… 70 being the image size I’ve setup in WP HTML Mail setup in my admin. But I can’t find any lookalike tag in the file…

    Anything about the ability to use the plugin in my test site ?

    Yes this is the correct file. The part you need to modify starts at line 46:

    
    <td class="image-wrap" style="width:<?php echo $image_size[0];?>px">
        <?php
            if( $_product->get_image_id() ){
                $image = wp_get_attachment_image_src( $_product->get_image_id(), $image_size );
                $image_src = $image[0];
                $current_image_size = array($image[1],$image[2]);
            }else{
                $image_src = wc_placeholder_img_src();
                $current_image_size = $image_size;
            }
            // Show title/image etc
            echo apply_filters( 'woocommerce_order_item_thumbnail', '<img src="' . $image_src .'" alt="' . __( 'Product Image', 'woocommerce' ) . '" height="' . esc_attr( $current_image_size[1] ) . '" width="' . esc_attr( $current_image_size[0] ) . '" style="vertical-align:middle; margin-right: 10px;" />', $item );
        ?>							
    </td>

    While copying this code I recognized the filter woocommerce_order_item_thumbnail which could be a better way to customize the image. I think if you google for it you should find some examples how to use it and you can avoid to overwrite templates.

    Thread Starter psivel

    (@psivel)

    Hi,

    The code to retrieve the original variation thumbnail from the duplicated one is:

    
    $original_variation_id = get_post_meta($item['variation_id'], '_' . DGFW::GIFT_VARIATION_OPTION . '_original', true);
    		
    if ($original_variation_id && $original_variation = WC()->product_factory->get_product($original_variation_id)) {
    $image = $original_variation->get_image($image_size);
    } else {
    $image = $product->get_image($image_size);
    }
    

    When I try this in the WC email-order-items.php on my test website it works and I get the correct variation image in the email. But when I try it overriding your template I still get the parents product thumbnail. In your code I’ve tried:

    
    if ($_product->get_image_id()) {
    									
    	$original_variation_id = get_post_meta($item['variation_id'], '_' . DGFW::GIFT_VARIATION_OPTION . '_original', true);
    		
    	if ($original_variation_id && $original_variation = WC()->product_factory->get_product($original_variation_id)) {
    									
    		$image_src = $original_variation->get_image($image_size);
    		$current_image_size = $image_size;
    									
    	} else {
    		$image = wp_get_attachment_image_src( $_product->get_image_id(), $image_size );
    		$image_src = $image[0];
    		$current_image_size = array($image[1],$image[2]);
    	}
    									
    } else {
    	$image_src = wc_placeholder_img_src();
    	$current_image_size = $image_size;
    }
    

    What am I doing wrong ?

    did you enable the use of custom templates in settings -> email template -> woocommerce ?

    Thread Starter psivel

    (@psivel)

    Yes I have this option enabled since I use a custom template for my gift card plugin.

    I’ve put it in <my_theme>/woocommerce/emails/ it is the right location right ?

    It seems that the script can’t define $original_variation_id and thus goes into the else everytime…

    Thread Starter psivel

    (@psivel)

    I tried something:

    1. Emptied my <my_theme>/woocommerce/emails/ folder
    2. Replaced the file email-order-items.php in your plugin by the WC’s original one that I customized this morning, appending ‘TEST’ after products’ name.
    3. Passed an order

    The email I receive is exactly the same as before (same formatting as your plugin and no TEST after products name)…

    It seems that this file in your folder is not executed at all (so my changes are not taken into account)… This would explain why I couldn’t find in the file the tags found in email source code…

    I don’t understand.

    I’m sorry, I assumed you already knew it is the right file. This file is only loaded if you choose to define one global template but it seems you edit each email individually so the content of the products table is created in class-wphtmlmail-woocommerce.php get_placeholders_productstable()
    Look for the line foreach ( $image_placeholder_sizes as $image_size_placeholder_name => $image_size_name)
    it creates an array of image placeholders in different sizes. A few lines later there’s a filter where you can hook in to modify the current products placeholder array:
    $items[ $i ] = apply_filters( 'haet_mail_order_placeholders_products_table', $items[$i], $item, $_product, $wc_order );

    Thread Starter psivel

    (@psivel)

    OK I got it working now thank you !

    The problem is that modifying plugins classes is not good practice it would have been better to override email-order-items.php but I didn’t really try to choose to define one global template. Since all my emails have different texts I thought editing each email individually would be better but I don’t know. Appart from the text before order table all the emails are the same. Could I choose a global template in this case to be able to put my code snippet in email-order-items.php and override it ?

    An again, any chance to be able to test all this in my mirror website ? I must dio everything on my prod website which is not a good thing.

    Thanks for your help anyway.

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Issue with SIP Advanced Email Notifications’ is closed to new replies.