小编Vas*_*ova的帖子

根据客户在Woocommerce中的总购买金额添加百分比折扣

在Woocommerce,我想根据客户的总购买金额设置百分比折扣.例如,如果总购买金额大于或等于200$,则客户获得5%折扣.

所以,我有第一部分代码来显示总和:

function get_customer_total_order() {
    $customer_orders = get_posts( array(
        'numberposts' => - 1,
        'meta_key'    => '_customer_user',
        'meta_value'  => get_current_user_id(),
        'post_type'   => array( 'shop_order' ),
        'post_status' => array( 'wc-completed' )
    ) );

    $total = 0;

    foreach ( $customer_orders as $customer_order ) {
        $order = wc_get_order( $customer_order );
        $total += $order->get_total();
    }

    return $total;
}
Run Code Online (Sandbox Code Playgroud)

我想将我的代码与此答案的代码一起使用:
基于WooCommerce中购物车总数的累进折扣

有没有办法使用它们来设置基于所有订单总和的折扣?

php sql cart discount woocommerce

4
推荐指数
1
解决办法
378
查看次数

标签 统计

cart ×1

discount ×1

php ×1

sql ×1

woocommerce ×1