【问题标题】:How to apply coupon in the magento product view before adding product to cart如何在将产品添加到购物车之前在 magento 产品视图中应用优惠券
【发布时间】:2013-02-14 20:38:49
【问题描述】:

我必须复制优惠券功能,用户可以在其中应用优惠券代码并在将产品添加到购物车之前在产品页面本身中查看折扣价格。

所以我使用ajax调用来加载优惠券代码,其规则条件如下所示

<?php
-----

    $oCoupon = Mage::getModel('salesrule/coupon')->load($couponcode, 'code');
    if($oCoupon){
            $oRule     = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
            $rule_arr       = unserialize($oRule->getConditionsSerialized());
            $actions_serialized = unserialize($oRule->getData("actions_serialized"));
            $conditions = $rule_arr['conditions'];
            foreach($conditions as $condition){
                $conditions1 = $condition['conditions'];
                $type        = $condition['type'];
                foreach($conditions1 as $condition1){
                    $type     = $condition1['type'];
                    $value    = $condition1['value'];

                }
            }
        }
    }

----

在这里我验证了所有可能的规则 - 但它仍然没有验证所有定义的规则并且它不稳定。

无论如何我可以验证产品和优惠券规则 - 或者是否有任何扩展程序可以针对一种产品和优惠券规则进行验证。请帮帮我

【问题讨论】:

    标签: magento magento-1.7


    【解决方案1】:

    由于您可以像这样将代码应用于购物车/报价单,因此我建议您查看这些模型,了解它如何实际验证产品上的代码。 (向后工作)

    Mage::getSingleton('checkout/cart')
        ->getQuote()
        ->setCouponCode($couponcode)
        ->collectTotals()
        ->save();
    

    【讨论】:

      【解决方案2】:

      我建议看看这个免费的扩展以获得灵感: http://www.magentocommerce.com/magento-connect/estimate-shipping-on-the-product-page.html

      它允许通过模拟空购物车,添加产品并收集运费来在产品页面中显示运费估算。

      你要做的是模拟空购物车,添加产品,应用优惠券(使用 Jared Kipe 的方法)并获得总数。

      此模块将启发您并为您提供模拟空购物车的方法。

      【讨论】:

        猜你喜欢
        • 2013-11-28
        • 1970-01-01
        • 2023-03-10
        • 1970-01-01
        • 2017-01-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多