如何在WooCommerce中禁用全局缺货订单 [英] How to disable globally backorders in WooCommerce

查看:61
本文介绍了如何在WooCommerce中禁用全局缺货订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每天都有新产品添加到我的网站,继续为每个新产品和缺货产品选择不允许缺货"选项是没有用的.目前,随着拥有超过2,000种产品的数据库的不断增长,我发现每天执行相同的过程很繁琐.使用functions.php文件,我可以实现一些php代码来禁止所有现有和将来产品的缺货吗?

New products are being added daily to my website and it is unproductive to keep choosing the "Do not allow backorders" option for each new product and out of stock products. Currently with a growing database of over 2,000 products, I am finding it tedious to do the same process daily. Using the functions.php file, is there some php code I can implement to disallow backorders for all existing and future products?

欢迎和帮助.

推荐答案

只需使用以下代码行即可全局禁用积压订单:

Simply use the following line of code to disable backorders globally:

add_filter( 'woocommerce_product_backorders_allowed', '__return_false' );

代码进入您的活动子主题(或活动主题)的functions.php文件中.经过测试和工作.

Code goes in functions.php file of your active child theme (or active theme). Tested and work.

在某些情况下,对于某些插件,您应该定义优先级挂钩,并将其增加,如:

In some cases, with some plugins you should define the priority hook, increasing it like:

add_filter( 'woocommerce_product_backorders_allowed', '__return_false', 1000 );


对于延期交货通知,有woocommerce_product_backorders_require_notification过滤器.


For backorder notifications there is the woocommerce_product_backorders_require_notification filter.

这篇关于如何在WooCommerce中禁用全局缺货订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆