php - WooCommerce 中的 “Get product X for free on orders over $100” 优惠券代码

标签 php wordpress woocommerce coupon discounts

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

最佳答案

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

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

Minimun amount spend

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


关于 woocommerce 优惠券的其他技巧

1) WooThemes 片段: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);

关于php - WooCommerce 中的 “Get product X for free on orders over $100” 优惠券代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37501884/

相关文章:

php - CodeIgniter 中的动态路由问题

javascript - 如何从页面上的特定元素创建 HTML 链接

woocommerce - 删除 woocommerce 中的小计

php - 显示 WooCommerce 可变产品的促销变体节省金额

php - Laravel 5.6 更改时间戳

php - Imagick 调整大小、居中和稀疏填充问题

html - CSS加载延迟页面显示

php - 更新 WooCommerce 中的购物车小计

php - 如何在每次迭代中获取 popen() 回调的最后一行?

mysql - 导出到 ShipStation 时,WooCommerce 订单中显示的订单日期为 01-01-1970