Conditions | 4 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public function execute(): void |
||
30 | { |
||
31 | if (!$this->getFactory()->getConfig()->isMerchantSwitcherEnabled()) { |
||
32 | return; |
||
33 | } |
||
34 | |||
35 | $quoteTransfer = $this->getFactory()->getQuoteClient()->getQuote(); |
||
36 | $merchantReference = $quoteTransfer->getMerchantReference(); |
||
37 | |||
38 | if ($merchantReference && $quoteTransfer->getItems()->count()) { |
||
39 | $this->getFactory()->createSelectedMerchantCookie()->setMerchantReference($merchantReference); |
||
40 | |||
41 | return; |
||
42 | } |
||
43 | |||
44 | $merchantReference = $this->getFactory()->createSelectedMerchantCookie()->getMerchantReference(); |
||
45 | $merchantSwitchRequestTransfer = (new MerchantSwitchRequestTransfer()) |
||
46 | ->setQuote($quoteTransfer) |
||
47 | ->setMerchantReference($merchantReference); |
||
48 | |||
49 | $this->getFactory()->getMerchantSwitcherClient()->switchMerchantInQuote($merchantSwitchRequestTransfer); |
||
50 | } |
||
52 |