|
|
|
@@ -77,7 +77,7 @@ class StateMachineTransitionSubscriber implements EventSubscriberInterface |
|
|
|
$orderId = $event->getEntityId(); |
|
|
|
$order = $this->getOrder($orderId, $event); |
|
|
|
$salesChannelId = $order->getSalesChannelId(); |
|
|
|
|
|
|
|
|
|
|
|
// In case no order could be found - return |
|
|
|
if (empty($order)) { |
|
|
|
return; |
|
|
|
@@ -85,14 +85,14 @@ class StateMachineTransitionSubscriber implements EventSubscriberInterface |
|
|
|
|
|
|
|
$minAmountDiscountableLineItems = $this->systemConfigService->get('AtlDiscountExtension.config.minAmountDiscountableLineItems', $salesChannelId); |
|
|
|
$amountDiscountableLineItems = $this->getAmountDiscountableLineItems($order->getLineItems(), $minAmountDiscountableLineItems, $salesChannelId, $event); |
|
|
|
|
|
|
|
|
|
|
|
// In case it is not enough - return |
|
|
|
if ($amountDiscountableLineItems < $minAmountDiscountableLineItems) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$customer = $order->getOrderCustomer()->getCustomer(); |
|
|
|
|
|
|
|
|
|
|
|
// Tag the customer and trace last order date in 'spwn_repeat_discount' table |
|
|
|
$this->tagCustomer($customer, $salesChannelId, $event); |
|
|
|
} |
|
|
|
@@ -133,11 +133,13 @@ class StateMachineTransitionSubscriber implements EventSubscriberInterface |
|
|
|
if ($customFieldName === '') { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$amountDiscountableLineItems = 0; |
|
|
|
foreach($lineItems as $lineItem) { |
|
|
|
if (empty($lineItem->getPayload()['customFields'])) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
$customFields = $lineItem->getPayload()['customFields']; |
|
|
|
|
|
|
|
// Checks if the custom field exists and is set to true |
|
|
|
if (!empty($customFields[$customFieldName]) && $customFields[$customFieldName] === true) { |
|
|
|
$amountDiscountableLineItems += $lineItem->getQuantity(); |
|
|
|
@@ -148,7 +150,6 @@ class StateMachineTransitionSubscriber implements EventSubscriberInterface |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $amountDiscountableLineItems; |
|
|
|
} |
|
|
|
|
|
|
|
|