|
7 | 7 |
|
8 | 8 | namespace Magento\Braintree\Plugin; |
9 | 9 |
|
10 | | -use Magento\Quote\Api\CartRepositoryInterface; |
11 | | -use Magento\Quote\Api\Data\PaymentInterface; |
| 10 | +use Magento\Quote\Model\QuoteManagement; |
12 | 11 | use Magento\Quote\Api\CartManagementInterface; |
| 12 | +use Magento\Quote\Model\Quote; |
13 | 13 |
|
14 | 14 | /** |
15 | | - * Plugin for CartManagementInterface to disable quote address validation |
| 15 | + * Plugin for QuoteManagement to disable quote address validation |
16 | 16 | */ |
17 | 17 | class DisableQuoteAddressValidation |
18 | 18 | { |
19 | 19 | /** |
20 | | - * @var CartRepositoryInterface |
21 | | - */ |
22 | | - private $quoteRepository; |
23 | | - |
24 | | - /** |
25 | | - * @param CartRepositoryInterface $quoteRepository |
26 | | - */ |
27 | | - public function __construct( |
28 | | - CartRepositoryInterface $quoteRepository |
29 | | - ) { |
30 | | - $this->quoteRepository = $quoteRepository; |
31 | | - } |
32 | | - |
33 | | - /** |
34 | | - * Disable quote address validation before place order |
| 20 | + * Disable quote address validation before submit order |
35 | 21 | * |
36 | | - * @param CartManagementInterface $subject |
37 | | - * @param \Closure $proceed |
38 | | - * @param int $cartId |
39 | | - * @param PaymentInterface|null $payment |
40 | | - * @return int |
41 | | - * @throws \Magento\Framework\Exception\NoSuchEntityException |
| 22 | + * @param QuoteManagement $subject |
| 23 | + * @param Quote $quote |
| 24 | + * @param array $orderData |
| 25 | + * @return array |
| 26 | + * @throws \Exception |
| 27 | + * @throws \Magento\Framework\Exception\LocalizedException |
42 | 28 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
43 | 29 | */ |
44 | | - public function aroundPlaceOrder( |
45 | | - CartManagementInterface $subject, |
46 | | - \Closure $proceed, |
47 | | - int $cartId, |
48 | | - PaymentInterface $payment = null |
| 30 | + public function beforeSubmit( |
| 31 | + QuoteManagement $subject, |
| 32 | + Quote $quote, |
| 33 | + $orderData = [] |
49 | 34 | ) { |
50 | | - $quote = $this->quoteRepository->get($cartId); |
51 | 35 | if ($quote->getPayment()->getMethod() == 'braintree_paypal' && |
52 | 36 | $quote->getCheckoutMethod() == CartManagementInterface::METHOD_GUEST) { |
53 | 37 | $billingAddress = $quote->getBillingAddress(); |
54 | 38 | $billingAddress->setShouldIgnoreValidation(true); |
55 | 39 | $quote->setBillingAddress($billingAddress); |
56 | 40 | } |
57 | | - return $proceed($cartId, $payment); |
| 41 | + return [$quote, $orderData]; |
58 | 42 | } |
59 | 43 | } |
0 commit comments