From c64c726da9d0ce3761b7457d5e389c72836015c3 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 15 Jan 2018 14:49:55 +0000 Subject: [PATCH] Set instance id --- includes/class-wc-checkout.php | 3 ++- .../class-wc-order-item-shipping-data-store.php | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index a39595b95c0..4b12acbf0c3 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -439,7 +439,8 @@ class WC_Checkout { $item->legacy_package_key = $package_key; // @deprecated For legacy actions. $item->set_props( array( 'method_title' => $shipping_rate->label, - 'method_id' => $shipping_rate->id, + 'method_id' => $shipping_rate->method_id, + 'instance_id' => $shipping_rate->instance_id, 'total' => wc_format_decimal( $shipping_rate->cost ), 'taxes' => array( 'total' => $shipping_rate->taxes, diff --git a/includes/data-stores/class-wc-order-item-shipping-data-store.php b/includes/data-stores/class-wc-order-item-shipping-data-store.php index 76708a1adfe..a0cf9d1f6b3 100644 --- a/includes/data-stores/class-wc-order-item-shipping-data-store.php +++ b/includes/data-stores/class-wc-order-item-shipping-data-store.php @@ -38,6 +38,14 @@ class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data 'total' => get_metadata( 'order_item', $id, 'cost', true ), 'taxes' => get_metadata( 'order_item', $id, 'taxes', true ), ) ); + + // BW compat. + if ( '' === $item->get_instance_id() && strstr( $item->get_method_id(), ':' ) ) { + $legacy_method_id = explode( ':', $item->get_method_id() ); + $item->set_method_id( $legacy_method_id[0] ); + $item->set_instance_id( $legacy_method_id[1] ); + } + $item->set_object_read( true ); }