Set instance id

This commit is contained in:
Mike Jolley 2018-01-15 14:49:55 +00:00
parent 054e68a047
commit c64c726da9
2 changed files with 10 additions and 1 deletions

View File

@ -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,

View File

@ -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 );
}