Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
Created December 4, 2013 20:52
Show Gist options
  • Select an option

  • Save ryaan-anthony/7795296 to your computer and use it in GitHub Desktop.

Select an option

Save ryaan-anthony/7795296 to your computer and use it in GitHub Desktop.
Hide all payment methods if none needed.
<?php
class Your_Custom_Block_Rewrite extends Mage_Checkout_Block_Onepage_Payment_Methods
{
protected function _canUseMethod($method)
{
$total = $this->getQuote()->getShippingAddress()->getBaseGrandTotal();
if((float)$total > 0){return parent::_canUseMethod($method);}
if($method->getCode() != 'free'){
return false;
}
return parent::_canUseMethod($method);
}
}
<?xml version="1.0"?>
<config>
<modules>
<Your_Custom>
<version>0.1.0</version>
</Your_Custom>
</modules>
<global>
<blocks>
<custom>
<class>Your_Custom_Block</class>
</custom>
<checkout>
<rewrite>
<onepage_payment_methods>Your_Custom_Block_Rewrite</onepage_payment_methods>
</rewrite>
</checkout>
</blocks>
</global>
</config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment