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

Thursday, February 17, 2022

[FIXED] SQL query to change backorder status of all products in WooCommerce

 February 17, 2022     product, sql, stock, woocommerce, wordpress     No comments   

Issue

In WooCommerce you can change the status of a product to allow backorders, the default setting is 'not allowed'. I have thousands of products on my shop and I rather not change it manually for all of them. Is there an SQL query that could do this for me directly in the database?


Solution

Try running this query in mySql

 UPDATE wp_postmeta SET  meta_value = 'yes' WHERE meta_key = '_backorders';

This is not enough to achieve your purpose. Need to enable Manage stock as well.

Try running this query also if WooCommerce allow backorders global settings is not enabled.

UPDATE wp_postmeta SET  meta_value = 'yes' WHERE meta_key = '_manage_stock';

Need to update stock quantity as well

UPDATE wp_postmeta SET  meta_value = 1000 WHERE meta_key = '_stock';

For stock status

UPDATE wp_postmeta SET  meta_value = 'instock' WHERE meta_key = '_stock_status';


Answered By - mujuonly
  • 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