Skip to content

Commit

Permalink
2.2.20 - Fix carts coupon code and discount values
Browse files Browse the repository at this point in the history
  • Loading branch information
bnayalivne committed Apr 18, 2018
1 parent d89c67f commit c3e3071
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
32 changes: 10 additions & 22 deletions Model/Api/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class Data implements DataInterface
"title",
"verified_email"
],
"discount_codes" => 'coupon_code',
"coupon_code" => 'coupon_code',
"email" => 'customer_email',
"fulfillment_status",
"id" => 'entity_id',
Expand Down Expand Up @@ -213,16 +213,14 @@ class Data implements DataInterface
"rate"
],
"total_tax" => "tax_amount",
"test",
"total_discounts" => 'base_discount_amount',
"order_discount" => 'discount_amount',
"total_line_items_price",
"total_price" => 'grand_total',
"total_shipping" => 'shipping_amount',
"total_weight" => 'weight',
"updated_at" => 'updated_at'
],
"carts" => [

"abandoned_checkout_url",
"billing_address" => [
"country" => 'country_id',
Expand All @@ -236,7 +234,7 @@ class Data implements DataInterface
"cart_token",
"created_at" => "created_at",
"currency" => "global_currency_code",
"discount_codes" => 'coupon_code',
"coupon_code" => "coupon_code",
"email" => 'customer_email',
"fulfillment_status",
"id" => 'entity_id',
Expand All @@ -259,10 +257,6 @@ class Data implements DataInterface
],
"shipping_lines" => 'shipping_method',
"subtotal_price" => 'subtotal',
"tax_lines",
"taxes_included",
"total_discounts",
"total_line_items_price",
"total_price" => 'grand_total',
"total_shipping",
"total_tax" => 'tax_amount',
Expand Down Expand Up @@ -798,18 +792,7 @@ public function getOrders(
$orderDetails = $order->getData();
foreach ($map['orders'] as $element => $value) {
if (!is_array($value)) {
if ($value == 'coupon_code') {
if ($orderDetails['coupon_code']) {
$ord['discount_codes'] = [
[
'code' => $orderDetails['coupon_code'],
'amount' => isset($orderDetails['discount_amount']) ? $orderDetails['discount_amount'] : 0
]
];
} else {
$ord['discount_codes'] = [];
}
} elseif (array_key_exists($value, $orderDetails)) {
if (array_key_exists($value, $orderDetails)) {
$ord[$element] = $orderDetails[$value];
}
}
Expand Down Expand Up @@ -941,6 +924,7 @@ public function getQuotes(
*/
$quotes = $this->quoteFactory->create()->getCollection();
$quotes->addFieldToFilter('is_active' , 1);
$quotes->addFieldToFilter('customer_email' , ['neq' => null]);

if ($mage_store_id != null) {
$quotes->addFieldToFilter('store_id', array('eq' => $mage_store_id));
Expand Down Expand Up @@ -991,6 +975,10 @@ public function getQuotes(
}
}

$subtotal = $quote->getSubtotal();
$subtotal_with_discount = $quote->getSubtotalWithDiscount();
$quoteArray['order_discount'] = $subtotal-$subtotal_with_discount;

$defaultBilling = $quote->getBillingAddress()->getData();
$defaultShipping = $quote->getShippingAddress()->getData();
foreach ($map['carts']['billing_address'] as $element => $value) {
Expand Down Expand Up @@ -1253,7 +1241,7 @@ public function setConfig($mage_store_id, $configName, $scope, $newValue)
*/
public function getVersion()
{
return '2.2.19';
return '2.2.20';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lib-libxml": "*"
},
"type": "magento2-module",
"version": "2.2.19",
"version": "2.2.20",
"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,5 +1,5 @@
<?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="Remarkety_Mgconnector" setup_version="2.2.19">
<module name="Remarkety_Mgconnector" setup_version="2.2.20">
</module>
</config>

0 comments on commit c3e3071

Please sign in to comment.