Skip to content

Commit

Permalink
Merge pull request #72 from jorgeeurekalabs/main
Browse files Browse the repository at this point in the history
v2.0.18
  • Loading branch information
jorgeeurekalabs authored Mar 27, 2024
2 parents 3a9ec96 + 900dbe9 commit 44ec9f1
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 19 deletions.
14 changes: 6 additions & 8 deletions AbandonedCart/Model/AbandonedCartSendData.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public function sendAbandonedCartData($quoteId = null): array
$abandonedCart->collectTotals();
$quoteItemsData = $this->getQuoteItemsData($abandonedCart->getEntityId(), $abandonedCart->getStoreId());
$abandonedCartRepository = $this->quoteRepository->get($abandonedCart->getId());
$timezone = $this->dateTime->getConfigTimezone(\Magento\Store\Model\ScopeInterface::SCOPE_STORES, $abandonedCart->getStoreId());
$abandonedCartData = [
"ecomOrder" => [
"externalcheckoutid" => $abandonedCart->getEntityId(),
Expand All @@ -280,9 +281,9 @@ public function sendAbandonedCartData($quoteId = null): array
"discountAmount" => $this->coreHelper->priceToCents($abandonedCart->getDiscountAmount())
],
"orderUrl" => $this->urlBuilder->getDirectUrl('checkout/cart'),
"abandonedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getUpdatedAt()))->format('Y-m-d\TH:i:sP'),
"externalCreatedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getCreatedAt()))->format('Y-m-d\TH:i:sP'),
"externalUpdatedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getUpdatedAt()))->format('Y-m-d\TH:i:sP'),
"abandonedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getUpdatedAt()),NULL,$timezone)->format('Y-m-d\TH:i:sP'),
"externalCreatedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getCreatedAt()),NULL,$timezone)->format('Y-m-d\TH:i:sP'),
"externalUpdatedDate" => $this->dateTime->date(strtotime($abandonedCartRepository->getUpdatedAt()),NULL,$timezone)->format('Y-m-d\TH:i:sP'),
"shippingMethod" => $abandonedCart->getShippingAddress()->getShippingMethod(),
"totalPrice" => $this->coreHelper->priceToCents($abandonedCart->getGrandTotal()),
"shippingAmount" => $this->coreHelper->priceToCents($abandonedCart->getShippingAmount()),
Expand Down Expand Up @@ -402,11 +403,8 @@ private function saveResult($quoteId, $acOrderId, $syncStatus): void
if ($quoteModel->getEntityId()) {
$quoteModel->setAcOrderSyncId($acOrderId);
$quoteModel->setAcSyncStatus($syncStatus);
if(!$quoteModel->getUpdatedAt()){
$quoteModel->setAcSyncedDate($this->dateTime->date()->modify('+1 day')->format('Y-m-d H:i:s'));
}else{
$quoteModel->setAcSyncedDate($this->dateTime->date($quoteModel->getUpdatedAt())->modify('+1 day')->format('Y-m-d H:i:s'));
}
$quoteModel->setAcSyncedDate(new \Zend_Db_Expr('CURRENT_TIMESTAMP'));

}
$quoteModel->save();
}
Expand Down
2 changes: 1 addition & 1 deletion AbandonedCart/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"config": {
"sort-packages": true
},
"version": "2.1.7",
"version": "2.1.8",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
"activecampaign/core": "2.1.*"
Expand Down
2 changes: 1 addition & 1 deletion AbandonedCart/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
comment="ActiveCampaign Status"/>
<column xsi:type="int" name="ac_order_sync_id" nullable="false" default="0" comment="ActiveCampaign Cart Id"/>
<column xsi:type="int" name="ac_temp_customer_id" nullable="false" default="0" comment="ActiveCampaign Customer Id"/>
<column xsi:type="datetime" name="ac_synced_date" on_update="false" nullable="true" comment="ActiveCampaign synced_date"/>
<column xsi:type="timestamp" name="ac_synced_date" on_update="false" nullable="true" comment="ActiveCampaign synced_date"/>
</table>
</schema>
10 changes: 10 additions & 0 deletions AbandonedCart/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"quote": {
"column": {
"ac_sync_status": true,
"ac_order_sync_id": true,
"ac_temp_customer_id": true,
"ac_synced_date": true
}
}
}
2 changes: 1 addition & 1 deletion AbandonedCart/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="ActiveCampaign_AbandonedCart" setup_version="2.1.7">
<module name="ActiveCampaign_AbandonedCart" setup_version="2.1.8">
<sequence>
<module name="Magento_Product"/>
<module name="Magento_Sales"/>
Expand Down
4 changes: 4 additions & 0 deletions Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class Customer
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* @var SubscriberFactory
*/
protected $subscriberFactory;

/**
* Customer constructor.
Expand Down
2 changes: 1 addition & 1 deletion Customer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"config": {
"sort-packages": true
},
"version": "2.1.7",
"version": "2.1.8",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
"activecampaign/core": "2.1.*"
Expand Down
2 changes: 1 addition & 1 deletion Customer/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="ActiveCampaign_Customer" setup_version="2.1.7">
<module name="ActiveCampaign_Customer" setup_version="2.1.8">
<sequence>
<module name="ActiveCampaign_Core"/>
</sequence>
Expand Down
16 changes: 13 additions & 3 deletions Order/Model/OrderData/OrderDataSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Store\Model\StoreManagerInterface as StoreManagerInterface;
use Magento\Quote\Api\CartRepositoryInterface;
Expand Down Expand Up @@ -119,6 +120,11 @@ class OrderDataSend
*/
protected $customer;

/**
* @var DateTime
*/
private $dateTime;

/**
* OrderDataSend constructor.
* @param ProductRepositoryInterfaceFactory $productRepositoryFactory
Expand All @@ -138,6 +144,7 @@ class OrderDataSend
* @param CustomerResource $customerResource
* @param CartRepositoryInterface $quoteRepository
* @param Customer $customer
* @param TimezoneInterface $dateTime
*/
public function __construct(
ProductRepositoryInterfaceFactory $productRepositoryFactory,
Expand All @@ -156,7 +163,8 @@ public function __construct(
CoreHelper $coreHelper,
CustomerResource $customerResource,
CartRepositoryInterface $quoteRepository,
Customer $customer
Customer $customer,
TimezoneInterface $dateTime
) {
$this->_productRepositoryFactory = $productRepositoryFactory;
$this->imageHelperFactory = $imageHelperFactory;
Expand All @@ -175,6 +183,7 @@ public function __construct(
$this->customerResource = $customerResource;
$this->quoteRepository = $quoteRepository;
$this->customer = $customer;
$this->dateTime = $dateTime;
}

/**
Expand Down Expand Up @@ -213,6 +222,7 @@ public function orderDataSend($order): array
if($quoteModel) {
$this->saveCustomerResultQuote($quote, $customerAcId);
}
$timezone = $this->dateTime->getConfigTimezone(\Magento\Store\Model\ScopeInterface::SCOPE_STORES, $order->getStoreId());
foreach ($order->getAllVisibleItems() as $item) {
$product = $this->_productRepositoryFactory->create()
->get($item->getSku());
Expand All @@ -239,8 +249,8 @@ public function orderDataSend($order): array
"orderDiscounts" => [
"discountAmount" => $this->activeCampaignHelper->priceToCents($order->getDiscountAmount())
],
"externalCreatedDate" => $order->getCreatedAt(),
"externalUpdatedDate" => $order->getUpdatedAt(),
"externalCreatedDate" => $this->dateTime->date(strtotime($order->getCreatedAt()),NULL,$timezone)->format('Y-m-d\TH:i:sP'),
"externalUpdatedDate" => $this->dateTime->date(strtotime($order->getUpdatedAt()),NULL,$timezone)->format('Y-m-d\TH:i:sP'),
"shippingMethod" => $order->getShippingMethod(),
"totalPrice" => $this->activeCampaignHelper->priceToCents($order->getGrandTotal()),
"shippingAmount" => $this->activeCampaignHelper->priceToCents($order->getShippingAmount()),
Expand Down
2 changes: 1 addition & 1 deletion Order/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"config": {
"sort-packages": true
},
"version": "2.1.3",
"version": "2.1.4",
"require": {
"php": "~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
"activecampaign/core": "2.1.*"
Expand Down
2 changes: 1 addition & 1 deletion Order/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="ActiveCampaign_Order" setup_version="2.1.3">
<module name="ActiveCampaign_Order" setup_version="2.1.4">
<sequence>
<module name="ActiveCampaign_Core" />
<module name="ActiveCampaign_Customer"/>
Expand Down
2 changes: 1 addition & 1 deletion marketplace-composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "activecampaign/module-integration",
"description": "ActiveCampaign extension for Magento 2.3 and 2.4",
"type": "metapackage",
"version": "2.0.17",
"version": "2.0.18",
"license": [
"OSL-3.0"
],
Expand Down

0 comments on commit 44ec9f1

Please sign in to comment.