Php magento中信用卡折扣的自定义价格规则

Php magento中信用卡折扣的自定义价格规则,php,magento-1.7,cart,Php,Magento 1.7,Cart,我希望有人能帮我制定一个我一直有问题的价格规则。如果有人用指定的信用卡付款,我想打一定的折扣 例如,假设我想对Visa信用卡给予一定的折扣,即如果客户使用Visa信用卡付款,他必须获得{xy}金额的折扣 我已经尝试了很多,我扩展了Mage_SalesRule_Model_Rule_Condition_Address类,并添加了一个新属性,我在管理站点上获得了创建规则的选项 但问题是,当我使用信用卡visa进行支付并再次回到支付模式以更改模式并使用其他支付卡时,它会获取上一张支付卡的信息,并对未指

我希望有人能帮我制定一个我一直有问题的价格规则。如果有人用指定的信用卡付款,我想打一定的折扣

例如,假设我想对Visa信用卡给予一定的折扣,即如果客户使用Visa信用卡付款,他必须获得{xy}金额的折扣

我已经尝试了很多,我扩展了Mage_SalesRule_Model_Rule_Condition_Address类,并添加了一个新属性,我在管理站点上获得了创建规则的选项

但问题是,当我使用信用卡visa进行支付并再次回到支付模式以更改模式并使用其他支付卡时,它会获取上一张支付卡的信息,并对未指定的信用卡提供折扣。 我的扩展课程是:

class Alw_ManageProduct_Model_Condition_Address extends Mage_SalesRule_Model_Rule_Condition_Address
{
    public function loadAttributeOptions()
    {
        $attributes = array(
            'base_subtotal' => Mage::helper('salesrule')->__('Subtotal'),
            'total_qty' => Mage::helper('salesrule')->__('Total Items Quantity'),
            'weight' => Mage::helper('salesrule')->__('Total Weight'),
            'payment_method' => Mage::helper('salesrule')->__('Payment Method'),
            'shipping_method' => Mage::helper('salesrule')->__('Shipping Method'),
            'postcode' => Mage::helper('salesrule')->__('Shipping Postcode'),
            'region' => Mage::helper('salesrule')->__('Shipping Region'),
            'region_id' => Mage::helper('salesrule')->__('Shipping State/Province'),
            'country_id' => Mage::helper('salesrule')->__('Shipping Country'),
            'cc_type' => Mage::helper('salesrule')->__('Credit Card Type'),
        );

        $this->setAttributeOption($attributes);

        return $this;
    }

    public function getAttributeElement()
    {
        $element = parent::getAttributeElement();
        $element->setShowAsText(true);
        return $element;
    }

    public function getInputType()
    {
        switch ($this->getAttribute()) {
            case 'base_subtotal': case 'weight': case 'total_qty':
                return 'numeric';

            case 'shipping_method': case 'payment_method': case 'country_id': case 'cc_type': case 'region_id':
                return 'select';
        }
        return 'string';
    }

    public function getValueElementType()
    {
        switch ($this->getAttribute()) {
            case 'shipping_method': 
            case 'payment_method': 
            case 'country_id': 
            case 'region_id': 
            case 'cc_type' :
                return 'select';
        }
        return 'text';
    }

    public function getValueSelectOptions()
    {
        if (!$this->hasData('value_select_options')) {
            switch ($this->getAttribute()) {
                case 'country_id':
                    $options = Mage::getModel('adminhtml/system_config_source_country')
                        ->toOptionArray();
                    break;

                case 'region_id':
                    $options = Mage::getModel('adminhtml/system_config_source_allregion')
                        ->toOptionArray();
                    break;

                case 'shipping_method':
                    $options = Mage::getModel('adminhtml/system_config_source_shipping_allmethods')
                        ->toOptionArray();
                    break;

                case 'payment_method':
                    $options = Mage::getModel('adminhtml/system_config_source_payment_allmethods')
                        ->toOptionArray();
                    break;

                case 'cc_type':
                    $options = Mage::getModel('adminhtml/system_config_source_payment_cctype')
                        ->toOptionArray();
                    break;

                default:
                    $options = array();
            }
            $this->setData('value_select_options', $options);
        }
        return $this->getData('value_select_options');
    }

    /**
     * Validate Address Rule Condition
     *
     * @param Varien_Object $object
     * @return bool
     */
    public function validate(Varien_Object $object)
    {
        $address = $object;
        if (!$address instanceof Mage_Sales_Model_Quote_Address) {
            if ($object->getQuote()->isVirtual()) {
                $address = $object->getQuote()->getBillingAddress();
            }
            else {
                $address = $object->getQuote()->getShippingAddress();
            }
        }

        if ('payment_method' == $this->getAttribute() && ! $address->hasPaymentMethod()) {
            $address->setPaymentMethod($object->getQuote()->getPayment()->getMethod());
        }

        if('cc_type' == $this->getAttribute() && ! $address->hasCcType()) {
            $address->setCcType($object->getQuote()->getPayment()->getCcType());

            // validation cc type

            //echo $cct = $object->getQuote()->getPayment()->getCcType();
            //die;

            // if ($this->validateAttribute($cct)) {
            //    return true;
            //} else {
            //    return false;
            //}              

        }

        return parent::validate($address);
    }
}

如果有人可以的话,请帮帮我……

我这里也有同样的问题。你解决了吗?我也在找类似的东西。如果有人有更多关于网关的文档,If可能会很有趣