PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, May 9, 2022

[FIXED] How to disable globally backorders in WooCommerce

 May 09, 2022     hook-woocommerce, php, product, woocommerce, wordpress     No comments   

Issue

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.


Solution

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.



Answered By - LoicTheAztec
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing