Hide variations that don't match Woocommerce

2019-02-24 09:54发布

问题:

So I'm currently working on a Woocommerce store that has lots of variations.

What I'm basically looking for is for the next variation to refresh based on what was chosen on the variation chosen before that.

For example, If you go on http://freelance.tstwebdesign.co.uk/platino/product/plain-platinum-court/ (Apologies for the slow load time) I want to choose a selection from "Width" which should then refresh "Depth" showing only the depths available that match with that width.

Is this possible?

Thanks!

回答1:

It's default function for not many variations. For many variations you can do it with function

    // Woo Commerce – Make Variations only appear when available
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 500;
}

add_filter( ‘woocommerce_ajax_variation_threshold’, ‘custom_wc_ajax_variation_threshold’, 10, 2 );