customized product thumbnail in order email?

Posted over 7 years ago by Christian Nießing

Post a topic
Implemented
C
Christian Nießing

Hi,

I have the problem that the procuct thumbnail in woocommerce order e-mail ist not the customized one. It is showing the basic procut image instead of the customized product. Is there any way to achieve this?

0 Votes


24 Comments

Sorted by
G

George Kepnick posted about 4 years ago

Is it on by default or do we have to enable it somehow?

0 Votes

P

Paul van Dun posted over 4 years ago

Any chance how the design image could be bigger included @ the new order email, or how it could be made bigger?

0 Votes

rady kal

rady kal posted over 5 years ago Admin

Included in V3.9.3

0 Votes

M

MichiK85 posted over 5 years ago

I think the feature is in the next new version which is 3.9.3. Radykal is currently working on this. 

0 Votes

R

Ryan Hudson posted over 5 years ago

I'm now in version 3.9.2. 

Does anyone have a solution for this with the latest version of FPD?

0 Votes

M

MichiK85 posted almost 6 years ago

Any idea for adding this in the future?

0 Votes

O

Oval posted about 6 years ago

It is seems iOS Mail.app starts to caching embedded images by its name (and show all over images as first loaded with same name). So i recommend to make unique name: 

$cid = 'item_' . $count . '.png';

|

V

$cid = 'item_' . strval($item_id) . '.png';



0 Votes

C

Clotilde posted about 6 years ago

After cache refresh of my browser it's all fine but the link to fancy product disappeared from the eMail...

 

0 Votes

C

Clotilde posted about 6 years ago

 Hi, I did all Oval said and thumbnails appear all fine in the cart.

But at the eMail level, the modification of email-order-items.php drives me to a blank page...

Do you have an idea?

For information, I have cutomizable products and other products also

 

0 Votes

A

Alex posted about 6 years ago

i will try this, thanks!

 

0 Votes

O

Oval posted about 6 years ago

2. Now as mention above:

in yourtheme/woocommerce/emails/email-order-items.php (copy it from plugin templates dir) edit:

$count = 1;

foreach ( $items as $item_id => $item ) :

...

...

do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );

                $cid = 'item_' . $count . '.png';

                $img = $item['_fpd_data']['fpd_product_thumbnail'];

                if($img)

                {

                    echo '<br>Product:<br>';

                    echo '<img src="cid:';

                    echo $cid;

                    echo '">';

 

                $imgdata = base64_decode(explode(',',$img)[1]);

                #$imgdata = explode(',',$img)[1];

 

                    add_action( 'phpmailer_init', function($phpmailer)use($cid, $imgdata){

                    //$phpmailer->SMTPKeepAlive = true;

                    write_log('cid = ' . $cid);

                    write_log('imgdata = ' . $imgdata);

                    $phpmailer->addStringEmbeddedImage($imgdata, $cid, $cid, 'base64', 'image/png');

                    remove_action( 'phpmailer_init', __function__ );

                });

                }

                $count++;

...


3. (Optional) Now suppose you want to see not only first view thumbnail of product but all of them?:

Go for "fancy-product-designer/woo/class-wc-product.php" and change "fancyProductDesigner.viewInstances[0].toDataURL(function(dataURL) {" to "fancyProductDesigner.getProductDataURL(function(dataURL) {" in two places.  Viola! 

0 Votes

O

Oval posted about 6 years ago

Once again for v 3.7.0

1. We need to correct bugs in FancyProductDesigner due to it don't save order thumbnails in "woocommerce_order_itemmeta" table:

1.1 Change all  'fpd_data' (with quota) in "fancy-product-designer/woo/class-wc-cart.php" to '_fpd_data' (with quota) - 33 entries.

1.2 Change  in "fancy-product-designer/woo/class-wc-order.phpfunction add_order_item_meta:

  

		public function add_order_item_meta( $item_id, $item ) {
		 
			$fpd_data = null;
			if( isset( $item->legacy_values['_fpd_data'] ) )  // WC 3.0+
				$fpd_data = $item->legacy_values['_fpd_data'];
			else if( isset( $item['_fpd_data'] ) )  // WC <3.0
				$fpd_data = $item['_fpd_data'];

			if( !is_null($fpd_data) ) {
				wc_add_order_item_meta( $item_id, '_fpd_data', $fpd_data);
			}
		} 

Now custom thumbnails will be saved.

To be continued...    



0 Votes

A

Alex posted about 6 years ago

Did anyone find a solution for this?? I really need this feature.

 

0 Votes

O

Oval posted over 6 years ago

it is possible only in 3.4.8 or below (after that FPD didn't store image in (_)fpd_data meta field due some mistaken code)

in yourtheme/woocommerce/emails/email-order-items.php (copy it from plugin):

$count = 1;

foreach ( $items as $item_id => $item ) :

...

...

do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );

                $cid = 'item_' . $count . '.png';

                $img = $item['_fpd_data']['fpd_product_thumbnail'];

                if($img)        

                {

                    echo '<br>Эскизы сторон:<br>';

                    echo '<img src="cid:';

                    echo $cid;  

                    echo '">';

                    

                $imgdata = base64_decode(explode(',',$img)[1]);

                #$imgdata = explode(',',$img)[1];

                    

                #write_log('img = ' . $imgdata);

                    add_action( 'phpmailer_init', function($phpmailer)use($cid, $imgdata){

                    //$phpmailer->SMTPKeepAlive = true;

                    write_log('cid = ' . $cid);

                    write_log('imgdata = ' . $imgdata);

                    $phpmailer->addStringEmbeddedImage($imgdata, $cid, $cid, 'base64', 'image/png');

                    remove_action( 'phpmailer_init', __function__ );

                });

                }

                $count++;


0 Votes

Andreas

Andreas posted over 6 years ago

Same here. Did anyone find a way to change the Admin Order Screen thumbnail?

0 Votes

k

kamran posted over 6 years ago

Hi i want to achieve same, i want to show customized image show in thankyou page or in email template if anyone solve this plz share the code if someone solves this

 

0 Votes

S

Sascha Retschitzegger posted almost 7 years ago

Hi,
it works fine for me on the email-template.
But is there a solution for the review-order-Page, too?
With this little code it will show the original thumb 
<?php $thumbnail = apply_filters( 'woocommerce_in_cart_product_thumbnail', $_product->get_image(), $values, $cart_item_key ); echo $thumbnail; ?>

but when I'll change this with the "filter" for the e-mail-image


woocommerce_order_item_thumbnail

 That will show only the original Thumb not the designed.

 

 Is there a quick solution?


It would make sense that the designed image will displayed on my orders. The color-settings, too. Or?


Thanks!

0 Votes

N

Natalie Savage posted about 7 years ago

This code doesn't work for me as well. 

0 Votes

Oktay Acikalin

Oktay Acikalin posted over 7 years ago

Hi Christian,


thank you for your code. Unfortunately the image is appearing as broken. There is some base64 content in there. Does it work on your installation? Can you assist me?


Thanks!

0 Votes

C

Christian Nießing posted over 7 years ago

 Try to add the following code to your theme functions. That should change the thumbnail to fancy product thumbnail. Let me know if it works. I would recommend to add this function to the plugin in general as it's an important feature.

function change_email_item_thumbnail($thumbnail, $item = null) {

    if (!is_null($item) && isset($item['fpd_data'])) {

        $fpd_data = maybe_unserialize($item['fpd_data']);

        //check if data contains the fancy product thumbnail
        if (isset($fpd_data['fpd_product_thumbnail']) && $fpd_data['fpd_product_thumbnail']) {

            $dom = new DOMDocument;
            libxml_use_internal_errors(true);
            $dom->loadHTML($thumbnail);
            $xpath = new DOMXPath($dom);
            libxml_clear_errors();
            $doc = $dom->getElementsByTagName("img")->item(0);
            $src = $xpath->query(".//@src");

            foreach ($src as $s) {
                $s->nodeValue = $fpd_data['fpd_product_thumbnail'];
            }

            $output = $dom->saveXML($doc);

            return $output;

        }

    }

    return $thumbnail;

}

add_filter('woocommerce_order_item_thumbnail', 'change_email_item_thumbnail', 10, 2);

 

0 Votes

A

Anthony Circosta posted over 7 years ago

Please, yes share the code. I can go ahead and put it in wherever you recommend. Let me know, thanks!

0 Votes

C

Christian Nießing posted over 7 years ago

I am close to have this done. Are you interested in the code?

0 Votes

A

Anthony Circosta posted over 7 years ago

My clients are certainly curious about getting images of the customized product in the order confirmation email....please add this feature!

0 Votes

D

Deleted Agent posted over 7 years ago

With the plugin as it is currently not, no sorry. You could make a feature request for this or support and existing one (I have not checked for one).

0 Votes

Login or Sign up to post a comment