WooCommerce 中的“订单满 100 美元免费获得产品 X”优惠券代码

dra*_*035 4 php wordpress discounts coupon woocommerce

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

Loi*_*tec 5

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

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

最低消费金额

  • 插件免费版本已经具有自动优惠券功能,如果满足限制,则允许将优惠券自动添加到用户购物车中。还有上面

  • 使用此插件廉价商业版本,您缺少所需的功能:根据优惠券规则将免费产品添加到客户的购物车中。

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


关于 woocommerce 优惠券的其他技巧

1) WooThemes 片段:以编程方式创建优惠券

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);
Run Code Online (Sandbox Code Playgroud)