1

Woocommerce v2.6 stores the following meta_key values in the wp_postmeta table:

_sku

_price

_regular_price

_sale_price

_manage_stock

_stock_status

_featured

Does Woocommerce v3.x, still store are all of the above in an identical manner as v2.6 or have any of the above been relocated to another table and/or modified in any way?

LoicTheAztec
  • 184,753
  • 20
  • 224
  • 275
Robert
  • 39
  • 7

1 Answers1

1

In WooCommerce 3+ everything listed is the same, except for _featured that doesn't work any more.


The "feature" product functionality in WooCommerce 3+:

Since version 3, WooCommerce generates a featured term (name and slug) located in wp_terms table, which custom taxonomy is product_visibility in wp_term_taxonomy table.

The wp_term_relationships table make the link between:

  • the "featured" products IDs through the object_id key
  • the ID for product_visibility taxonomy through term_taxonomy_id key

The wp_term_taxonomy table make the link with the term featured through its term_id key.

It works jut like a post term.


Update: regarding other changes not listed in your question.

The product_visibility taxonomy also handle those terms (functionalities):

  • exclude-from-search (product visibility option)
  • exclude-from-catalog (product visibility option)
  • outofstock (stock status)
  • rated-1 to rated-5 (product rating)
LoicTheAztec
  • 184,753
  • 20
  • 224
  • 275
  • Thanks. I just checked woocommerce's docs and I found this: "We now use taxonomies to determine and display product visibility, featured products, and out of stock products instead of the slower post meta." Does this mean that stock status is now stored in the same way as featured? https://woocommerce.com/2017/04/woocommerce-3-0-release/ – Robert Jan 28 '18 at 15:18
  • Thanks, so in order to set an item to "Out Of Stock" I would need to update 3 rows with the selected item id: 1. In wp_postmeta, update manage_stock to "yes". 2. wp_postmeta update stock_status to "outofstock". 3. product_visibility update outofstock to "yes" ? – Robert Jan 28 '18 at 22:43
  • Currently I am updating the Woo 2.6 wp_postmeta table using PHP. When a product id goes out of stock I update its manage_stock to yes, and its stock_status to outofstock. This has been working well for quite some time. How would this be accomplished with Woo 3.x? – Robert Jan 28 '18 at 23:11
  • Thanks. I'm not familiar with the wp methods and/or class libraries. Where would I find them? Currently I accomplish the task with PHP using UPDATE queries on the wp_postmeta table. How do I accomplish this for Woo 3.x using UPDATE queries? – Robert Jan 28 '18 at 23:35
  • Aztec Disregard my last question. I'm going use the methods you suggested. I just need to include the WC class library, correct? – Robert Jan 28 '18 at 23:40
  • @Robert Thanks… You need to get the an instance of the WC_Product object *(if you don't have yet the `$product` variable)*… you can get it from a product ID this way: $product = `wc_get_product( $product_id );`… The you can apply to it [**all available WC_Product setters methods**](https://docs.woocommerce.com/wc-apidocs/class-WC_Product.html) … once done you need to save the data using `$product->save();` – LoicTheAztec Jan 29 '18 at 01:02