WooCommerce 最低订单金额指的是顾客在网店下单时必须达到的最低消费金额。零售商店或服务提供商通常会这样设置,确保交易对业务具有经济可行性,并覆盖运输、处理或支付手续费等成本。
![图片[1]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219161033646-image.png)
如何在 WooCommerce 中设置最低订单金额
在 WooCommerce 中设置最低订单金额,可以用 PHP 代码 maybe plug-in (software component),具体选择取决于你们自己的需求。
用 PHP 代码设置 WooCommerce 最低订单金额
通过 PHP 代码设置 WooCommerce 最低订单金额,可以自定义控制结账要求。在主题的 functions.php
文件中添加几行代码,即可确保订单符合你们自己的需求。
在向 WordPress 网站添加自定义 PHP 代码之前,务必要谨慎:
- Backup SitesUse UpdraftPlus 或主机提供的工具对网站进行完整备份(包括文件和数据库),确保在代码出现问题时可以快速恢复。可以参阅How to backup WordPress website data?
- 用子主题:不要直接修改主题文件,建议用subtheme,防止主题更新时覆盖自定义代码。可以了解How to Create a WordPress Child Theme (Beginner's Guide)
- 咨询专业人士:如果没有编程经验,建议咨询开发者或用plug-in (software component),而不是自行插入代码。
如何添加代码
在 WordPress 仪表盘中,前往 Appearance > Theme Editorand then in the右侧文件列表hit the nail on the head functions.php
Documentation.
![图片[2]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219154142712-image.png)
接下来,将下面代码片段复制并粘贴到 functions.php
文件中,即可应用 WooCommerce 最低订单金额限制。
add_action( 'WooCommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
function required_min_cart_subtotal_amount() {
// HERE Set minimum cart total amount
$minimum_amount = 200;
// Total (before taxes and shipping charges)
$cart_subtotal = WC()->cart->subtotal;
// Add an error notice is cart total is less than the minimum required
if( $cart_subtotal < $minimum_amount ) {
// Display an error message
wc_add_notice( '<strong>' . sprintf( __("A minimum total purchase amount of %s is required to checkout."), wc_price($minimum_amount) ) . '<strong>', 'error' );
}
}
点update按钮运行代码:
![图片[3]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219154403300-image.png)
在此代码中,WooCommerce 的最低订单金额已设置为 $200The
因此,如果订单金额低于 $200,顾客就无法继续结账,并会收到下面通知,提醒他们店铺已应用此规则。
![图片[4]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219154621511-image.png)
顾客必须增加商品数量或添加更多商品到购物车,满足最低订单金额的要求并完成购买。
可以在上述代码中将 200 替换为任意其他数值,更改 WooCommerce 的最低订单金额。
用插件设置 WooCommerce 最低订单金额
如果觉得之前的方法过于复杂,或者改用更简单、安全的方法,我们推荐用 WooCommerce Min Max Quantity Plug-ins.
![图片[5]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219155020570-image.png)
如何用插件设置 WooCommerce 最低订单金额
步骤 1:安装 WooCommerce Min Max Quantity 插件
购买并下载 WooCommerce Min Max Quantity 插件的 ZIP 文件。
在 WordPress 后台上传并安装插件。
go into WordPress > iThemeland > License,输入许可证密钥并激活插件。
![图片[6]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219155127292-image.png)
插件激活后,即可按照接下来的步骤,设置 WooCommerce 购物车最低订单金额规则。
步骤 2:设置 WooCommerce 最低订单金额规则
要在插件中创建 WooCommerce 最低订单金额 规则,请按照下面步骤操作:
在 WordPress 仪表盘中,前往 iThemeland > Min Max Quantity,打开插件主界面。
![图片[7]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219155429465-image.png)
exist 常规(General) 选项卡中,找到 购物车限制(Cart Restrictions) 部分,该部分包含以下两个选项:
- 启用购物车数量限制(Enable cart quantity restriction)
- 启用购物车消费限制(Enable cart spend restriction)
![图片[8]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219155449603-image.png)
设置最低订单金额规则
activate "启用购物车消费限制” 选项。
exist 最低消费限制(Minimum spend restriction) 字段中输入最低订单金额。
根据需要选择下面可选项(可选):
- 包含运费及相关费用:如果启用这个选项,顾客购物车的总金额(包括运费和其他费用)必须超过设定的最低金额。
- 禁止优惠券计算:如果启用此选项,优惠券折扣金额不会计入最低消费限制。
strike (on the keyboard) 保存设置(Save settings),应用规则。
![图片[9]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219155547263-image.png)
步骤 3:设置最低订单金额通知
在 WooCommerce 设置最低订单金额后,需要设置通知,方便顾客了解店铺的消费限制规则。
Setting method
1. Opening 通知(Notification) tab, find the 购物车页面错误消息(Cart Page Error Messages) Part.
2. 在 最低购物车数量未达到(Minimum Cart quantity not reached) 字段中,可以看到默认的提示信息。
- 如果默认通知符合需求,则无需更改,插件会自动在购物车金额不足时向顾客显示提示。
3. 如果需要自定义通知,可以在文本框中输入自定义消息The
![图片[10]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219160004342-image.png)
可用的占位符(可选):
- {Limit}:在消息中显示最低消费金额或数量限制。
- {Cart_quantity}:在消息中显示当前购物车的商品总数量。
- {Cart_quote}:可用于自定义显示购物车的相关信息。
这样,就可以根据店铺需求,灵活设置 WooCommerce 购物车的最低订单金额提醒The
示例 1:在 WooCommerce 中设置最低订单金额为 $100
如果想顾客的订单金额必须超过 $100,可以按照下面步骤操作:
- tick 启用购物车消费限制(Enable cart spend restrictions)The
- exist 最低消费限制(Minimum spend restriction) 的文本框中输入 100The
- strike (on the keyboard) 保存设置(Save Settings) Button.
![图片[11]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219160227683-image.png)
当顾客的订单总金额低于 $100 时,他们将在 WooCommerce 购物车页面上收到通知,提醒他们需要满足最低订单金额要求。
![图片[12]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219160241998-image.png)
WooCommerce Min Max Quantity 插件的其他功能
设置 WooCommerce 最低订单金额 只是 WooCommerce Min Max Quantity 插件的众多功能之一。这个插件提供了灵活的选项,可以对商品数量、订单数量及其他限制进行自定义设置。
我们来看看其中的一些功能。
在 WooCommerce 中设置购物车数量限制
许多店铺管理员需要对购物车数量进行限制,这对于控制最低或最高购买数量非常有用。例如,可以限制顾客在购物车中添加的商品数量范围,确保订单符合自己商店的销售策略。
WooCommerce Min Max Quantity 插件是一个强大的工具,可以快速、轻松地设置购物车商品数量限制规则。
Example:
- 如果希望每位顾客最多只能购买 20 件商品It's okay.将最大数量限制设置为 20,这样顾客在结账时就无法超过该数量。
![图片[13]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219160518361-image.png)
如果需要更详细的操作指南,可以参考本教程,了解如何在 WooCommerce 中设置订单数量限制The
在 WooCommerce 产品类别/标签上添加限制规则
如果你们的电商网站有多个产品类别,对特定类别或标签应用限制是很常见的需求。
WooCommerce Min Max Quantity 插件支持在 WooCommerce 产品类别或标签 上设置数量respond in singing消费金额限制。
![图片[14]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219160656184-image.png)
设置产品类别/标签的消费限制规则
- tick 启用类别消费限制(Enable category spend restrictions)The
- exist 最低消费限制(Minimum spend restriction) respond in singing 最高消费限制(Maximum spend restriction) 字段中输入相应的金额。
- strike (on the keyboard) 保存设置(Save Options),规则将应用于所有选定的产品类别和标签。
![图片[15]-如何在 WooCommerce 中设置最低订单金额(代码 & 插件指南)](https://www.361sale.com/wp-content/uploads/2025/02/20250219160707437-image.png)
reach a verdict
设置 WooCommerce 最低订单金额 is an提升盈利、优化运营furthermoreImproving the user experience的策略。设定最低消费金额时,需要平衡客户期望,避免因过高的门槛导致潜在顾客流失。
WooCommerce Min Max Quantity 插件 furnish灵活的规则设置,支持不同场景下的最低订单金额配置。
Link to this article:https://www.361sale.com/en/33637The article is copyrighted and must be reproduced with attribution.
No comments