最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

database - WooCommerce sku location in DB

programmeradmin6浏览0评论

I need a little help. We want to connect our physical shop system with our virtual shop developed with woocommerce. So we need to be able to find where the SKU numbers are registred in the database so that we can do a batch process a few times a day to modify it as the products are physically sold (and not on the web).

But we haven't been able to find out where that number is registered in the WP database. Could someone help us?

I need a little help. We want to connect our physical shop system with our virtual shop developed with woocommerce. So we need to be able to find where the SKU numbers are registred in the database so that we can do a batch process a few times a day to modify it as the products are physically sold (and not on the web).

But we haven't been able to find out where that number is registered in the WP database. Could someone help us?

Share Improve this question asked Jul 17, 2020 at 14:06 federicofederico 211 silver badge2 bronze badges 2
  • 2 It's in wp_postmeta, where the meta_key = '_sku'. If you plan to update data in the store though, you'd be much better served by using the REST API, rather than modifying the data directly: docs.woocommerce/document/woocommerce-rest-api Modifying the database directly means that no WooCommerce code will run for important actions when products are updated. – Jacob Peattie Commented Jul 17, 2020 at 14:19
  • you can visit the following link to get an idea wordpress.stackexchange/questions/137501/… – Shamsur Rahman Commented Jul 17, 2020 at 14:37
Add a comment  | 

1 Answer 1

Reset to default 1

As suggested in comments, the best way to update stock, or any other product information would be through the WooCommerce API.

The product endpoint with all the parameters is documented here (link is directly to how to update): https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product.

I'm not very familiar with woocommerce, but based on other posts it looks like the stock value is stored in the _stock key in wp_postmeta, see here for more info on that and how to e.g. convert between post ID and SKU if you need to. Again, note that not doing this through the API you might miss out on other code that gets triggered if WooCommerce would usually do other things (e.g. if stock is set to zero maybe it updates other fields automatically or triggers other events if you update through the API)

发布评论

评论列表(0)

  1. 暂无评论