Ubercart to WooCommerce migration notes
I've now had several Ubercart to WooCommerce migration projects so it's time to start documenting the process. As with all my documentation, I'll start off this post as rough notes and improve it over time. If this topic interests you, be sure to check back every so often to see the updates. Please keep in mind that I'm writing this from the standpoint of Drupal to WordPress migrations. In other words, the main objective for the projects were to migrate a Drupal site to WordPress but there was also an Ubercart to WooCommerce component.
Key differences between Ubercart and WooCommerce
There's one key difference between Ubercart and WooCommerce from an architectural point-of-view. Ubercart stores products as nodes and orders are stored in a separate table uc_orders
. Orders have an order_id
and there's no direct relationship in uc_orders
to a product's node ID. Instead, the uc_order_products
table stores the relationship between orders and products purchased with the order.
WooCommerce stores both products and order transactions as posts in the wp_posts
table. The post ID is used as the order's transaction ID. Products purchased with the order are stored in wp_woocommerce_order_items
, with additional product metadata being strored in wp_woocommerce_order_itemmeta
.
Obviously there are many more differences but this information architecture is the key thing to keep in mind when migrating the data.
Database tables
Here are the main database tables that you'll need to migrate Ubercart content to WooCommerce.
Ubercart
Table | Description |
---|---|
node | Products are stored in the Drupal node table. |
uc_orders | Stores the individual Ubercart transactions. |
uc_order_products | Stores the products purchased during the transaction. |
uc_order_line_items | Line items for an order. This includes tax and shipping fees applied to an order. |
uc_order_comments | Customer or administrator notes associated with each order. |
uc_order_log | Comments about the order status by the shop administrator. |
uc_zone | Country zone codes for customer billing and delivery. |
uc_countries | Countries and zone codes in ISO 3166-1 Alpha-2 and Alpha-3 code format for customer billing and delivery. |
WooCommerce
Table | Description |
---|---|
wp_posts | Stores products and transactions. |
wp_postmeta | Transaction meta data. |
wp_woocommerce_order_items | Stores the line items for a transaction in the wp_posts table. |
wp_woocommerce_order_itemmeta | Stores the meta data for line items, such as quantity, price and tax information. |
wp_comments | Order notes. |
Order transactions and products are saved as WordPress posts. One or many order item meta entries can be linked to an order.
WooCommerce shop orders
A WooCommerce transaction is saved as a shop order in thewp_posts
table.
post_status = wc_completed
post_type = shop_order
WooCommerce subscriptions
WooCommerce subscriptions are saved in wp_posts
. A subscription is made up of two entries:
- The transaction order for a subscription.
- The subscription itself.
Subscription transaction order
post_status = wc_completed
post_parent = 0
post_type = shop_order
The subscription
post_status = wc_active
post_parent = [post ID to the transaction shop order]
post_type = shop_subscription
Products
Purchased products are saved as line items in thewp_woocommerce_order_items
and wp_woocommerce_order_itemmeta
tables.
A WooCommerce product can be of any post type. The product post is linked to a shop order transaction by setting the product's post ID in the wp_woocommerce_order_itemmeta
table:
meta_key = _product_id
meta_value = [post ID to the product]
Notes
My apologies if you've come here looking for more complete documentation. I've been planning to write this post for more than two years but have been putting it off due to my work schedule. I figure the best way to finally get it done is to just make a start and update it as time allows.
The most-viewed articles here started off as notes for my own use and evolved over time. This one is no different. Hopefully it will still be of use to some people in its draft state.
In the meantime, you might want to take a look at these other articles and plugins.