Removed the extra parameter that didn't make sense.
Also get_data_for_lookup_table should not be checking db value of _manage_stock as that can be in the process of being changed.
This commit is contained in:
parent
35c63ee475
commit
68a325249f
|
@ -555,10 +555,9 @@ class WC_Data_Store_WP {
|
|||
* @since 3.6.0
|
||||
* @param int $id ID of object to update.
|
||||
* @param string $table Lookup table name.
|
||||
* @param bool $ignore_manage_stock If set to true, stock quantity will be returned regardless of _manage_stock meta value on the product.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_data_for_lookup_table( $id, $table, $ignore_manage_stock = false ) {
|
||||
protected function get_data_for_lookup_table( $id, $table ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -579,11 +578,10 @@ class WC_Data_Store_WP {
|
|||
* @since 3.6.0
|
||||
* @param int $id ID of object to update.
|
||||
* @param string $table Lookup table name.
|
||||
* @param bool $force_qty_update If set to true, stock quantity for update of lookup table will be read from the database regardless of manage stock setting on the product.
|
||||
*
|
||||
* @return NULL
|
||||
*/
|
||||
protected function update_lookup_table( $id, $table, $force_qty_update = false ) {
|
||||
protected function update_lookup_table( $id, $table ) {
|
||||
global $wpdb;
|
||||
|
||||
$id = absint( $id );
|
||||
|
@ -594,7 +592,7 @@ class WC_Data_Store_WP {
|
|||
}
|
||||
|
||||
$existing_data = wp_cache_get( 'lookup_table', 'object_' . $id );
|
||||
$update_data = $this->get_data_for_lookup_table( $id, $table, $force_qty_update );
|
||||
$update_data = $this->get_data_for_lookup_table( $id, $table );
|
||||
|
||||
if ( ! empty( $update_data ) && $update_data !== $existing_data ) {
|
||||
$wpdb->replace(
|
||||
|
|
|
@ -1324,8 +1324,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
// Sometimes I wonder if it shouldn't be part of update_lookup_table.
|
||||
wp_cache_delete( $product_id_with_stock, 'post_meta' );
|
||||
|
||||
// Stock qty in lookup table might not be set to the same value here due to manage_stock not being set to true, thus using force update.
|
||||
$this->update_lookup_table( $product_id_with_stock, 'wc_product_meta_lookup', true );
|
||||
$this->update_lookup_table( $product_id_with_stock, 'wc_product_meta_lookup' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1998,14 +1997,12 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
* @since 3.6.0
|
||||
* @param int $id ID of object to update.
|
||||
* @param string $table Lookup table name.
|
||||
* @param bool $ignore_manage_stock If set to true, stock quantity will be returned regardless of _manage_stock meta value on the product.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_data_for_lookup_table( $id, $table, $ignore_manage_stock = false ) {
|
||||
protected function get_data_for_lookup_table( $id, $table ) {
|
||||
if ( 'wc_product_meta_lookup' === $table ) {
|
||||
$price_meta = (array) get_post_meta( $id, '_price', false );
|
||||
$manage_stock = get_post_meta( $id, '_manage_stock', true ); // while product is being modified, manage stock could be 'no' in the db, but we want to change the stock qty anyway.
|
||||
$stock = 'yes' === $manage_stock || $ignore_manage_stock ? wc_stock_amount( get_post_meta( $id, '_stock', true ) ) : null;
|
||||
$stock = wc_stock_amount( get_post_meta( $id, '_stock', true ) );
|
||||
$price = wc_format_decimal( get_post_meta( $id, '_price', true ) );
|
||||
$sale_price = wc_format_decimal( get_post_meta( $id, '_sale_price', true ) );
|
||||
return array(
|
||||
|
|
Loading…
Reference in New Issue