Home Forums WoodMart support forum Related Products: Sold Out Products at Bottom of Page

Related Products: Sold Out Products at Bottom of Page

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #529168

    mohaxs
    Participant

    Hello…

    1. I prefer to put sold outs products at bottom of page rather than complete hiding the sold out products at entire the shop. I use code below in functions.php and working perfectly at shop page, category, and brand or tag archive. But still appear in the “Related Products”. Can you give some code to hide it in the related products?

    It will be amazing if you can implement it into the theme setting directly in the next update.

    if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
        add_filter('posts_clauses', 'order_by_stock_status', 2000);
    }
    
    function order_by_stock_status($posts_clauses) {
        global $wpdb;
      
        if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag())) {
    	$posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) ";
    	$posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
    	$posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where'];
        }
    	return $posts_clauses;
    }

    2. How to configure Related Product? For example show by tag or categories. I don’t see configuration in the theme setting, just on or off option there.

    You can see my shop at private area. Thank you

    #529272

    Luke Nielsen
    Keymaster

    Hello,

    1. I suggest you use our Layouts for product page, there is an option that gives the ability to hide out-of-stock products without any additional custom code. https://prnt.sc/X4w9DDgr97D6

    2. In general, the “Related Products” comes from WooCommerce so we have an option just for disabling/enabling it.

    Kind Regards

    #529332

    mohaxs
    Participant

    I was do it in my front page Ajax Products Tabs. Any guide to import prebuilt layout? Not from scratch even it done by drag and drop. I don’t see import options from layouts admin bar.

    #529342

    Luke Nielsen
    Keymaster

    Hello,

    Here is a video with more details on how to set the prebuilt layout: https://gyazo.com/e5387fb78879e53b6e4ed7ce79fd12f7

    In the meantime, feel free to ask me any questions you may have.

    Kind Regards

    #529346

    mohaxs
    Participant

    I’ve try so many times but still goes to blank canvas page. Am I missing something or some Woodmart setting? Or it’s normal?

    https://drive.google.com/file/d/1Re2_Ha15IjXi9twbJZklbUGb3aZ9T_GI/view?usp=sharing

    #529352

    Luke Nielsen
    Keymaster

    Hello,

    It’s weird. Please send me access to the admin dashboard so I can check it on your side.

    Thank you in advance.

    Kind Regards

    #529366

    mohaxs
    Participant

    Access in private content. One more, If it’s work, that’s mean I can change shop page using the template without losing any data right? I mean it’s doesn’t same with import prebuilt website.
    Thank you.

    #529745

    Luke Nielsen
    Keymaster

    Hello,

    I see that you have some additional code in functions.php file in your child theme so pleasetry to enable the parent theme and import the content again.

    The data should be saved, at any time you can disable layouts (https://prnt.sc/_t60HS8jEDjs) thus the default archive/product pages will be enabled.

    Kind Regards

    #529788

    mohaxs
    Participant

    Thank you for your assistance… It’s work. You can mark it solved!

    #529851

    Luke Nielsen
    Keymaster

    Hello,

    You are welcome! In case you need any additional help, I’d be more than happy to assist you.

    Wish you all the best.

    Kind Regards

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Related Products: Sold Out Products at Bottom of Page’ is closed to new replies.