You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a variable product with couple of valid variations. After saving the product from the admin page there is no price html in the front product page.
What I saw so far ?
Searching how the price html is processing and found that the _price meta data for this product is empty string.
I went deeper and found that the _price metadata is updated twice in every product save execution:
once in includes/admin/meta-boxes/class-wc-meta-box-product-data.php:996 and once in includes/class-wc-product-variable.php:809 . in the first time it always update empty string and in the second time it process sync method that update it properly.
So whats the problem ?
I'm working with replication DB and hyperDB WP Plugin. Lets see the problem step by step:
The current value of _price is 199
Performs update_post_meta( $post_id, '_price', '' ); - _price is updated in master DB, metadata cache deleted.
Performs update_post_meta( $product_id, '_price', $min_price ); - where $min_price is 199, update_metadata functions first check the current value and get the result from the slave DB that haven't being updated yet from the master and get the value 199 which is equal to the $min_price, hence, the metadata is not updated , cache is not set and false is returned.
Slave DB is updating from master with the wrong value of empty string.
Next time get_post_meta( $post_id, '_price', true ); will return empty string.
My questions is:
Do we really need to maintain _price metadata in variable products ? WC_Product_Variable::get_price_html method is checking this value first, and then uses get_variation_prices which is much more efficient
If the answer to 1 is yes. Why to do it twice ?
Is my issue with the replication DB is a general problem ?
Thanks ahead
The text was updated successfully, but these errors were encountered:
@sh-guti I see what you mean, but surely this is a problem with the hyperDB plugin if it cannot update values correctly? Meta data (from any plugin!) doesn't necessarily only get set once per session.
Hello,
I want to share with you a problem
What is the symptom?
I have a variable product with couple of valid variations. After saving the product from the admin page there is no price html in the front product page.
What I saw so far ?
Searching how the price html is processing and found that the _price meta data for this product is empty string.
I went deeper and found that the _price metadata is updated twice in every product save execution:
once in
includes/admin/meta-boxes/class-wc-meta-box-product-data.php:996
and once inincludes/class-wc-product-variable.php:809
. in the first time it always update empty string and in the second time it process sync method that update it properly.So whats the problem ?
I'm working with replication DB and hyperDB WP Plugin. Lets see the problem step by step:
update_post_meta( $post_id, '_price', '' );
- _price is updated in master DB, metadata cache deleted.update_post_meta( $product_id, '_price', $min_price );
- where $min_price is 199,update_metadata
functions first check the current value and get the result from the slave DB that haven't being updated yet from the master and get the value 199 which is equal to the $min_price, hence, the metadata is not updated , cache is not set and false is returned.get_post_meta( $post_id, '_price', true );
will return empty string.My questions is:
WC_Product_Variable::get_price_html
method is checking this value first, and then usesget_variation_prices
which is much more efficientThanks ahead
The text was updated successfully, but these errors were encountered: