Do not update woocommerce_order_items if nothing changed

Do not update the item (`woocommerce_order_items`) unless something changed.
This commit is contained in:
Cesar Rodas 2017-03-25 00:30:12 -03:00
parent 3946654b29
commit f2f6d76f6d
1 changed files with 9 additions and 5 deletions

View File

@ -59,11 +59,15 @@ abstract class Abstract_WC_Order_Item_Type_Data_Store extends WC_Data_Store_WP i
public function update( &$item ) { public function update( &$item ) {
global $wpdb; global $wpdb;
$changes = $item->get_changes();
if ( ! empty( $changes ) ) {
$wpdb->update( $wpdb->prefix . 'woocommerce_order_items', array( $wpdb->update( $wpdb->prefix . 'woocommerce_order_items', array(
'order_item_name' => $item->get_name(), 'order_item_name' => $item->get_name(),
'order_item_type' => $item->get_type(), 'order_item_type' => $item->get_type(),
'order_id' => $item->get_order_id(), 'order_id' => $item->get_order_id(),
), array( 'order_item_id' => $item->get_id() ) ); ), array( 'order_item_id' => $item->get_id() ) );
}
$this->save_item_data( $item ); $this->save_item_data( $item );
$item->save_meta_data(); $item->save_meta_data();