W
W
WebforSelf2020-12-06 16:47:21
WooCommerce
WebforSelf, 2020-12-06 16:47:21

Does not really show the presence of residues in Woocomerce?


I uploaded the balances and need to display whether the product is in stock or

not

UPDATE wp_postmeta
SET meta_value = 'yes'
WHERE meta_key = '_manage_stock'


Made the given request it.

But the problem is that the product still writes "In stock", and when I click to save the product, then it starts to show real balances (Not in stock if 0), each product cannot really be re-stored. Where in base it does not consider now?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pychev Anatoly, 2020-12-06
@pton

This question has been raised time and again.
"Product" in Woo is not just an entry in the database - it is an entity, and changing some field can violate its integrity. And if several more product management plugins are connected, then the normal operation of these plugins will be disrupted.
The correct state change is via code via WC_Product. Yes, it’s long, hard, but you have to break the blocks if there are a lot of goods. But it's safe.

$product = wc_get_product($id);
... делаем что то 
$product->save();

in your case, speaking only about Woo (I mean no other plugins affected by this change), you need to look into the field stock_statusand into the table..._wc_product_meta_lookup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question