Stock quantity hook not working on Xstore

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

  • Avatar: jaswinders
    jaswinders
    Participant
    February 7, 2024 at 07:19

    We would need to show the quantity currently available in stock, next to the product pricing on the Shop page. We have tried adding the below hook but this is not working. Please fix the issue.

    add_action( ‘after_etheme_product_grid_list_product_element_title’, ‘webarro_show_stock_shop’, 10 );
    function webarro_show_stock_shop() {
    global $product;
    echo wc_get_stock_html( $product );
    }

    Please, contact administrator
    for this information.
    Files is visible for topic creator and
    support staff only.
    1 Answer
    Avatar: Justin
    Luca Rossi
    Support staff
    February 7, 2024 at 09:41

    Dear Jaswinders,

    We hope this message finds you well.

    Please find below the correct hook for your reference:

    
    add_action( 'woocommerce_after_shop_loop_item_title', 'webarro_show_stock_shop', 99 );
    function webarro_show_stock_shop() {
        if(is_shop()){
            echo '<div class="custom-stock">';
            etheme_show_single_stock();
            echo '</div>';
        }
    }
    

    We have included a conditional statement to ensure that the custom stock information is displayed exclusively on the SHOP page. Additionally, we have encapsulated the output within a DIV element to facilitate the application of custom CSS styling:

    
    div.custom-stock p {
        /* Custom CSS here */
    }
    

    Should you require any further assistance or have any queries, please do not hesitate to contact us.

    Best regards,

    The 8Theme Team

  • Viewing 2 results - 1 through 2 (of 2 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.