File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed
app/code/Magento/InstantPurchase/Model Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -57,9 +57,11 @@ public function createQuote(
57
57
$ quote ->setCustomer ($ customer ->getDataModel ());
58
58
$ quote ->setCustomerIsGuest (0 );
59
59
$ quote ->getShippingAddress ()
60
- ->importCustomerAddressData ($ shippingAddress ->getDataModel ());
60
+ ->importCustomerAddressData ($ shippingAddress ->getDataModel ())
61
+ ->setCollectShippingRates (true );
61
62
$ quote ->getBillingAddress ()
62
- ->importCustomerAddressData ($ billingAddress ->getDataModel ());
63
+ ->importCustomerAddressData ($ billingAddress ->getDataModel ())
64
+ ->setCollectShippingRates (true );
63
65
$ quote ->setInventoryProcessed (false );
64
66
return $ quote ;
65
67
}
Original file line number Diff line number Diff line change 13
13
*/
14
14
class CheapestMethodDeferredChooser implements DeferredShippingMethodChooserInterface
15
15
{
16
- const METHOD_CODE = 'cheapest ' ;
16
+ public const METHOD_CODE = 'cheapest ' ;
17
17
18
18
/**
19
19
* @inheritdoc
20
20
*/
21
21
public function choose (Address $ address )
22
22
{
23
- $ address ->setCollectShippingRates (true );
24
- $ address ->collectShippingRates ();
25
- $ shippingRates = $ address ->getAllShippingRates ();
26
-
23
+ $ shippingRates = $ this ->getShippingRates ($ address );
27
24
if (empty ($ shippingRates )) {
28
25
return null ;
29
26
}
@@ -32,6 +29,23 @@ public function choose(Address $address)
32
29
return $ cheapestRate ->getCode ();
33
30
}
34
31
32
+ /**
33
+ * Retrieves previously collected shipping rates or computes new ones.
34
+ *
35
+ * @param Address $address
36
+ * @return Rate[]
37
+ */
38
+ private function getShippingRates (Address $ address ) : array
39
+ {
40
+ if (!empty ($ shippingRates = $ address ->getAllShippingRates ())) {
41
+ // Favour previously collected rates over recomputing.
42
+ return $ shippingRates ;
43
+ }
44
+ $ address ->setCollectShippingRates (true );
45
+ $ address ->collectShippingRates ();
46
+ return $ address ->getAllShippingRates ();
47
+ }
48
+
35
49
/**
36
50
* Selects shipping price with minimal price.
37
51
*
You can’t perform that action at this time.
0 commit comments