• Resolved vaibhavbthl

    (@vaibhavbthl)


    Hi, I am using the basic storefront theme. My labels are not showing up in the category page, they are only showing up on the product page itself. Labels are not showing on this page but they will show up when you click the product – https://www.rudragems.com/product-category/rudraksha/1-mukhi-rudraksha/

    I have already cleared the cache and have disabled nitropack temporarily but that didn’t solve the issue so its not due to cache. Please let me know how to fix this.

    Thanks

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    Please tell me – inside your theme do you have code similar to this one:

    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;
    }
    

    This code changes product queries and puts out of stock products to the end of products list.

    Regards

    Thread Starter vaibhavbthl

    (@vaibhavbthl)

    Hi, yes I have this same exact code in my functions.php but this code was always there. When I first installed this plugin, it was working fine. I think this issue occured in the the last couple of updates.

    Thanks

    Plugin Author ILLID

    (@mihail-barinov)

    I think this issue appears after some WooCommerce update. Anyway please try to change this code to the following one:

    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()) && strpos( $posts_clauses['where'], 'awl-labels' ) === false ) {
    	$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;
    }
    Thread Starter vaibhavbthl

    (@vaibhavbthl)

    Hi, replacing the code with the one you provided worked and the labels are now showing.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Labels not showing up on the category page’ is closed to new replies.