Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
WooCommerce prior to 3.3.x lacked the woocommerce_pre_customer_bought…
Browse files Browse the repository at this point in the history
…_product filter, and instead had a hard-coded SQL query against the postmeta table within wc_customer_bought_product().

As a result, versions prior to 3.3.0 need to still store the billing email and customer ID in the post meta table.
  • Loading branch information
stevegrunwell committed Jan 22, 2018
1 parent 5bf070a commit 7c877ca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions includes/class-wc-order-data-store-custom-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ protected function update_post_meta( &$order ) {
if ( $this->creating ) {
$wpdb->insert( $table, $order_data ); // WPCS: DB call OK.

/*
* WooCommerce prior to 3.3 lacks some necessary filters to entirely move order details
* into a custom database table. If the site is running WooCommerce < 3.3.0, store the
* billing email and customer ID in the post meta table as well, for backwards-compatibility.
*/
if ( version_compare( WC()->version, '3.3.0', '<' ) ) {
update_post_meta( $order->get_id(), '_billing_email', $order->get_billing_email() );
update_post_meta( $order->get_id(), '_customer_user', $order->get_customer_id() );
}

$this->creating = false;

} else {
Expand Down

0 comments on commit 7c877ca

Please sign in to comment.