Skip to content

Commit

Permalink
[KDEV-50855] fix paypal orders bug and guest checkout bug (#28)
Browse files Browse the repository at this point in the history
* fix paypal orders bug and guest checkout bug

* update module version
  • Loading branch information
aacebo authored Dec 8, 2022
1 parent 7fc4072 commit 69e6231
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alexcheng/magento2:2.1-developer
FROM alexcheng/magento2:2.2-developer

ADD . app/code/Kustomer/KustomerIntegration

Expand Down
32 changes: 19 additions & 13 deletions Observer/CheckoutSuccessActionObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,23 @@ public function __construct(
*/
public function execute(EventObserver $observer)
{
/**
* @var \Magento\Sales\Api\Data\OrderInterface $order
* @var \Magento\Customer\Model\Customer $customer
* @var \Magento\Store\Model\Store $store
*/
$order = $observer->getEvent()->getData()['order'];
$eventName = $observer->getEvent()->getName();
$customer = $order->getCustomerId();
$store = $order->getStoreId();
$objectType = 'order';
$data = $this->__helperData->normalizeOrder($order);
$this->publish($objectType, $data, $customer, $store, $eventName);
try
{
/**
* @var string $eventName
* @var \Magento\Sales\Model\Order $orderModel
*/
$eventName = $observer->getEvent()->getName();
$order = $observer->getEvent()->getData()['order'];
$customer = $order->getCustomerId();
$store = $order->getStoreId();
$orderData = $this->__helperData->normalizeOrder($order);
$dataType = 'order';
$this->publish($dataType, $orderData, $customer, $store, $eventName);
}
catch (\Error $e)
{
$this->logger->error('CheckoutSuccessActionObserver ' . $e->getMessage());
}
}
}
}
8 changes: 3 additions & 5 deletions Observer/KustomerEventObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,9 @@ public function publish($dataType, $data, $customer, $store = null, $eventName =
$customer = $this->__getCustomerById($customer->getId());
}

if ((!$customer instanceof CustomerInterface) && ($eventName === 'checkout_submit_all_after')) {
if ((!$customer instanceof CustomerInterface))
{
$customer = $this->__guestCustomerFromOrder($data);
} elseif (!$customer instanceof CustomerInterface) {
$this->logger->error('no customer provided for event '.$eventName);
return;
}

if ($dataType === 'customer' && empty($data))
Expand All @@ -166,4 +164,4 @@ public function publish($dataType, $data, $customer, $store = null, $eventName =
$result = $this->__publish($eventName, $dataType, $data, $customer, $store);
$this->logger->debug('kustomer: processing for event '.$eventName.' complete. success: '.$result);
}
}
}
33 changes: 19 additions & 14 deletions Observer/OrderSaveAfterObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@ public function __construct(
*/
public function execute(EventObserver $observer)
{
/**
* @var string $eventName
* @var \Magento\Sales\Model\Order $orderModel
*/
$eventName = $observer->getEvent()->getName();
$orderModel = $observer->getEvent()->getData()['order'];
$order = $this->__orderRepository->get($orderModel->getId());
$customer = $order->getCustomerId();
$store = $order->getStoreId();

$orderData = $this->__helperData->normalizeOrder($order);
$dataType = 'order';
$this->publish($dataType, $orderData, $customer, $store, $eventName);
try
{
/**
* @var string $eventName
* @var \Magento\Sales\Model\Order $orderModel
*/
$eventName = $observer->getEvent()->getName();
$order = $observer->getEvent()->getData()['order'];
$customer = $order->getCustomerId();
$store = $order->getStoreId();
$orderData = $this->__helperData->normalizeOrder($order);
$dataType = 'order';
$this->publish($dataType, $orderData, $customer, $store, $eventName);
}
catch (\Error $e)
{
$this->logger->error('OrderSaveAfterObserver ' . $e->getMessage());
}
}
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "kustomer/kustomer-integration",
"description": "Integrate Magento eCommerce site with Kustomer service",
"type": "magento2-module",
"version": "1.1.10",
"version": "1.1.11",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Kustomer_KustomerIntegration" setup_version="1.1.10">
<module name="Kustomer_KustomerIntegration" setup_version="1.1.11">
<sequence>
<module name="Magento_Store"/>
</sequence>
Expand Down

0 comments on commit 69e6231

Please sign in to comment.