Skip to content

Commit 0ad156a

Browse files
AC-2044::Cart Price Rule with shipping method set as condition is not working Magento - Reverted Js Changes apply other fix
1 parent 2f3883d commit 0ad156a

File tree

3 files changed

+12
-88
lines changed

3 files changed

+12
-88
lines changed

app/code/Magento/Checkout/Model/TotalsInformationManagement.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,34 @@
66
namespace Magento\Checkout\Model;
77

88
use Magento\Checkout\Api\Data\TotalsInformationInterface;
9+
use Magento\Quote\Api\CartRepositoryInterface;
10+
use Magento\Quote\Api\CartTotalRepositoryInterface;
911

1012
/**
1113
* Class for management of totals information.
1214
*/
1315
class TotalsInformationManagement implements \Magento\Checkout\Api\TotalsInformationManagementInterface
1416
{
1517
/**
16-
* @var \Magento\Quote\Api\CartTotalRepositoryInterface
18+
* @var CartTotalRepositoryInterface
1719
*/
1820
protected $cartTotalRepository;
1921

2022
/**
2123
* Quote repository.
2224
*
23-
* @var \Magento\Quote\Api\CartRepositoryInterface
25+
* @var CartRepositoryInterface
2426
*/
2527
protected $cartRepository;
2628

2729
/**
28-
* @param \Magento\Quote\Api\CartRepositoryInterface $cartRepository
29-
* @param \Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalRepository
30+
* @param CartRepositoryInterface $cartRepository
31+
* @param CartTotalRepositoryInterface $cartTotalRepository
3032
* @codeCoverageIgnore
3133
*/
3234
public function __construct(
33-
\Magento\Quote\Api\CartRepositoryInterface $cartRepository,
34-
\Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalRepository
35+
CartRepositoryInterface $cartRepository,
36+
CartTotalRepositoryInterface $cartTotalRepository
3537
) {
3638
$this->cartRepository = $cartRepository;
3739
$this->cartTotalRepository = $cartTotalRepository;
@@ -66,6 +68,8 @@ public function calculate(
6668
}
6769
$quoteShippingAddress->setCollectShippingRates(true)
6870
->setShippingMethod($shippingMethod);
71+
72+
$this->cartRepository->save($quote);
6973
}
7074
}
7175
$quote->collectTotals();

app/code/Magento/Checkout/view/frontend/web/js/model/cart/shipping-save-processor/default.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

app/code/Magento/Checkout/view/frontend/web/js/view/cart/shipping-rates.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,8 @@ define([
1111
'Magento_Catalog/js/price-utils',
1212
'Magento_Checkout/js/model/quote',
1313
'Magento_Checkout/js/action/select-shipping-method',
14-
'Magento_Checkout/js/model/shipping-save-processor',
15-
'Magento_Checkout/js/model/cart/shipping-save-processor/default',
1614
'Magento_Checkout/js/checkout-data'
17-
], function (
18-
ko,
19-
_,
20-
Component,
21-
shippingService,
22-
priceUtils,
23-
quote,
24-
selectShippingMethodAction,
25-
shippingSaveProcessor,
26-
cartShippingProcessor,
27-
checkoutData
28-
) {
15+
], function (ko, _, Component, shippingService, priceUtils, quote, selectShippingMethodAction, checkoutData) {
2916
'use strict';
3017

3118
return Component.extend({
@@ -50,12 +37,6 @@ define([
5037

5138
this._super();
5239

53-
shippingSaveProcessor.registerProcessor('cart', cartShippingProcessor);
54-
this.selectedShippingMethod.subscribe(function () {
55-
if (quote.shippingMethod()) {
56-
shippingSaveProcessor.saveShippingInformation('cart');
57-
}
58-
});
5940
this.shippingRates.subscribe(function (rates) {
6041
self.shippingRateGroups([]);
6142
_.each(rates, function (rate) {
@@ -96,6 +77,7 @@ define([
9677
selectShippingMethod: function (methodData) {
9778
selectShippingMethodAction(methodData);
9879
checkoutData.setSelectedShippingRate(methodData['carrier_code'] + '_' + methodData['method_code']);
80+
9981
return true;
10082
}
10183
});

0 commit comments

Comments
 (0)