具有自定义条件的购物车规则? [英] Shopping Cart Rules with Custom Condition?

查看:125
本文介绍了具有自定义条件的购物车规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一张优惠券[coupon_code = SWIMFREE] 如果categoryswimming equipmenthobbyswimming,则折扣为50%.

I have made a coupon [coupon_code = SWIMFREE] if category is swimming equipment and hobby is swimming will be discount by 50%.

,现在我有3个步骤结帐的问题.这是说明...

and now I have problem about 3 steps checkout. Here's the description ...

  1. 结帐购物车:适用于优惠券
  2. 第一步:运输和开票 地址
  3. 第二步:选择您的爱好(还有另一个sales_flat_quote tablesales_flat_quote_hobby)
  4. 最终步骤:结帐->概述
  1. Checkout Cart : to apply to coupon
  2. First Step : Shipping and Billing Address
  3. Second Step : Pick your Hobby (has another sales_flat_quote table, sales_flat_quote_hobby)
  4. Final Step : Checkout->Overview

我想要的是:当应用优惠券且爱好在游泳时,第三步将价格更改为每种产品的价格,优惠券仍会显示在此处.

What i wanted is: when the coupon applied and the hobby is swimming, the third step changing the price to price every product, and coupon is still be shown there.

在爱好"步骤之后如何拦截优惠券?

分步案例示例:

1.在购物车中已经添加了

  • 泳衣的正常价格为100美元(游泳装备类)
  • 凯夫拉的正常价格为50美元(射击器材类别)
  • 优惠券申请SWIMFREE,总计为100美元(由于优惠券条件)

2.在运输和结算步骤上

  • 收货和付款地址-下一个

3.在兴趣爱好"上

  • 检查并确认足球爱好(单选按钮)

4.然后在概述步骤上

  • 泳衣的价格是50美元(游泳装备类)
  • 凯夫拉尔的价格是50美元(射击器材类别)
  • 优惠券申请SWIMFREE,总计总计现在为150 $(因为业余爱好不游泳)

我有很多产品,我尝试添加新的属性,但是与该属性无关,因为它在sales_flat_quote_hobby

i have a lot of products, I've tried to add new attributes, but it's not related with the attribute, because it's on sales_flat_quote_hobby

我尝试更改Sales/Model/Quote/Subtotal.php来设置购物车上的所有产品价格,但这似乎没用.

I've tried to change Sales/Model/Quote/Subtotal.php to set the all product prices on cart, but it seems useless.

推荐答案

已经由我自己找到了答案:

可能创建自定义优惠券条件.

重写Mage_SalesRule_Model_Rule_Condition_Product

rewrite the Mage_SalesRule_Model_Rule_Condition_Product

    public function validate(Varien_Object $object){
        if ($this->getAttribute() == 'quote_item_with_hobby') {

            $quote = Mage::getSingleton('checkout/cart')->getQuote();
            $hobby= $quote->getHobbyByItemId($object->getId());

            if ($hobby){
                if ($this->getOperator() == '=='){
                    if (strtolower($this->getValue()) == $hobby->getHobby()) return true;
                    else return false;
                }
                else if ($this->getOperator() == '!='){
                    if (strtolower($this->getValue()) == $hobby->getHobby()) return false;
                    else return true;
                }

            }
            return true;
        }

        return parent::validate($object);
    }

此函数将在加载的每个步骤中调用.然后检查是否返回true,则将应用优惠券;如果返回false,则将不应用优惠券.

this function will be called every step loaded. then checked if return true, then the coupon will be applied, if return false then the coupon won't be applied.

感谢所有参与的人.我很感激.

这篇关于具有自定义条件的购物车规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆