3

I want to add a feature by which I can charge a specific amount to the customer when he use Cash on Delivery but no extra charge when he uses the payment gateway in magento 1.9X.? kindly provide a solution.

  • Did you try this extensionhttps://magecomp.com/magento-payment-fee.html – Gaurav Jain Mar 15 '18 at 9:06
1

you can try this extension, but before that test in staging or demo site : https://www.magentocommerce.com/magento-connect/cash-on-delivery-3.html

or

https://www.magentocommerce.com/magento-connect/cash-on-delivery-extra-charges.html

<?php
class Mfp_Cod_Model_Observer 
{

    public function getCashOnDelvery(Varien_Event_Observer $observer) {
        $event           = $observer->getEvent();
        $method          = $event->getMethodInstance();
        $result          = $event->getResult();
        $isModuleEnable = Mage::getStoreConfig('cod/cod/enable');
        $returnValue = false;
        if($isModuleEnable) {

            if($method->getCode() == 'cashondelivery' ){

                $quote = Mage::getSingleton('checkout/cart')->getQuote();
        if($quote->getEntityId()!='')
        {
                $add = $quote->getShippingAddress();
                $postcode = $add->getData('postcode');
                $comparisonMode = Mage::getStoreConfig('cod/cod/mode');
                $zipCodes = Mage::getStoreConfig('cod/cod/zipcode');
                $isExist = false;
                if(strlen($postcode) >= 6) {
                    if(trim($zipCodes) == '') {             
                        $result->isAvailable = true;
                    } else {    

                        if(strpos($zipCodes, $postcode) !==  false) {
                            $isExist = true;
                        }

                        if($isExist != true) {

                            $zipCodesArray = explode(',', nl2br($zipCodes));
                            if(count($elementLineArray) > 1) {
                                foreach($zipCodesArray as $codzipLine) {
                                    $elementLineArray = explode('-', $codzipLine);
                                    if(count($elementLineArray) == 2 && ( $postcode >= $elementLineArray[0] && $postcode <= $elementLineArray[1] )) {
                                        $isExist = true;
                                        break;
                                    } else if($postcode == $codzipLine) {
                                        $isExist = true;
                                        break;
                                    }
                                }
                            }
                        }
                        $returnValue = ($isExist)?true:false;
                        $result->isAvailable = $returnValue;
                    }
                }
                $result->isAvailable = $returnValue;   
}
            } 
        }   
    }
}
  • 1
    link does not exist – Kishan Patadia Nov 19 '17 at 16:48
  • @Baby in Magento, Links are not available, check again – Teja Bhagavan Kollepara Nov 29 '17 at 4:37
  • @TejabhagavanKollepara thanks for informing, i updated code..... – Baby in Magento Nov 29 '17 at 5:10
  • @BabyinMagento, you are welcome, I am suggesting you please add the file path and edit the urls of existed – Teja Bhagavan Kollepara Nov 29 '17 at 5:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.