PHOENIX-MEDIA / Magento-CashOnDelivery

Cash on Delivery allows to book additional fee on delivery depending on inland or international delivery.
43 stars 46 forks source link

Cod is sometimes shown buying downloadable products #13

Closed kamzata closed 6 years ago

kamzata commented 10 years ago

I noticed that sometimes (I can understand why) Cod option is shown buying downloadable products.

How can I remove the option?

(Cache management was disable)

PHOENIX-MEDIA commented 10 years ago

Mage_Payment_Model_Method_Abstract has two hooks to change the "availability" of the payment option:

Mage_Payment_Model_Method_Abstract::isAvailable and Mage_Payment_Model_Method_Abstract::isApplicableToQuote

If you check for $quote->isVirtual() you should be able to hide the payment option.

Let us know if this works, would appreciate a pull request as this definitely makes sense.

kamzata commented 10 years ago

Thank you but reinstalling extension has solved the issue.

kamzata commented 10 years ago

Due to new problems I solved by editing the file Model/CashOnDelivery.php and adding:

.....
public function isAvailable($quote = null)
    {
        if($quote->isVirtual()) {
            return false;
        }

        if (!parent::isAvailable($quote)) {
            return false;
        }
        if (!is_null($quote)) {
        ......

and now it seems not miss a beat.