Home › Forums › WoodMart support forum › Image swatches for variable products
Image swatches for variable products
- This topic has 6 replies, 2 voices, and was last updated 2 months ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
February 10, 2025 at 6:22 pm #636960
kubiq.skParticipantHello,
how can we activate image swatches for a specific product attribute?
We don’t want to define image per every term in that taxonomy, but we want to define only images per product variations so it should load that variation image into the Image swatch on the product detail page.
If there is no way how to achieve this in admin, then maybe some action/filter hook in the PHP code?
ThanksFebruary 11, 2025 at 12:10 pm #637137
Aizaz Imtiaz AwanKeymasterHello,
To enable this feature,
1. Enable the “Use images from product variations” in Theme Settings > Shop > Variable products: https://prnt.sc/SLKIoDeCW
2. Define the image for the variation in the settings of the product – https://prnt.sc/nmOUHmnlVId0
3. Enable the “Text swatch” for the attributes – https://prnt.sc/-J5sJSTq4C3V
4. Navigate to Theme Settings > Shop > Variable products > set the as “Grid swatch attribute to display”: https://prnt.sc/YqWQY2EvNQ2j
When this option is enabled, the swatches will automatically use the images assigned to product variations instead of the images uploaded to attribute terms. This allows you to display variation images dynamically without having to define images for each attribute term separately.
Best Regards,
February 11, 2025 at 12:22 pm #637142
kubiq.skParticipantWhere can i find “3. Enable the “Text swatch” for the attributes” ?
In/wp-admin/edit.php?post_type=product&page=product_attributes&edit=1
I can see this https://i.imgur.com/iOS8jNY.pngFebruary 11, 2025 at 3:05 pm #637201
Aizaz Imtiaz AwanKeymasterHello,
Navigate to Attributes > Edit Attributes > Configure terms > edit any value > and enable the text swatch.
https://ibb.co/HfGXqqsjPlease check this manual:
https://xtemos.com/docs-topic/variable-products-and-swatches/Best Regards,
February 12, 2025 at 12:27 am #637323
kubiq.skParticipantok, thanks, but obviously there is another problem and that is default woocommerce_ajax_variation_threshold that is 30 and I have more variations eg. 34 and this will cause that $available_variations that you use in /add-to-cart/variable.php is not containing actual variations but it is FALSE instead.
you can find this filter hook in /plugins/woocommerce/includes/wc-template-functions.php to see what I mean
so I changed this in the child theme with add_filter to 100 and now it is working
February 12, 2025 at 1:06 am #637327
kubiq.skParticipantok actually there are more problems… please test this with product that has more than 30 variations… you will see it’s not working on the product detail page and also in the shop listing…
currently I had to override you function woodmart_has_swatches in my child theme and add there a few lines at the beginning:
if( $available_variations === false ){
global $product;
$available_variations = $product->get_available_variations();
}February 12, 2025 at 1:14 pm #637474
Aizaz Imtiaz AwanKeymasterHello,
Try to increase the “AJAX variation threshold” option in Theme Settings -> Shop -> Variable products: https://prnt.sc/x_BOGCelUZQ7 and check the issue.
Best Regards,
-
AuthorPosts
Tagged: Attributes, swatches, variations
- You must be logged in to create new topics. Login / Register