How to disable globally backorders in WooCommerce

China☆狼群 提交于 2020-06-27 03:06:48

问题


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?

Any help is welcome and appreciated.


回答1:


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

add_filter( 'woocommerce_product_backorders_allowed', '__return_false' );

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 );

For backorder notifications there is the woocommerce_product_backorders_require_notification filter.



来源:https://stackoverflow.com/questions/56291624/how-to-disable-globally-backorders-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!