7
7
8
8
namespace Magento \QuoteGraphQl \Model \Cart ;
9
9
10
+ use Magento \Framework \App \ObjectManager ;
10
11
use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
11
12
use Magento \GraphQl \Model \Query \ContextInterface ;
12
13
use Magento \Quote \Api \Data \CartInterface ;
14
+ use Magento \Quote \Model \QuoteRepository ;
13
15
14
16
/**
15
17
* Set single shipping address for a specified shopping cart
@@ -26,16 +28,25 @@ class SetShippingAddressesOnCart implements SetShippingAddressesOnCartInterface
26
28
*/
27
29
private $ getShippingAddress ;
28
30
31
+ /**
32
+ * @var QuoteRepository
33
+ */
34
+ private $ quoteRepository ;
35
+
29
36
/**
30
37
* @param AssignShippingAddressToCart $assignShippingAddressToCart
31
38
* @param GetShippingAddress $getShippingAddress
39
+ * @param QuoteRepository|null $quoteRepository
32
40
*/
33
41
public function __construct (
34
42
AssignShippingAddressToCart $ assignShippingAddressToCart ,
35
- GetShippingAddress $ getShippingAddress
43
+ GetShippingAddress $ getShippingAddress ,
44
+ QuoteRepository $ quoteRepository = null
36
45
) {
37
46
$ this ->assignShippingAddressToCart = $ assignShippingAddressToCart ;
38
47
$ this ->getShippingAddress = $ getShippingAddress ;
48
+ $ this ->quoteRepository = $ quoteRepository
49
+ ?? ObjectManager::getInstance ()->get (QuoteRepository::class);
39
50
}
40
51
41
52
/**
@@ -70,5 +81,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
70
81
throw $ e ;
71
82
}
72
83
$ this ->assignShippingAddressToCart ->execute ($ cart , $ shippingAddress );
84
+ // trigger quote re-evaluation after address change
85
+ $ this ->quoteRepository ->save ($ cart );
73
86
}
74
87
}
0 commit comments