RVandenbussche
Forum Replies Created
-
Forum: Reviews
In reply to: [Meta Box] Superb supportAfter restoring a back-up and deactivating the plugin the problem still persisted. It looks like the problem is not from the Meta Box plugin. I will adjust my review, thank you for the quick support reply.
Ok, I got it somewhat working now. It only shows all the colours not the only ones in stock.
add_action( 'woocommerce_after_shop_loop_item', 'sm_display_product_color_options', 9 ); function sm_display_product_color_options(){ global $woocommerce, $product; $variation_colors_data = $product->get_attributes(); $variation_colors_data = $variation_colors_data['pa_farben']; $variation_colors = $variation_colors_data['options']; echo "<div class='product_colors_container'>"; foreach ($variation_colors as $variation_color) { $image = get_term_meta($variation_color,'image',true); $image = wp_get_attachment_image_src($image, 'thumbnail', false); $image = $image[0]; echo '<span class="swatch swatch-image"><img src=' . $image . ' style="height: 20px; width: 20px; margin-right: 5px;"></span>'; } echo "</div>"; }
@thmsggn Good to hear! Probably some css stuff.
@saurabhj91 I couldn’t find a way to make a proper var_dump, I only get back int(25), int(28), etc. I’m not that technical. Do you have any idea to get the swatch image url back?
@thmsggn You probably need to use ‘pa_couleur’ instead of ‘couleur’.
@thmsggn If that happens you’re not using the right attribute name. Replace pa_color for your attribute slug.
@saurabhj91, I’ve tried changing it and it works but since I’m using images instead of colours I need some other syntax in the html get something back. Do you know what i need to fill in? ‘image’ doesn’t work.
@thmsggn, Ok will it might be hard to tell then. But can you confirm you’ve implemented the code in the functions.php in the child-theme? If you’ve implemented it correctly you should at least see “<div class=’product_colors_container’></div>” in your source code on the product archive page. Can you check if that’s the case?
@thmsggn Can you please provide the website you’re working on? Without it would be guesswork.
@saurabhj91 I think I’ve tried that already, but will retry it tonight. I also use image-swatches instead of colour-swatches. Probably I need to modify the outputted HTML anyway, but let’s first get something on the screen.
Thanks @saurabhj91! Your efforts are appreciated.
@saurabhj91 I can’t seem to get it to work. I’ve tried to change the ‘pa_color’ but doesn’t do a thing. I also don’t know what I need to fill in in the “$variation_colors = $variation_colors_data[‘options’];”
Let me know if you have an idea. I’m working on https://speedropeshop.de
I’ve found a paid plugin ($25) that does the trick: https://codecanyon.net/item/wooswatches-woocommerce-color-or-image-variation-swatches/7444039. Haven’t tried it yet let me know if you’ve tested it.
I need this as well.