Update reserved stock when a row already exists

This commit is contained in:
Mike Jolley 2020-06-18 12:09:57 +01:00
parent 3763d3b428
commit 00f1246553
1 changed files with 1 additions and 1 deletions

View File

@ -160,7 +160,7 @@ final class ReserveStock {
INSERT INTO {$wpdb->wc_reserved_stock} ( `order_id`, `product_id`, `stock_quantity`, `timestamp`, `expires` )
SELECT %d, %d, %d, NOW(), ( NOW() + INTERVAL %d MINUTE ) FROM DUAL
WHERE ( $query_for_stock FOR UPDATE ) - ( $query_for_reserved_stock FOR UPDATE ) >= %d
ON DUPLICATE KEY UPDATE `expires` = VALUES( `expires` )
ON DUPLICATE KEY UPDATE `expires` = VALUES( `expires` ), `stock_quantity` = VALUES( `stock_quantity` )
",
$order->get_id(),
$product_id,