Read this if woocommerce help needed
-
This is not a request help, please excuse me if I posted something I shouldn’t have.
I have been looking for help with woocommerce, couldn’t find anything, so I had to find my own solution. I thought maybe someone else could use it.
I’m a beginner, and I know how hard is to find a script or an explanation you can really understand and apply in your own case. So…
In my case, I needed two featured images for my products, one to display in the shop page, and the other in the single product page. Now, these are the steps to follow:
1. Install the Multiple Featured Images plugin.
2. Add this to your theme functions.php:
add_filter( 'kdmfi_featured_images', function( $featured_images ) { $args = array( 'id' => 'product-image-detail', 'desc' => 'The detail image of the product.', 'label_name' => 'Product detail image', 'label_set' => 'Set product detail image', 'label_remove' => 'Remove product detail image', 'label_use' => 'Set product detail image', 'post_type' => array( 'product' ), ); $featured_images[] = $args; return $featured_images; });
3. Go to plugins\woocommerce\includes\wc-template-functions.php
4. Look for this code:
if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) { /** * Get the product thumbnail for the loop. */ function woocommerce_template_loop_product_thumbnail() { echo woocommerce_get_product_thumbnail(); // WPCS: XSS ok. } }
5. Replace this line:
echo woocommerce_get_product_thumbnail(); // WPCS: XSS ok.
with this line:
kdmfi_the_featured_image ( "product-image-detail", "full");
6. Open any product in the admin area.
Add as “Product Image” the image you want to use on the single product page.
Add as “Product detail image” the image you want to use on the shop page.Ta-da!
That’s it ??
- The topic ‘Read this if woocommerce help needed’ is closed to new replies.