How to hide payment method on shopping cart price rules?
Asked
Active
Viewed 2,459 times
-3
-
3What have you tried so far? Please read http://stackoverflow.com/questions/how-to-ask – reto Jun 04 '14 at 12:01
-
In my project, i wants to hide credit card payment method hide when products subtotal is less than Rs.15000/-, when it goes higher than it, Credit card method display. – Parag Dave Jun 04 '14 at 12:46
-
how many payment method you are using means credit card and .... – Vishal Sharma Jun 04 '14 at 13:14
-
Credit Card, Debit Card, Paypal, Bank Transfer, COD – Parag Dave Jun 04 '14 at 13:21
-
1so if amount is less then 1500 then only credit card hide from the payment method ..right ? – Vishal Sharma Jun 04 '14 at 13:21
-
User can checkout but not use credit card method for purchase. – Parag Dave Jun 04 '14 at 13:22
-
right now i am trying in magento default theme – Parag Dave Jun 04 '14 at 13:29
2 Answers
2
Another way to accomplish this would be to using an observer payment_method_is_active
. See Disable payment options-only cash on delivery for particular product-magento
class Company_Module_Model_Observer
{
public function paymentMethodIsActive($observer)
{
$instance = $observer->getMethodInstance();
$result = $observer->getResult();
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
$grandtotal = round($totals["grand_total"]->getValue())
if ($instance->getCode() == "ccsave") {
if(1500 > $grandtotal && !Mage::app()->getStore()->isAdmin())
$result->isAvailable = false;
}
else{
$result->isAvailable = true;
}
}
}
}

Community
- 1
- 1

MagePal Extensions
- 17,646
- 2
- 47
- 62
-
-
@ParagDave:if you are using this then you have to create a new module and then use the Observer class on it and then put this code in your observer class.... – Vishal Sharma Jun 05 '14 at 05:26
1
Go into the
app/design/frontend/base/default/template/checkout/onepage/payment/methods.php
change your methods.php to this code
<?php
$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;
?>
<?php if (empty($methods)): ?>
<dt>
<?php echo $this->__('No Payment Methods') ?>
</dt>
<?php else:
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
$grandtotal = round($totals["grand_total"]->getValue());
foreach ($methods as $_method):
$_code = $_method->getCode();
if($grandtotal > 1500)
{
?>
<dt>
<?php if(!$oneMethod): ?>
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php
}
else
{
if($_code != 'ccsave')
{
?>
<dt>
<?php if(!$oneMethod): ?>
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php
}
}
?>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd>
<?php echo $html; ?>
</dd>
<?php endif; ?>
<?php endforeach;
endif;
?>
<?php echo $this->getChildChildHtml('additional'); ?>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?php echo $oneMethod ?>');
<?php endif; ?>
//]]>
</script>
EDIT:-
if you want to use this condition in model then go to the
app/code/core/mage/payment/helper/Data.php
Replace this function (getStoreMethods) with my code
public function getStoreMethods($store = null, $quote = null)
{
$res = array();
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
$grandtotal = round($totals["grand_total"]->getValue());
if($grandtotal > 1500)
{
foreach ($this->getPaymentMethods($store) as $code => $methodConfig) {
$prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/';
if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) {
continue;
}
$methodInstance = Mage::getModel($model);
if (!$methodInstance) {
continue;
}
$methodInstance->setStore($store);
if (!$methodInstance->isAvailable($quote)) {
/* if the payment method cannot be used at this time */
continue;
}
$sortOrder = (int)$methodInstance->getConfigData('sort_order', $store);
$methodInstance->setSortOrder($sortOrder);
$res[] = $methodInstance;
}
}
else
{
foreach ($this->getPaymentMethods($store) as $code => $methodConfig) {
if($code != 'ccsave')
{
$prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/';
if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) {
continue;
}
$methodInstance = Mage::getModel($model);
if (!$methodInstance) {
continue;
}
$methodInstance->setStore($store);
if (!$methodInstance->isAvailable($quote)) {
/* if the payment method cannot be used at this time */
continue;
}
$sortOrder = (int)$methodInstance->getConfigData('sort_order', $store);
$methodInstance->setSortOrder($sortOrder);
$res[] = $methodInstance;
}
}
}
usort($res, array($this, '_sortMethods'));
return $res;
}

Vishal Sharma
- 1,372
- 1
- 8
- 17