如何设置最低订单金额 WooCommerce

如果您管理使用以下语言构建的在线商店,那么这篇文章很有用 WooCommerce 并且您想知道如何设置最低订单金额 WooCommerce。 在设置中 default 网上商店的 self-hosted,结帐选项不存在。 因此,确定订单的最低金额将通过另一种方法完成。

与实体店相比,网上商店通常会根据其针对的客户、销售产品的类型、价值以及支付和交付方式施加新的规则。

如果我们去实体店花 10 美分购买产品没有问题,那么在网上商店情况就有些不同了。 客户下的任何订单也涉及商店的一些费用。 从订单的简单处理到包装发货,所有这些操作都需要时间。
当销售报价包含非常便宜的产品时,最好为每个订单设置最低金额。 例如,如果购物篮中的产品总数未达到 10 欧元的总和,则无法完成订单。

如何设置最低订单金额 WooCommerce

最简单的方法是在 functions.php 您可以通过它设置订单的最低金额 WooCommerce.

打开文件 functions.php 活动主题(最好是子主题)并添加以下代码:

// Set Minimum Order Amount in WooCommerce
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
 
function wc_minimum_order_amount() {
    
    $minimum = 10; // Set this variable to specify a minimum order value

    if ( WC()->cart->total < $minimum ) {

        if( is_cart() ) {
            wc_print_notice( 
                sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order ' , 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );
        } else {
            wc_add_notice( 
                sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order' , 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );

        }
    }
}

这里也是设置消息的地方,提示买家没有总金额未达到下单最低限额的商品。

如何设置最低订单金额 WooCommerce
您当前的订单总额为 3,00 欧元——您必须至少有 10,00 欧元的订单才能下订单

至 WooCommerce 一些在线支付模块提供自动支持设置下订单的限额。

此功能适用于以低价销售产品,无法支付加工和运输成本的在线商店。

作为科技爱好者,我从2006年开始在StealthSettings.com上愉快地撰写文章。我在操作系统方面有丰富的经验,包括macOS、Windows和Linux,还熟悉编程语言和博客平台(WordPress),以及在线商店平台(WooCommerce、Magento、PrestaShop)。

如何以 » WordPress » 如何设置最低订单金额 WooCommerce
发表评论