简体   繁体   中英

“Get product X for free on orders over $100” coupon code in WooCommerce

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

Yes this is possible with an additional plugin: The commercial version of WooCommerce Extended Coupon Features .

  • In WooCommerce coupons settings you have already a minimum field for orders amount:

Minimun金额花费

So with that 3 functionalities, the conditions are met to auto add a coupon code for "get product X for free on orders over $100".


Additional tricks about woocommerce coupons

1) WooThemes snippet: Create a coupon programmatically

2) Auto apply Discount Coupon to Customer's Purchase:

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM