Sunday, 17 February 2019

Multiple thumbnails in checkout section on woocommerce/fancy product designer

I'm trying to output multiple thumbnails from my checkout instead of just showing one product image - users can design their own up to 6 different images via. fancy product designer.

enter image description here (example photo)

$dom = new DOMDocument;
libxml_use_internal_errors(true);
$dom->loadHTML( $thumbnail );
$xpath = new DOMXPath( $dom );
libxml_clear_errors();

$doc = $dom->getElementsByTagName("img")->item(1);
$src = $xpath->query(".//@src");
$srcset = $xpath->query(".//@srcset");

// custom image from customer 
foreach ( $src as $s ) {
    $s->nodeValue = $fpd_data['fpd_product_thumbnail'];
}
foreach ( $srcset as $s ) {
    $s->nodeValue = $fpd_data['fpd_product_thumbnail'];
}
return $dom->saveXML( $doc );

I use a foreach to loop through the images from fancy product designer. But it's like it's just lists the first image in my checkout.

Any idea if it's even possible or I should use another approach in the class-wc-cart.php file in woocommerce. Thanks.



from Multiple thumbnails in checkout section on woocommerce/fancy product designer

No comments:

Post a Comment