2016-02-28 202 views
0

可以选择每种产品的付款方式吗?Magento - 每种产品的付款方式

例如:在我的商店中,有一款产品因为“现金游戏”而销售,因此当客户购买此产品时,magento仅启用“游戏中”的付款选项。

至于其他真钱购买的产品,它禁用了“游戏中”的付款选项并启用了信用卡付款(例如)。

我发现了一些模块,但经过测试,并没有工作。

感谢的

+0

你可以告诉你有哪些模块使用?如果在购物车中同时存在两种产品,但我希望他们应该做好你的工作http://www.blog.magepsycho.com/how-to-filter-payment-method-in-onepage-checkout/ –

+0

请检查以下内容链接模块 https://www.magentocommerce.com/magento-connect/payment-method-per-product.html,https://www.magentocommerce.com/magento-connect/payment-restrictions-by-amasty。 html –

+0

确实解决了您的问题 – Rathinam

回答

0

是的,你可以通过这个模块来做到这一点。例如我们想为某些产品交付货款 - >

首先创建产品属性(名称:'magepal_payment_filter_by_product',类型:是/否)以标识这些产品。

Magento的V1.7,你可以

自动启用支付模块编程的

如基本[查看] [1]

启用所有适用的支付模块和滤波器模块,以显示其中

在/应用程序/代码/本地/ MagePal/PaymentFilterByProduct的/ etc/config.xml中

<?xml version="1.0"?> 
<config> 
<modules> 
    <MagePal_PaymentFilterByProduct> 
     <version>1.0.1</version> 
    </MagePal_PaymentFilterByProduct> 
</modules> 
<global> 
    <helpers> 
     <paymentfilterbyproduct> 
      <class>MagePal_PaymentFilterByProduct_Helper</class> 
     </paymentfilterbyproduct> 
     <payment> 
      <rewrite> 
       <data>MagePal_PaymentFilterByProduct_Helper_Payment_Data</data> 
      </rewrite> 
     </payment>    
    </helpers>  
</global> 
</config> 

在/应用程序/代码/本地/ MagePal/PaymentFilterByProduct /助手/付款/沓ta.php

<?php 
class MagePal_PaymentFilterByProduct_Helper_Payment_Data extends Mage_Payment_Helper_Data 
{ 

public function getStoreMethods($store = null, $quote = null) 
{ 
    $methods = parent::getStoreMethods($store, $quote); 

    if(!Mage::getStoreConfig('paymentfilterbyproduct/general_option/paymentfilterbyproduct_enable', Mage::app()->getStore()) || !$quote){ 
     return $methods; 
    } 

    //get a list of product in cart 
    $cart = Mage::getSingleton('checkout/session'); 

    $specialProductInCart = array(); 

    foreach ($cart->getQuote()->getAllItems() as $item) { 
     $specialProductInCart[] = $item->getMagepalPaymentFilterByProduct();     
    } 

    // if special product in cart 
    // need to if check $item->getMagepalPaymentFilterByProduct() return 'yes/no' or '0/1) 
    if(in_array('yes', $specialProductInCart)){ 
     $filter_csv = Mage::getStoreConfig('paymentfilterbyproduct/filter_option/paymentfilter_special_products', Mage::app()->getStore()); 
    } 
    else{ 
     $filter_csv = Mage::getStoreConfig('paymentfilterbyproduct/filter_option/paymentfilter_all_product', Mage::app()->getStore()); 
    } 

    $filter_array = explode(",", $filter_csv); 

    foreach ($methods as $k => $method){ 
     if(!in_array($method->getCode(), $filter_array)) 
      unset($methods[$k]);  
    }//methods 

    return $methods; 
} 
} 

在/app/code/local/MagePal/PaymentFilterByProduct/etc/system.xml

<?xml version="1.0"?> 
<config> 
<tabs> 
    <magepal translate="label" module="paymentfilterbyproduct"> 
     <label>MagePal</label> 
     <sort_order>900</sort_order> 
    </magepal> 
</tabs> 
<sections> 
    <paymentfilterbyproduct translate="label" module="paymentfilterbyproduct"> 
     <label>Payment Method Filter by Product</label> 
     <tab>magepal</tab> 
     <sort_order>1000</sort_order> 
     <show_in_default>1</show_in_default> 
     <show_in_website>1</show_in_website> 
     <show_in_store>1</show_in_store> 
     <groups> 
      <general_option translate="label"> 
       <label>General Options</label> 
       <frontend_type>text</frontend_type> 
       <sort_order>1</sort_order> 
       <show_in_default>1</show_in_default> 
       <show_in_website>1</show_in_website> 
       <show_in_store>1</show_in_store> 
       <fields> 
        <paymentfilter_enable translate="label"> 
         <label>Enable Payment Filter</label> 
         <frontend_type>select</frontend_type> 
         <source_model>adminhtml/system_config_source_yesno</source_model> 
         <sort_order>50</sort_order> 
         <show_in_default>1</show_in_default> 
         <show_in_website>1</show_in_website> 
         <show_in_store>1</show_in_store> 
        </paymentfilter_enable> 
       </fields> 
      </general_option> 
      <filter_option translate="label"> 
       <label>Payment Method Filter Configuration</label> 
       <frontend_type>text</frontend_type> 
       <sort_order>2</sort_order> 
       <show_in_default>1</show_in_default> 
       <show_in_website>1</show_in_website> 
       <show_in_store>1</show_in_store> 
       <comment>Please enable all applicable payment methods in system payment config</comment> 
       <fields> 
        <paymentfilter_all_products translate="label"> 
         <label>Select Default Payment option for All Products</label> 
         <frontend_type>multiselect</frontend_type> 
         <source_model>MagePal_PaymentFilterByProduct_ActivePaymentMethod</source_model> 
         <sort_order>30</sort_order> 
         <show_in_default>1</show_in_default> 
         <show_in_website>1</show_in_website> 
         <show_in_store>1</show_in_store> 
        </paymentfilter_admin> 
        <paymentfilter_special_products translate="label"> 
         <label>Select Payments for Cart with Special Products</label> 
         <frontend_type>multiselect</frontend_type> 
         <source_model>MagePal_PaymentFilterByProduct_ActivePaymentMethod</source_model> 
         <sort_order>40</sort_order> 
         <show_in_default>1</show_in_default> 
         <show_in_website>1</show_in_website> 
         <show_in_store>1</show_in_store> 
        </paymentfilter_store> 
       </fields> 
      </filter_option> 
     </groups> 
    </paymentfilterbyproduct> 
</sections> 
</config> 

在/应用程序/代码/本地/ MagePal/PaymentFilterByProduct /助手/数据。 PHP

<?php 
class MagePal_PaymentFilterByProduct_Helper_Data extends Mage_Core_Block_Template 
{ 
} 

在/app/code/local/MagePal/PaymentFilterByProduct/ActivePaymentMethod.php

getActiveMethods();

foreach ($payments as $paymentCode=>$paymentModel) { 
     if($paymentModel->canUseCheckout() == 1){ 
      $paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title'); 
      $methods[$paymentCode] = array(
       'label' => $paymentTitle, 
       'value' => $paymentCode, 
      ); 
     } 
    } 

    return $methods; 
} 
} 

在/app/etc/modules/MagePal_PaymentFilterByProduct.xml

<?xml version="1.0"?> 
<config> 
<modules> 
    <MagePal_PaymentFilterByProduct> 
     <active>true</active> 
     <codePool>local</codePool> 
    </MagePal_PaymentFilterByProduct> 
</modules> 
</config> 
+0

谢谢,但是我在另一篇文章中看到的这个模块似乎是相同的。我已经测试并失败。但万一我会再次测试并带来回报.. – ManehScripts