Home Forums WoodMart support forum Swatches on composite product

Swatches on composite product

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #443037

    Nuevee
    Participant

    Is 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?

    #443114

    Hello,

    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

    #444268

    Nuevee
    Participant

    No problem in creating a variable product. The problem is that swatches in grid (Shop Archives) does not show.

    #444365

    Hello,

    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

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)