1

I am facing an issue and not able to figure it out if its a magento bug.

I have added an additional fee created a module for it and its working fine every where. The only issue occurs If I come in payment step (checkout).

When I am in payment step and change the price from additional fee from backend and refresh the the payment page. My additional fee gets updated but grand total does not.

But if I go back to shipping step again proceed to payment step from there it gets proper total again. That means $quote->collectTotals() are not called in payment step? Or Am I missing something?

public function collect(
    \Magento\Quote\Model\Quote $quote,
    \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
    \Magento\Quote\Model\Quote\Address\Total $total
)
{
    parent::collect($quote, $shippingAssignment, $total);
    if (!count($shippingAssignment->getItems()) || !$this->feeHelper->isModuleEnable()) {
        return $this;
    }

    $fee = $this->calculator->calculate($quote);
    $total->setTotalAmount($this->getCode(), $fee);
    $total->setBaseTotalAmount($this->getCode(), $fee);
    $total->setFee($fee);
    $total->setBaseFee($fee);
    $quote->setFee($fee);
    $quote->setBaseFee($fee);
    return $this;
}

/**
 * @param \Magento\Quote\Model\Quote $quote
 * @param \Magento\Quote\Model\Quote\Address\Total $total
 * @return array
 */
public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
{
    $result = [];
    if(!$this->feeHelper->isModuleEnable()){
        return $result;
    }

    $fee = $this->calculator->calculate($quote);
    if($fee > 0){
        $result = [
            'code' => $this->getCode(),
            'title' => $this->getLabel(),
            'value' => $fee
        ];
    }

    return $result;
}
  • You need to do update total programetically. – Dhiren Vasoya Sep 26 '18 at 14:19
  • I faced this issue last time, I think. You might need to add / modify quote javascript for additional fee module. The checkout pages are mostly written using knockoutJS – Afham Sep 26 '18 at 16:18
  • So is this a magento bug? – Priyank Sep 26 '18 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.