Magento 如何隐藏购物车价格规则上的付款方式?
如何在购物车价格规则中隐藏付款方式?进入Magento 如何隐藏购物车价格规则上的付款方式?,magento,magento-1.7,magento-1.6,magento-1.8,Magento,Magento 1.7,Magento 1.6,Magento 1.8,如何在购物车价格规则中隐藏付款方式?进入 app/design/frontend/base/default/template/checkout/onepage/payment/methods.php 将methods.php更改为以下代码 <?php $methods = $this->getMethods(); $oneMethod = count($methods) <= 1; ?> <?php if (empty($methods)): ?> <
app/design/frontend/base/default/template/checkout/onepage/payment/methods.php
将methods.php更改为以下代码
<?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>
用“我的代码”替换此函数getStoreMethods
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;
}
实现这一点的另一种方法是使用观察员付款方法。看
到目前为止你试过什么?请阅读我的项目,我想隐藏信用卡付款方式隐藏产品小计小于Rs.15000//-时,高于它时,显示信用卡付款方式。您使用的付款方式有多少表示信用卡和……信用卡、借记卡、贝宝、银行转账、,CODso如果金额小于1500,则只有信用卡才能隐藏付款方式。对吗?此文件在哪个位置可用?Filename?@ParagDave:如果您正在使用这个模块,那么您必须创建一个新模块,然后在其上使用Observer类,然后将此代码放入Observer类中。。。。
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;
}
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;
}
}
}
}