• Resolved aovivo

    (@aovivo)


    Hi there I am interested in having swatches for weight (coffee) and then secondly a dropdown to choose the option fro ground coffee (for filter, espresso machine, french press) …

    – like in the example here: https://www.leuchtfeuer.coffee/products/amoruso

    Is it possible with your plugin to combine variation swatches with attributes dropdown?
    thanks in advance

Viewing 1 replies (of 1 total)
  • Plugin Support Shravan Bhaskaravajjula

    (@bhshravankumar)

    Hello @aovivo,

    We have a filter code using which you can keep a variation as a dropdown only while other variations can be styled using variation swatch options.

    1. Please update the variation swatches plugin to the latest version.

    2. Please add this filter code to your child theme’s functions.php -or- use a code snippets plugin to add this filter code.

    add_filter(‘cfvsw_is_custom_attr_filter’, function( $default_value, $attribute ){

    // Check attribute.
    $attribute_name = !empty( $attribute[ 'attribute' ] ) ? $attribute[ 'attribute' ] : '';
    
    // Excluded attributes.
    $excluded_attributes = [ "pa_color" ];
    if( ! empty( $excluded_attributes ) && in_array( $attribute_name, $excluded_attributes ) ){
        return false;
    }
    
    return $default_value;}, 10, 2 );


    Steps to use the filter –

    1. Add this filter code to your child theme’s functions.php -or- use a code snippets plugin to add this code
    2. Add the attribute name you want to exclude in the $excluded_attributes array.

    How to get the global attribute name? Please refer to this screenshot.

    1. Go to the WordPress dashboard.
    2. Click on the product tab pointer 1.
    3. Click on attribute tab pointer 2.
    4. In pointer 3 you get the attribute name just add the prefix pa_ on this slug ex – your slug is color then your attribute name will be pa_color

    How to get a custom attribute name? Please refer to this screenshot.

    1. Go to the WordPress dashboard click on the product tab and click on all products Pointer 1.
    2. Chose product.
    3. Go to the product data section and open the tab Pointer 2.
    4. Click on attribute Pointer 3.
    5. Click on custom attribute Pointer 4.
    6. Here you get the name of the custom attribute you don’t need to add any prefix or suffix on this just copy the name?Pointer 5.

    Hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Add swatches for Variations and then dropdown for attributes’ is closed to new replies.