Fix item data
This commit is contained in:
parent
0b9a5998cc
commit
3755049d86
|
@ -231,7 +231,7 @@ class WC_Checkout {
|
|||
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
|
||||
$product = $values['data'];
|
||||
$item = new WC_Order_Item_Product( array(
|
||||
'qty' => $values['quantity'],
|
||||
'quantity' => $values['quantity'],
|
||||
'name' => $product ? $product->get_title() : '',
|
||||
'tax_class' => $product ? $product->get_tax_class() : '',
|
||||
'product_id' => $product ? $product->get_id() : '',
|
||||
|
|
|
@ -108,6 +108,14 @@ class WC_Order_Item_Fee extends WC_Order_Item {
|
|||
return $this->get_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal meta keys we don't want exposed as part of meta_data.
|
||||
* @return array()
|
||||
*/
|
||||
protected function get_internal_meta_keys() {
|
||||
return array( '_tax_class', '_tax_status', '_line_subtotal', '_line_subtotal_tax', '_line_total', '_line_tax', '_line_tax_data' );
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setters
|
||||
|
|
|
@ -222,25 +222,6 @@ class WC_Order_Item_Product extends WC_Order_Item {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all class data in array format.
|
||||
* @since 2.7.0
|
||||
* @return array
|
||||
*/
|
||||
public function get_data() {
|
||||
return array_merge(
|
||||
$this->_data,
|
||||
array(
|
||||
// Return SKU for convenience
|
||||
'sku' => $this->get_product() ? $this->get_product()->get_sku(): null,
|
||||
|
||||
// Return item price for convenience
|
||||
'price' => $this->get_total() / max( 1, $this->get_quantity() ),
|
||||
'meta_data' => $this->get_meta_data(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setters
|
||||
|
|
Loading…
Reference in New Issue