Skip to content

"inlandcosts" is Included in the Grand Total #53

@khaledomari87

Description

@khaledomari87

Hello there,

I'll describe the issue by an example, assume you've set "inlandcosts" to 25$, and "max_order_total" to 1000$. Now add items to the cart with 998$ grand total.

See the implementation of Mage_Payment_Model_Method_Abstract::isApplicableToQuote()

if ($checksBitMask & self::CHECK_ORDER_TOTAL_MIN_MAX) {
       $total = $quote->getBaseGrandTotal();
       $minTotal = $this->getConfigData('min_order_total');
       $maxTotal = $this->getConfigData('max_order_total');
       if (!empty($minTotal) && $total < $minTotal || !empty($maxTotal) && $total > $maxTotal) {
            return false;
       }
}

So if the current payment method in the quote is set to "phoenix_cashondelivery", the GT will be 1023$ which makes the payment method not available, otherwise the GT will be 998$ and the payment method is available.

How did I fix it?
I overridden getConfigData method in Phoenix_CashOnDelivery_Model_CashOnDelivery as follows:

public function getConfigData($field, $storeId = null)
{
	if($field == 'max_order_total')
	{
		$customConfig = parent::getConfigData($field, $storeId);
		try {
			/* @var Mage_Checkout_Model_Type_Onepage $onePage */
			$onePage = Mage::getSingleton('checkout/type_onepage');
			$paymentCode = $onePage->getQuote()->getPayment()->getMethod();
			if($paymentCode == 'phoenix_cashondelivery')
				$customConfig += $this->getConfigData('inlandcosts', $storeId);
		} catch (Exception $e)
		{
			Mage::logException($e);
		}
		return $customConfig;
	}
	return parent::getConfigData($field, $storeId);
}

Please advise.
Many Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions