Product Data Structure Explained

wp_posts

These are the main Product Columns and can be retrieved using get_post.

example: If I have a product with an ID of 83:

$product = get_post(83);

Column Name Description
ID Product ID
post_content Product Description
post_title Product Name
post_name Product Slug
post_status Product Publishing Status (Draft, Publish, Trash)
post_type Product Custom Post Type (wpsc-product)
post_name Product Slug
post_parent 0 if it is a normal product, ID of Parent Product if it is a variation

wp_postmeta

These are the main available product meta data.. due to search limitations of serialized data, things like Price and SKU that can be required for searches are not placed inside the main _wpsc_product_metadata. If you are creating a new product_meta that does not necessarily need to be used for searches, place them into the _wpsc_product_metadata instead of into an entirely new product meta.

You can retrieve meta data through either get_post_meta; or get_product_meta;

examples: Say I have a product with an ID of 83 and I want to retrieve the price:

For get_post_meta;

$price = get_post_meta(83, '_wpsc_price' , true);

For get_product_meta;

$price = get_product_meta(83, 'price', true);

Meta Key Description
_wpsc_price Product Price
_wpsc_special_price Product Sales Price
_wpsc_sku Product SKU
_wpsc_stock empty if product does not use stock control, or stock quantity in not empty (so if it is 0 it means there is no stock left!)
_wpsc_currency Serialized array of additional currencies and prices.
_wpsc_is_donation Boolean Value, 0 if product is a standard product, 1 if the product is a donation.
_wpsc_product_metadata Serialized Product Meta (used for data that does not get searched) see Table 3

_wpsc_product_metadata

This array can be retrieved using the same functions as the above product meta using get_post_meta and get_product_meta

Key Description
weight Numeric weight amount
weight_unit Weight Unit (pound, kilograms)
dimensions Array of height, height_unit, width,width_unit, length, and length_unit
shipping Per Product Shipping Amounts for Local and international
external_link Product external link – used for redirecting users to different shop
external_link_text Product external text – Text to replace Add to Cart for external products
external_link_target Product external target – whether link should open in a new window, or on the same tab
merchant_notes Notes for shop owners about the selected product
engraved whether the product accepts personalized user inputted text.
can_have_uploaded_image whether the product accepts personalized user images
enable_comments Whether intenseDebate commenting is enabled for this product
unpublish_when_none_left Checks whether or not to send notification email to store owner when stock runs out
no_shipping Checks whether this product should disregard shipping
quantity_limited Checks whether this product has limited quantity (__deprecated__)
special Checks whether this product is marked as special (__deprecated__)
display_weight_as Chosen display of weight in wp-admin
table_rate_price A multiple array for quantity based pricing per product
google_prohibited Set for products that are prohibited for sale on google

3 Responses to Product Data Structure Explained

  1. Ignatius Vermaak October 31, 2011 at 3:53 pm #

    The tables in this post may need styling, theme does not interpret well…

  2. Ejub December 8, 2011 at 11:59 am #

    Hi!

    Is there a way to get variation price? I have tried _wpsc_price, but it only gets prices for products that doesn’t have variations.

  3. Mychelle December 8, 2011 at 8:36 pm #

    Hi Ejub,

    Im going to move this comment to the questions section but I will answer it for you here.

    The post meta _wpsc_price will return the price for that post – the product is the parent post all the variations of the product are child posts and will have their own ID’s so you can use get_post_meta and _wpsc_price however you will need to know the ID of the variation post to do that.

    You can get the price out with on of the price functions from wpsc – most of them should be in the product-template.php file

    wpsc_calculate_price( $product_id, $variations = false, $special = true ) (about line 437 product-template.php) will calculate the price.

    Thanks
    Michelle

Leave a Reply