Hide variable that does not exist in the filter

This topic has 6 replies, 2 voices, and was last updated 11 months ago ago by Luca Rossi

  • Avatar: mahdar
    MAHDAR
    Participant
    December 18, 2023 at 14:18

    Hello, I hope you are well

    I want to add a feature

    When the color or size is not available, it should not be displayed in the filter search
    for example :
    The customer enters the shoes category and filters size 40

    And I want the shoes whose size 40 is finished not to be displayed in the filter

    I also used the code below, but it didn’t work
    Thank you for your guidance

    add_filter( 'woocommerce_product_variation_get_available', 'hide_unavailable_variations', 10, 3 );
    
    function hide_unavailable_variations( $available_variations, $product, $variation ) {
        // Check if the variation is available
        if ( ! $variation->is_in_stock() ) {
            // If not available, remove it from the list of available variations
            foreach ( $available_variations as $key => $value ) {
                if ( $value['variation_id'] == $variation->get_id() ) {
                    unset( $available_variations[$key] );
                }
            }
        }
    
        return $available_variations;
    }
    5 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    December 19, 2023 at 04:16

    Dear @MAHDAR,

    We wish to inform you that we have encountered difficulties when attempting to access the Private Content area using the provided administrative credentials. It appears that the login details are no longer functioning as expected.

    Could you kindly verify the accuracy of the login information at your earliest convenience?

    Best regards,
    The 8Theme Team

    Avatar: mahdar
    MAHDAR
    Participant
    December 19, 2023 at 07:50

    Hello

    Please login with this

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    December 19, 2023 at 10:14

    Dear @MAHDAR,

    We regret to inform you that currently, there are no available hooks to conceal variations of products that are out of stock.

    However, as an alternative solution, you may apply the following custom CSS code to hide all variations of products that are out of stock. Please navigate to Theme Options > Theme Custom CSS > Global CSS and insert the code provided below:

    
    [data-attribute="pa_groesse"] li.type-label.sten-li-disabled {
        display: none;
    }
    

    We trust this will serve as an effective workaround for your requirements.

    Best regards,
    The 8Theme Team

    Avatar: mahdar
    MAHDAR
    Participant
    December 19, 2023 at 10:22

    Thank you very much, can you do this in custom service?

    Avatar: Justin
    Luca Rossi
    Support staff
    December 19, 2023 at 10:38

    Hi @MAHDAR,

    If you wish our developers team can personally assist you via our customization service.
    To get started, please follow this link to send us your requirements – https://prnt.sc/PZkD4AEf27qO https://www.8theme.com/account/#etheme_customization_panel , and we will prepare a detailed estimate for the customization work. Our goal is to create a design that aligns with your vision and enhances your website’s appearance and functionality.
    Customize your website to suit your needs and make it stand out with our expert dev team.

    Best regards,
    The 8Theme Team

  • Viewing 6 results - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.