/** * @param \Magento\Checkout\Model\ShippingInformationManagement $subject * @param $cartId * @param \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation */ public function beforeSaveAddressInformation(\Magento\Checkout\Model\ShippingInformationManagement $subject, $cartId, \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation) { $customFee = $addressInformation->getExtensionAttributes()->getFee(); $quote = $this->quoteRepository->getActive($cartId); if ($customFee) { $fee = $this->dataHelper->getCustomFee(); $quote->setFee($fee); } else { $quote->setFee(NULL); } }
/** * @return array */ public function getConfig() { $customFeeConfig = []; $enabled = $this->dataHelper->isModuleEnabled(); $minimumOrderAmount = $this->dataHelper->getMinimumOrderAmount(); $customFeeConfig['fee_label'] = $this->dataHelper->getFeeLabel(); $quote = $this->checkoutSession->getQuote(); $subtotal = $quote->getSubtotal(); $customFeeConfig['custom_fee_amount'] = $this->dataHelper->getCustomFee(); $customFeeConfig['show_hide_customfee_block'] = $enabled && $minimumOrderAmount <= $subtotal && $quote->getFee() ? true : false; $customFeeConfig['show_hide_customfee_shipblock'] = $enabled && $minimumOrderAmount <= $subtotal ? true : false; return $customFeeConfig; }