• Resolved stuartgre

    (@stuartgre)


    If you set up variable products that can only be exact matches, can you make it automatically select the options that relate to that variation rather than making the user click the only remaining option?

    e.g.

    e.g.

    Product Name
    1 Door Nest of 1 – 305mm deep
    1 Door Nest of 2 – 305mm deep

    Dimension
    (H) 1974 x (W) 305 x (D) 305mm
    (H) 1974 x (W) 610 x (D) 305mm

    Code / SKU
    L/305/1/1
    L/305/1/2
    Now, if you select the first option then it looks like this

    Product Name
    1 Door Nest of 1 – 305mm deep

    Dimension
    (H) 1974 x (W) 305 x (D) 305mm

    Code / SKU
    L/305/1/1

    And then just automatically select the dimension and code?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    This isn’t possible out of the box although one could tweak the behaviour using custom JavaScript code. Given the extent of the coding involved, we recommend getting in touch with a web developer on one of the customisation experts listed at https://woocommerce.com/customizations/ to look into that for you.

    Thread Starter stuartgre

    (@stuartgre)

    Ok, for any one else looking for this kind of functionality, this is how I did it

    $(‘select#name option’).each(function(i) {
    $(this).attr(‘data-id’, i);
    });

    $(‘select#name’).on(‘change’, function() {
    $(‘select#dimensions’).find(‘option’).eq($(this).find(‘:selected’).data(‘id’)).attr(‘selected’, ‘selected’);
    $(‘select#product-code’).find(‘option’).eq($(this).find(‘:selected’).data(‘id’)).attr(‘selected’, ‘selected’);
    });

    I first gave each option a unique identifier (an ID) and then on change of the select passed in the ID to the eq() method and applied this to any variation I required be updated.

    Hope this helps someone else out.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Variable product, automatically select options with exact match’ is closed to new replies.