如何在 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,一些在线支付模块提供了自动支持来设置下订单的限额。

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

如何以 » WordPress » 如何在 WooCommerce 中设置最低订单金额

对技术充满热情,我喜欢测试和编写有关操作系统的教程 macOS, Linux, Windows, 关于 WordPress, WooCommerce 和配置 LEMP 网络服务器 (Linux、NGINX、MySQL 和 PHP)。 我写在 StealthSettings.com 自 2006 年以来,几年后我开始撰写 iHowTo.Tips 教程和有关生态系统中设备的新闻 Apple: iPhone, iPad, Apple 手表,HomePod, iMac, MacBook、AirPods 和配件。

发表评论