loginSessionHelper = $loginSessionHelper; $this->cartRepository = $cartRepository; $this->orderInformationManagement = $orderInformationManagement; } /** * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeSaveAddressInformation( ShippingInformationManagementInterface $subject, $cartId, ShippingInformationInterface $shippingInformation ) { $return = [$cartId, $shippingInformation]; $quote = $this->cartRepository->getActive($cartId); /* Grand total is 0, skip rest of the plugin */ if ($quote->getGrandTotal() <= 0) { return $return; } // Add Amazon Order Reference ID only when logged in using Amazon Account $amazonCustomer = $this->loginSessionHelper->getAmazonCustomer(); if (!$amazonCustomer) { return $return; } $amazonOrderReferenceId = $quote->getExtensionAttributes()->getAmazonOrderReferenceId(); if ($amazonOrderReferenceId) { $this->orderInformationManagement->saveOrderInformation( $amazonOrderReferenceId, [ AmazonConstraint::PAYMENT_PLAN_NOT_SET_ID, AmazonConstraint::PAYMENT_METHOD_NOT_ALLOWED_ID ] ); } return $return; } }