Skip to content

Instantly share code, notes, and snippets.

@meminuygur
Created May 12, 2017 15:21
Show Gist options
  • Save meminuygur/a28cd2a591cda145baaf91edc1cf685d to your computer and use it in GitHub Desktop.
Save meminuygur/a28cd2a591cda145baaf91edc1cf685d to your computer and use it in GitHub Desktop.
MSP_CashonDelivery_Model_Order_Total collects bug
<?php
/**
* IDEALIAGroup srl
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category MSP
* @package MSP_CashOnDelivery
* @copyright Copyright (c) 2014 IDEALIAGroup srl (http://www.idealiagroup.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class MSP_CashOnDelivery_Model_Order_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
{
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$order = $invoice->getOrder();
$payment = $order->getPayment();
$method = $payment->getMethodInstance()->getCode();
if( $method == 'msp_cashondelivery' ) {
$amount = $order->getMspCashondelivery();
$baseAmount = $order->getMspBaseCashondelivery();
$invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmount);
}
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment