Home Forums Plugins WooCommerce Product Variations Swatches Issue with Out-of-Stock Variation Display in Product List

Issue with Out-of-Stock Variation Display in Product List

  • Author
    Posts
  • #163690

    harunstudio
    Participant

    Dear Support Team,

    I am currently using your WooCommerce Product Variations Swatches plugin on my WooCommerce site. The plugin is very helpful, but I’ve recently encountered a problem that I can’t resolve on my own.

    On my product list page, I display only the size attribute for my products. I noticed that when a certain variation is out of stock, the size attribute is still shown instead of being blurred or marked with an ‘X’ icon.

    I’ve reviewed the settings in your plugin, particularly the ‘Disable out of stock variation items’ setting under the ‘Swatches on Product List’ tab. I understand that this setting won’t work for products whose number of variations is greater than the ‘Ajax variation threshold’. However, I’ve made sure that the number of variations for the product in question is less than the ‘Ajax variation threshold’.

    I’ve also tried to resolve this issue using a custom code snippet to change the display of out-of-stock product variations, but this has not been successful.

    Here is the snippet I tried:

    function custom_variation_is_active( $active, $variation ) {
        if ( ! $variation->is_in_stock() ) {
            return false;
        }
        return $active;
    }
    add_filter( 'woocommerce_variation_is_active', 'custom_variation_is_active', 10, 2 );
    

    Can you please help me understand why the out-of-stock variations are still displayed and suggest a possible solution? I would appreciate your guidance on this issue.

    Best Regards,

You must be logged in to see replies to this topic. Click here to login or register