/** * @return $this */ public function initTotals() { $parent = $this->getParentBlock(); $this->_order = $parent->getOrder(); $this->_source = $parent->getSource(); // $store = $this->getStore(); $fee = new \Magento\Framework\DataObject(['code' => 'fee', 'strong' => false, 'value' => $this->_source->getFee(), 'label' => $this->_dataHelper->getFeeLabel()]); $parent->addTotal($fee, 'fee'); return $this; }
/** * @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 $this */ public function initTotals() { $this->getParentBlock(); $this->getOrder(); $this->getSource(); if (!$this->getSource()->getFee()) { return $this; } $total = new \Magento\Framework\DataObject(['code' => 'fee', 'value' => $this->getSource()->getFee(), 'label' => $this->_dataHelper->getFeeLabel()]); $this->getParentBlock()->addTotalBefore($total, 'grand_total'); return $this; }
/** * @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; }