Skip to content

Commit

Permalink
closes #84
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Sep 7, 2017
1 parent 4797585 commit 838f8b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
13 changes: 13 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,19 @@ public function getMCMinSyncing($storeId)
$ret = $this->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_IS_SYNC, $storeId);
return !$ret;
}
public function getCartUrl($storeId,$cartId,$token)
{
$rc = $this->_storeManager->getStore($storeId)->getUrl(
'mailchimp/cart/loadquote',
[
'id' => $cartId,
'token' => $token,
'_nosid' => true,
'_secure' => true
]
);
return $rc;
}
/**
* @param null $store
* @return mixed
Expand Down
17 changes: 5 additions & 12 deletions Model/Api/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ protected function _getModifiedQuotes($mailchimpStoreId, $magentoStoreId)
* @var $cart \Magento\Quote\Model\Quote
*/
foreach ($modifiedCarts as $cart) {
$this->_token = null;
$cartId = $cart->getEntityId();
$allCarts[$this->_counter]['method'] = 'DELETE';
$allCarts[$this->_counter]['path'] = '/ecommerce/stores/' . $mailchimpStoreId . '/carts/' . $cartId;
Expand Down Expand Up @@ -309,6 +310,7 @@ protected function _getNewQuotes($mailchimpStoreId, $magentoStoreId)
* @var $cart \Magento\Quote\Model\Quote
*/
foreach ($newCarts as $cart) {
$this->_token = null;
$cartId = $cart->getEntityId();
$orderCollection = $this->_getOrderCollection();
$orderCollection->addFieldToFilter('main_table.customer_email', ['eq' => $cart->getCustomerEmail()])
Expand Down Expand Up @@ -399,7 +401,6 @@ protected function _getAllCartsByEmail($email, $mailchimpStoreId, $magentoStoreI
*/
protected function _makeCart(\Magento\Quote\Model\Quote $cart, $mailchimpStoreId, $magentoStoreId)
{
$this->_token = null;
$campaignId = $cart->getMailchimpCampaignId();
$oneCart = [];
$oneCart['id'] = $cart->getEntityId();
Expand All @@ -408,7 +409,7 @@ protected function _makeCart(\Magento\Quote\Model\Quote $cart, $mailchimpStoreId
$oneCart['campaign_id'] = $campaignId;
}

$oneCart['checkout_url'] = $this->_getCheckoutUrl($cart);
$oneCart['checkout_url'] = $this->_getCheckoutUrl($cart,$magentoStoreId);
$oneCart['currency_code'] = $cart->getQuoteCurrencyCode();
$oneCart['order_total'] = $cart->getGrandTotal();
$oneCart['tax_total'] = 0;
Expand Down Expand Up @@ -468,18 +469,10 @@ protected function _makeCart(\Magento\Quote\Model\Quote $cart, $mailchimpStoreId
* @param \Magento\Quote\Model\Quote $cart
* @return string
*/
protected function _getCheckoutUrl(\Magento\Quote\Model\Quote $cart)
protected function _getCheckoutUrl(\Magento\Quote\Model\Quote $cart, $storeId)
{
$token = md5(rand(0, 9999999));
$url = $this->_urlHelper->getUrl(
'mailchimp/cart/loadquote',
[
'id' => $cart->getId(),
'token' => $token,
'_nosid' => true,
'_secure' => true
]
);
$url = $this->_helper->getCartUrl($storeId,$cart->getId(),$token);
$this->_token = $token;
return $url;
}
Expand Down

0 comments on commit 838f8b0

Please sign in to comment.