SQL;
if ($payloadExists) { $sql = <<<'SQL'
INSERT INTO `cart` (`token`, `currency_id`, `shipping_method_id`, `payment_method_id`, `country_id`, `sales_channel_id`, `customer_id`, `price`, `line_item_count`, `payload`, `rule_ids`, `compressed`, `created_at`)
VALUES (:token, :currency_id, :shipping_method_id, :payment_method_id, :country_id, :sales_channel_id, :customer_id, :price, :line_item_count, :payload, :rule_ids, :compressed, :now)
ON DUPLICATE KEY UPDATE `currency_id` = :currency_id, `shipping_method_id` = :shipping_method_id, `payment_method_id` = :payment_method_id, `country_id` = :country_id, `sales_channel_id` = :sales_channel_id, `customer_id` = :customer_id,`price` = :price, `line_item_count` = :line_item_count, `payload` = :payload, `compressed` = :compressed, `rule_ids` = :rule_ids, `updated_at` = :now;
SQL;
} $customerId =
$context->
getCustomer() ? Uuid::
fromHexToBytes($context->
getCustomer()->
getId()) : null;
$data =
[ 'token' =>
$cart->
getToken(),
'currency_id' => Uuid::
fromHexToBytes($context->
getCurrency()->
getId()),
'shipping_method_id' => Uuid::
fromHexToBytes($context->
getShippingMethod()->
getId()),
'payment_method_id' => Uuid::
fromHexToBytes($context->
getPaymentMethod()->
getId()),
'country_id' => Uuid::
fromHexToBytes($context->
getShippingLocation()->
getCountry()->
getId()),
'sales_channel_id' => Uuid::
fromHexToBytes($context->
getSalesChannel()->
getId()),
'customer_id' =>
$customerId,
'price' =>
$cart->
getPrice()->
getTotalPrice(),
'line_item_count' =>
$cart->
getLineItems()->
count(),