Quantcast
Channel: WordPress.org Forums » [WooCommerce] Support
Viewing all articles
Browse latest Browse all 102129

nyenius on "[Plugin: WooCommerce - excelling eCommerce] Updating Product Category based on stock status in single product view"

$
0
0

Hi, I have ready stock and backorder items in my store.

What I need to achieve is to group products by their availability (stock status). So the items with 0 (zero) stock should go to "Preorder" category, and the available items should go to "Ready Stock" category.

I can't find any solution to this need. So i try to figure out how to do that, I think 'auto-updating' the product category should solve the problem. I try to write some pseudo code.

add_action('woocommerce_before_single_product', 'check_and_update_category');

function check_and_update_category() {
       // get the stock status of current product
       // if stock is empty, AND one of the item category is 'Ready Stock'
       // Change the product category to "Preorder"
}

I've spent hours trying to write the real code, but still I can't find the functions to update the product's category nor knowing where the relation is stored in the database.

So, I need some help to write the real code, or any solution to solve my problem above.

Thanks in advance

http://wordpress.org/extend/plugins/woocommerce/


Viewing all articles
Browse latest Browse all 102129

Trending Articles