@@ 275-285 (lines=11) @@ | ||
272 | add_post_meta( $this->id, '_stock', 0, true ); |
|
273 | ||
274 | // Update stock in DB directly |
|
275 | switch ( $mode ) { |
|
276 | case 'add' : |
|
277 | $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = meta_value + %f WHERE post_id = %d AND meta_key='_stock'", $amount, $this->id ) ); |
|
278 | break; |
|
279 | case 'subtract' : |
|
280 | $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = meta_value - %f WHERE post_id = %d AND meta_key='_stock'", $amount, $this->id ) ); |
|
281 | break; |
|
282 | default : |
|
283 | $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = %f WHERE post_id = %d AND meta_key='_stock'", $amount, $this->id ) ); |
|
284 | break; |
|
285 | } |
|
286 | ||
287 | // Clear caches |
|
288 | wp_cache_delete( $this->id, 'post_meta' ); |
@@ 452-462 (lines=11) @@ | ||
449 | add_post_meta( $this->variation_id, '_stock', 0, true ); |
|
450 | ||
451 | // Update stock in DB directly |
|
452 | switch ( $mode ) { |
|
453 | case 'add' : |
|
454 | $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = meta_value + %f WHERE post_id = %d AND meta_key='_stock'", $amount, $this->variation_id ) ); |
|
455 | break; |
|
456 | case 'subtract' : |
|
457 | $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = meta_value - %f WHERE post_id = %d AND meta_key='_stock'", $amount, $this->variation_id ) ); |
|
458 | break; |
|
459 | default : |
|
460 | $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = %f WHERE post_id = %d AND meta_key='_stock'", $amount, $this->variation_id ) ); |
|
461 | break; |
|
462 | } |
|
463 | ||
464 | // Clear caches |
|
465 | wp_cache_delete( $this->variation_id, 'post_meta' ); |