Merged in release/release-1.09 (pull request #10)
Release/release 1.09 * Install missing plugins * rs set to 1 * rebase pantheon for aws * rebase pantheon for aws * prod config change * prod config change * fix campaing issue * revert Approved-by: Jay Sharma
This commit is contained in:
committed by
Jay Sharma
parent
779393381f
commit
22f10a9edd
@@ -347,8 +347,6 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
|
||||
} else {
|
||||
add_post_meta( $coupon->get_id(), '_used_by', strtolower( $used_by ) );
|
||||
}
|
||||
|
||||
$this->refresh_coupon_data( $coupon );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,7 +375,6 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
|
||||
if ( $meta_id ) {
|
||||
delete_metadata_by_mid( 'post', $meta_id );
|
||||
$coupon->set_used_by( (array) get_post_meta( $coupon->get_id(), '_used_by' ) );
|
||||
$this->refresh_coupon_data( $coupon );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,8 +405,6 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
|
||||
)
|
||||
);
|
||||
|
||||
$this->refresh_coupon_data( $coupon );
|
||||
|
||||
// Get the latest value direct from the DB, instead of possibly the WP meta cache.
|
||||
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'usage_count' AND post_id = %d;", $id ) );
|
||||
}
|
||||
@@ -561,7 +556,7 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
|
||||
$result = $wpdb->query( $insert_statement ); // WPCS: unprepared SQL ok.
|
||||
if ( false !== $result ) {
|
||||
// Clear meta cache.
|
||||
$this->refresh_coupon_data( $coupon );
|
||||
wp_cache_delete( WC_Coupon::generate_meta_cache_key( $coupon->get_id(), 'coupons' ), 'coupons' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -656,7 +651,7 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
|
||||
$result = $wpdb->query( $insert_statement ); // WPCS: unprepared SQL ok.
|
||||
if ( false !== $result ) {
|
||||
// Clear meta cache.
|
||||
$this->refresh_coupon_data( $coupon );
|
||||
wp_cache_delete( WC_Coupon::generate_meta_cache_key( $coupon->get_id(), 'coupons' ), 'coupons' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -698,18 +693,6 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
|
||||
); // WPCS: unprepared SQL ok.
|
||||
}
|
||||
|
||||
/**
|
||||
* This function clears coupon data from the WP cache after certain operations which, for performance reasons,
|
||||
* are done via SQL queries.
|
||||
*
|
||||
* @param \WC_Coupon $coupon The coupon object.
|
||||
* @return void
|
||||
*/
|
||||
private function refresh_coupon_data( &$coupon ) {
|
||||
wp_cache_delete( $coupon->get_meta_cache_key(), 'coupons' );
|
||||
wp_cache_delete( $coupon->get_id(), 'post_meta' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a coupon code for a specific ID.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user