Home › Forums › WoodMart support forum › Swatches on composite product
Swatches on composite product
- This topic has 3 replies, 2 voices, and was last updated 1 year, 8 months ago by Elise Noromit.
-
AuthorPosts
-
February 14, 2023 at 9:49 pm #443037
NueveeParticipantIs it possible to add swatches like variables have, on composite product?
https://woocommerce.com/document/composite-products/I have this little snippet, that adds the label of color attribute – but it is not shown as an swatch:
if( $product->is_type(‘composite’) ) {
$attributes = $product->get_attributes();
if( isset($attributes[‘pa_color’]) ) {
$attribute_name = $attributes[‘pa_color’]->get_name();
$attribute_value = $product->get_attribute($attribute_name);
$attribute_value = str_replace(‘ ‘, ”, $attribute_value);
$attribute_value = strtolower($attribute_value);
$attribute_value = explode(‘,’, $attribute_value);
$attribute_value = array_unique($attribute_value);
$attribute_value = implode(‘,’, $attribute_value);
$attribute_value = str_replace(‘,’, ‘ ‘, $attribute_value);
echo ‘<div class=”swatch-container”><span class=”swatch-label”>Color:</span><span class=”swatch-value”>’ . $attribute_value . ‘</span></div>’;
}
}
}I know this is out of support for the theme, but I am guessing you may have encountered this question before?
February 15, 2023 at 5:42 am #443114
Elise NoromitMemberHello,
You can create a variable product and configure the swatches in this way: https://woodmart.xtemos.com/shop/accessories/smart-watches-wood-edition/
You can also make every variation as a separate product.
If you need something else, you will need to search for a plugin.
Our support does not cover investigating or fixing custom code.
If you have any questions please feel free to contact us.
Best Regards
February 18, 2023 at 3:04 pm #444268
NueveeParticipantNo problem in creating a variable product. The problem is that swatches in grid (Shop Archives) does not show.
February 19, 2023 at 5:23 am #444365
Elise NoromitMemberHello,
Please remove the custom snippets related to the variable products and insert the site admin access into the Private content below the message area. We will take a closer look at the case.
Best Regards
-
AuthorPosts
Tagged: swatches
- You must be logged in to create new topics. Login / Register