【问题标题】:“Get product X for free on orders over $100” coupon code in WooCommerceWooCommerce 中的“订单超过 100 美元免费获得产品 X”优惠券代码
【发布时间】:2016-09-26 21:06:56
【问题描述】:

是否有任何简单的方法或任何插件可以为以下类型的优惠创建优惠券代码:“订单超过 100 美元免费获得产品 X”?

【问题讨论】:

    标签: php wordpress woocommerce coupon discounts


    【解决方案1】:

    是的,这可以通过附加插件实现:WooCommerce Extended Coupon Features 的商业版本。

    • 在 WooCommerce 优惠券设置中,您已经有一个订单金额的最小字段:

    因此,有了这 3 个功能,就满足了自动添加“订单满 100 美元即可免费获得产品 X”的优惠券代码的条件。


    关于 woocommerce 优惠券的其他技巧

    1) WooThemes sn-p:Create a coupon programmatically

    2) 客户购买时自动应用优惠券:

    function order_price_is_greater_than_100() {
    
        global $woocommerce, $total_qty;
    
        if ( $woocommerce->cart->has_discount( $coupon_code ) ) return;
    
        if ( $woocommerce->cart->get_cart_total() >= 100 ) {
    
            $coupon_code = 'UNIQUECODE'; // <= set the name of your coupon code here
    
            if (!$woocommerce->cart->add_discount( sanitize_text_field( $coupon_code ))) {
                $woocommerce->show_messages();
            }
    
            echo '<div class="woocommerce_message"><strong>The total price in your cart is greater than 100: You get … </strong></div>';
    
        }
    }
    add_action('woocommerce_before_cart_table', 'order_price_is_greater_than_100', 10, 0);
    

    【讨论】:

    • 嗨@LoicTheAztec。我已经拥有免费礼品券插件,所以我将它与“最低消费”字段结合使用。我没有测试你的答案。您是否 100% 肯定您的解决方案有效?请确认,我会接受你的回答。谢谢!
    • @drake035 是的,这当然可行!但是您需要微调设置,并且可能会根据您的特定 woocommerce 商店设置和代码自定义添加一些 php 代码。
    猜你喜欢
    • 1970-01-01
    • 2019-07-29
    • 2021-01-21
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 2022-01-09
    • 1970-01-01
    • 2019-12-06
    相关资源
    最近更新 更多