Instance ID methods
This commit is contained in:
parent
ad18445eeb
commit
054e68a047
|
@ -25,6 +25,7 @@ class WC_Order_Item_Shipping extends WC_Order_Item {
|
|||
protected $extra_data = array(
|
||||
'method_title' => '',
|
||||
'method_id' => '',
|
||||
'instance_id' => '',
|
||||
'total' => 0,
|
||||
'total_tax' => 0,
|
||||
'taxes' => array(
|
||||
|
@ -93,6 +94,16 @@ class WC_Order_Item_Shipping extends WC_Order_Item {
|
|||
$this->set_prop( 'method_id', wc_clean( $value ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shipping instance id.
|
||||
*
|
||||
* @param string $value Value to set.
|
||||
* @throws WC_Data_Exception May throw exception if data is invalid.
|
||||
*/
|
||||
public function set_instance_id( $value ) {
|
||||
$this->set_prop( 'instance_id', wc_clean( $value ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set total.
|
||||
*
|
||||
|
@ -142,10 +153,11 @@ class WC_Order_Item_Shipping extends WC_Order_Item {
|
|||
* @param WC_Shipping_Rate $shipping_rate Shipping rate to set.
|
||||
*/
|
||||
public function set_shipping_rate( $shipping_rate ) {
|
||||
$this->set_method_title( $shipping_rate->label );
|
||||
$this->set_method_id( $shipping_rate->id );
|
||||
$this->set_total( $shipping_rate->cost );
|
||||
$this->set_taxes( $shipping_rate->taxes );
|
||||
$this->set_method_title( $shipping_rate->get_label() );
|
||||
$this->set_method_id( $shipping_rate->get_method_id() );
|
||||
$this->set_instance_id( $shipping_rate->get_instance_id() );
|
||||
$this->set_total( $shipping_rate->get_cost() );
|
||||
$this->set_taxes( $shipping_rate->get_taxes() );
|
||||
$this->set_meta_data( $shipping_rate->get_meta_data() );
|
||||
}
|
||||
|
||||
|
@ -199,6 +211,16 @@ class WC_Order_Item_Shipping extends WC_Order_Item {
|
|||
return $this->get_prop( 'method_id', $context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get instance ID.
|
||||
*
|
||||
* @param string $context View or edit context.
|
||||
* @return string
|
||||
*/
|
||||
public function get_instance_id( $context = 'view' ) {
|
||||
return $this->get_prop( 'instance_id', $context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total cost.
|
||||
*
|
||||
|
|
|
@ -21,7 +21,7 @@ class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data
|
|||
* @since 3.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $internal_meta_keys = array( 'method_id', 'cost', 'total_tax', 'taxes' );
|
||||
protected $internal_meta_keys = array( 'method_id', 'instance_id', 'cost', 'total_tax', 'taxes' );
|
||||
|
||||
/**
|
||||
* Read/populate data properties specific to this order item.
|
||||
|
@ -34,6 +34,7 @@ class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data
|
|||
$id = $item->get_id();
|
||||
$item->set_props( array(
|
||||
'method_id' => get_metadata( 'order_item', $id, 'method_id', true ),
|
||||
'instance_id' => get_metadata( 'order_item', $id, 'instance_id', true ),
|
||||
'total' => get_metadata( 'order_item', $id, 'cost', true ),
|
||||
'taxes' => get_metadata( 'order_item', $id, 'taxes', true ),
|
||||
) );
|
||||
|
@ -51,6 +52,7 @@ class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data
|
|||
$id = $item->get_id();
|
||||
$save_values = array(
|
||||
'method_id' => $item->get_method_id( 'edit' ),
|
||||
'instance_id' => $item->get_instance_id( 'edit' ),
|
||||
'cost' => $item->get_total( 'edit' ),
|
||||
'total_tax' => $item->get_total_tax( 'edit' ),
|
||||
'taxes' => $item->get_taxes( 'edit' ),
|
||||
|
|
Loading…
Reference in New Issue