diff --git a/.idea/deployment.xml b/.idea/deployment.xml
new file mode 100644
index 0000000..c489644
--- /dev/null
+++ b/.idea/deployment.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/sshConfigs.xml b/.idea/sshConfigs.xml
new file mode 100644
index 0000000..fecd2fd
--- /dev/null
+++ b/.idea/sshConfigs.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/webServers.xml b/.idea/webServers.xml
new file mode 100644
index 0000000..70f96e9
--- /dev/null
+++ b/.idea/webServers.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AtlDiscountExtension-main/src/Subscriber/StateMachineTransitionSubscriber.php b/AtlDiscountExtension-main/src/Subscriber/StateMachineTransitionSubscriber.php
index 7e51bb0..28664af 100644
--- a/AtlDiscountExtension-main/src/Subscriber/StateMachineTransitionSubscriber.php
+++ b/AtlDiscountExtension-main/src/Subscriber/StateMachineTransitionSubscriber.php
@@ -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;
}