More crud updates
This commit is contained in:
parent
190cd0bf86
commit
3f4ffe8a49
|
@ -651,7 +651,7 @@ class WC_Admin_Post_Types {
|
|||
$item_meta_html = $item_meta->display( true, true );
|
||||
?>
|
||||
<tr class="<?php echo apply_filters( 'woocommerce_admin_order_item_class', '', $item, $the_order ); ?>">
|
||||
<td class="qty"><?php echo absint( $item['qty'] ); ?></td>
|
||||
<td class="qty"><?php echo esc_html( $item->get_quantity() ); ?></td>
|
||||
<td class="name">
|
||||
<?php if ( $product ) : ?>
|
||||
<?php echo ( wc_product_sku_enabled() && $product->get_sku() ) ? $product->get_sku() . ' - ' : ''; ?><a href="<?php echo get_edit_post_link( $product->id ); ?>" title="<?php echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ); ?>"><?php echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ); ?></a>
|
||||
|
|
|
@ -130,30 +130,14 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
|
|||
|
||||
// Add line items.
|
||||
foreach ( $refund->get_items() as $item_id => $item ) {
|
||||
$product = $refund->get_product_from_item( $item );
|
||||
$product_id = 0;
|
||||
$variation_id = 0;
|
||||
$product_sku = null;
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
// Check if the product exists.
|
||||
if ( is_object( $product ) ) {
|
||||
$product_id = $product->id;
|
||||
$variation_id = $product->variation_id;
|
||||
$product_sku = $product->get_sku();
|
||||
}
|
||||
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
|
||||
$item_meta = array();
|
||||
|
||||
$hideprefix = 'true' === $request['all_item_meta'] ? null : '_';
|
||||
|
||||
foreach ( $meta->get_formatted( $hideprefix ) as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $formatted_meta['key'],
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$line_item = array(
|
||||
|
@ -162,13 +146,13 @@ class WC_REST_Order_Refunds_Controller extends WC_REST_Posts_Controller {
|
|||
'sku' => $product_sku,
|
||||
'product_id' => (int) $product_id,
|
||||
'variation_id' => (int) $variation_id,
|
||||
'quantity' => wc_stock_amount( $item['qty'] ),
|
||||
'tax_class' => ! empty( $item['tax_class'] ) ? $item['tax_class'] : '',
|
||||
'quantity' => $item->get_quantity(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'price' => wc_format_decimal( $refund->get_item_total( $item, false, false ), $dp ),
|
||||
'subtotal' => wc_format_decimal( $refund->get_line_subtotal( $item, false, false ), $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ),
|
||||
'total' => wc_format_decimal( $refund->get_line_total( $item, false, false ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $item['line_tax'], $dp ),
|
||||
'total_tax' => wc_format_decimal( $item->get_total_tax(), $dp ),
|
||||
'taxes' => array(),
|
||||
'meta' => $item_meta,
|
||||
);
|
||||
|
|
|
@ -116,11 +116,11 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
$order_data = array(
|
||||
'id' => $order->get_id(),
|
||||
'order_number' => $order->get_order_number(),
|
||||
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
|
||||
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ),
|
||||
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ),
|
||||
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->order_currency,
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), 2 ),
|
||||
'subtotal' => wc_format_decimal( $this->get_order_subtotal( $order ), 2 ),
|
||||
'total_line_items_quantity' => $order->get_item_count(),
|
||||
|
@ -175,37 +175,33 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add line items
|
||||
foreach( $order->get_items() as $item_id => $item ) {
|
||||
|
||||
$product = $order->get_product_from_item( $item );
|
||||
|
||||
$product = $item->get_product();
|
||||
$order_data['line_items'][] = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ),
|
||||
'quantity' => (int) $item['qty'],
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'quantity' => $item->get_quantity(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id,
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
);
|
||||
}
|
||||
|
||||
// add shipping
|
||||
foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
|
||||
|
||||
$order_data['shipping_lines'][] = array(
|
||||
'id' => $shipping_item_id,
|
||||
'method_id' => $shipping_item['method_id'],
|
||||
'method_title' => $shipping_item['name'],
|
||||
'total' => wc_format_decimal( $shipping_item['cost'], 2 ),
|
||||
'method_id' => $shipping_item->get_method_id(),
|
||||
'method_title' => $shipping_item->get_name(),
|
||||
'total' => wc_format_decimal( $shipping_item->get_total(), 2 ),
|
||||
);
|
||||
}
|
||||
|
||||
// add taxes
|
||||
foreach ( $order->get_tax_totals() as $tax_code => $tax ) {
|
||||
|
||||
$order_data['tax_lines'][] = array(
|
||||
'code' => $tax_code,
|
||||
'title' => $tax->label,
|
||||
|
@ -216,11 +212,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add fees
|
||||
foreach ( $order->get_fees() as $fee_item_id => $fee_item ) {
|
||||
|
||||
$order_data['fee_lines'][] = array(
|
||||
'id' => $fee_item_id,
|
||||
'title' => $fee_item['name'],
|
||||
'tax_class' => ( ! empty( $fee_item['tax_class'] ) ) ? $fee_item['tax_class'] : null,
|
||||
'title' => $fee_item->get_name(),
|
||||
'tax_class' => $fee_item->get_tax_class(),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $fee_item ), 2 ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), 2 ),
|
||||
);
|
||||
|
@ -228,11 +223,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add coupons
|
||||
foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) {
|
||||
|
||||
$order_data['coupon_lines'][] = array(
|
||||
'id' => $coupon_item_id,
|
||||
'code' => $coupon_item['name'],
|
||||
'amount' => wc_format_decimal( $coupon_item['discount_amount'], 2 ),
|
||||
'code' => $coupon_item->get_code(),
|
||||
'amount' => wc_format_decimal( $coupon_item->get_discount_total(), 2 ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -385,13 +379,11 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
* @return float
|
||||
*/
|
||||
private function get_order_subtotal( $order ) {
|
||||
|
||||
$subtotal = 0;
|
||||
|
||||
// subtotal
|
||||
foreach ( $order->get_items() as $item ) {
|
||||
|
||||
$subtotal += ( isset( $item['line_subtotal'] ) ) ? $item['line_subtotal'] : 0;
|
||||
$subtotal += $item->get_subtotal();
|
||||
}
|
||||
|
||||
return $subtotal;
|
||||
|
|
|
@ -156,9 +156,9 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
$order_data = array(
|
||||
'id' => $order->get_id(),
|
||||
'order_number' => $order->get_order_number(),
|
||||
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
|
||||
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ),
|
||||
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ),
|
||||
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), $dp ),
|
||||
|
@ -213,61 +213,44 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add line items
|
||||
foreach ( $order->get_items() as $item_id => $item ) {
|
||||
|
||||
$product = $order->get_product_from_item( $item );
|
||||
$product_id = null;
|
||||
$product_sku = null;
|
||||
|
||||
// Check if the product exists.
|
||||
if ( is_object( $product ) ) {
|
||||
$product_id = ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id;
|
||||
$product_sku = $product->get_sku();
|
||||
}
|
||||
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
|
||||
$item_meta = array();
|
||||
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
foreach ( $meta->get_formatted( $hideprefix ) as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $formatted_meta['key'],
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$order_data['line_items'][] = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $item['line_tax'], $dp ),
|
||||
'total_tax' => wc_format_decimal( $item->get_total_tax(), $dp ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ),
|
||||
'quantity' => wc_stock_amount( $item['qty'] ),
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'quantity' => $item->get_qty(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => $product_id,
|
||||
'sku' => $product_sku,
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
'meta' => $item_meta,
|
||||
);
|
||||
}
|
||||
|
||||
// add shipping
|
||||
foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
|
||||
|
||||
$order_data['shipping_lines'][] = array(
|
||||
'id' => $shipping_item_id,
|
||||
'method_id' => $shipping_item['method_id'],
|
||||
'method_title' => $shipping_item['name'],
|
||||
'total' => wc_format_decimal( $shipping_item['cost'], $dp ),
|
||||
'method_id' => $shipping_item->get_method_id(),
|
||||
'method_title' => $shipping_item->get_name(),
|
||||
'total' => wc_format_decimal( $shipping_item->get_total(), $dp ),
|
||||
);
|
||||
}
|
||||
|
||||
// add taxes
|
||||
foreach ( $order->get_tax_totals() as $tax_code => $tax ) {
|
||||
|
||||
$order_data['tax_lines'][] = array(
|
||||
'id' => $tax->id,
|
||||
'rate_id' => $tax->rate_id,
|
||||
|
@ -280,11 +263,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add fees
|
||||
foreach ( $order->get_fees() as $fee_item_id => $fee_item ) {
|
||||
|
||||
$order_data['fee_lines'][] = array(
|
||||
'id' => $fee_item_id,
|
||||
'title' => $fee_item['name'],
|
||||
'tax_class' => ( ! empty( $fee_item['tax_class'] ) ) ? $fee_item['tax_class'] : null,
|
||||
'title' => $fee_item->get_name(),
|
||||
'tax_class' => $fee_item->get_tax_class(),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $fee_item ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), $dp ),
|
||||
);
|
||||
|
@ -292,11 +274,10 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// add coupons
|
||||
foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) {
|
||||
|
||||
$order_data['coupon_lines'][] = array(
|
||||
'id' => $coupon_item_id,
|
||||
'code' => $coupon_item['name'],
|
||||
'amount' => wc_format_decimal( $coupon_item['discount_amount'], $dp ),
|
||||
'code' => $coupon_item->get_code(),
|
||||
'amount' => wc_format_decimal( $coupon_item->get_discount_total(), $dp ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1515,39 +1496,36 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// Add line items
|
||||
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
$product = $order->get_product_from_item( $item );
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
$item_meta = array();
|
||||
|
||||
foreach ( $meta->get_formatted() as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $meta_key,
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$line_items[] = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], 2 ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), 2 ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ),
|
||||
'quantity' => (int) $item['qty'],
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'quantity' => $item->get_quantity(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id,
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
'meta' => $item_meta,
|
||||
'refunded_item_id' => (int) $item['refunded_item_id'],
|
||||
'refunded_item_id' => (int) $item->get_meta( 'refunded_item_id' ),
|
||||
);
|
||||
}
|
||||
|
||||
$order_refund = array(
|
||||
'id' => $refund->id,
|
||||
'created_at' => $this->server->format_datetime( $refund->date ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $refund->get_date_created() ) ) ),
|
||||
'amount' => wc_format_decimal( $refund->get_refund_amount(), 2 ),
|
||||
'reason' => $refund->get_refund_reason(),
|
||||
'line_items' => $line_items
|
||||
|
|
|
@ -162,9 +162,9 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
'id' => $order->get_id(),
|
||||
'order_number' => $order->get_order_number(),
|
||||
'order_key' => $order->get_order_key(),
|
||||
'created_at' => $this->server->format_datetime( $order_post->post_date_gmt ),
|
||||
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ),
|
||||
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ),
|
||||
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), $dp ),
|
||||
|
@ -215,47 +215,32 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
'tax_lines' => array(),
|
||||
'fee_lines' => array(),
|
||||
'coupon_lines' => array(),
|
||||
'is_vat_exempt' => $order->is_vat_exempt === 'yes' ? true : false,
|
||||
);
|
||||
|
||||
// Add line items.
|
||||
foreach ( $order->get_items() as $item_id => $item ) {
|
||||
$product = $order->get_product_from_item( $item );
|
||||
$product_id = null;
|
||||
$product_sku = null;
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
// Check if the product exists.
|
||||
if ( is_object( $product ) ) {
|
||||
$product_id = ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id;
|
||||
$product_sku = $product->get_sku();
|
||||
}
|
||||
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
|
||||
$item_meta = array();
|
||||
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_';
|
||||
|
||||
foreach ( $meta->get_formatted( $hideprefix ) as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $formatted_meta['key'],
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$line_item = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $item['line_tax'], $dp ),
|
||||
'total_tax' => wc_format_decimal( $item->get_total_tax(), $dp ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ),
|
||||
'quantity' => wc_stock_amount( $item['qty'] ),
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'quantity' => $item->get_qty(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => $product_id,
|
||||
'sku' => $product_sku,
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
'meta' => $item_meta,
|
||||
);
|
||||
|
||||
|
@ -274,9 +259,9 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
|
||||
$order_data['shipping_lines'][] = array(
|
||||
'id' => $shipping_item_id,
|
||||
'method_id' => $shipping_item['method_id'],
|
||||
'method_title' => $shipping_item['name'],
|
||||
'total' => wc_format_decimal( $shipping_item['cost'], $dp ),
|
||||
'method_id' => $shipping_item->get_method_id(),
|
||||
'method_title' => $shipping_item->get_name(),
|
||||
'total' => wc_format_decimal( $shipping_item->get_total(), $dp ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -306,8 +291,8 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
foreach ( $order->get_fees() as $fee_item_id => $fee_item ) {
|
||||
$order_data['fee_lines'][] = array(
|
||||
'id' => $fee_item_id,
|
||||
'title' => $fee_item['name'],
|
||||
'tax_class' => ( ! empty( $fee_item['tax_class'] ) ) ? $fee_item['tax_class'] : null,
|
||||
'title' => $fee_item->get_name(),
|
||||
'tax_class' => $fee_item->get_tax_class(),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $fee_item ), $dp ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), $dp ),
|
||||
);
|
||||
|
@ -317,12 +302,12 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) {
|
||||
$coupon_line = array(
|
||||
'id' => $coupon_item_id,
|
||||
'code' => $coupon_item['name'],
|
||||
'amount' => wc_format_decimal( $coupon_item['discount_amount'], $dp ),
|
||||
'code' => $coupon_item->get_code(),
|
||||
'amount' => wc_format_decimal( $coupon_item->get_discount_total(), $dp ),
|
||||
);
|
||||
|
||||
if ( in_array( 'coupons', $expand ) ) {
|
||||
$_coupon_data = WC()->api->WC_API_Coupons->get_coupon_by_code( $coupon_item['name'] );
|
||||
$_coupon_data = WC()->api->WC_API_Coupons->get_coupon_by_code( $coupon_item->get_code() );
|
||||
|
||||
if ( ! is_wp_error( $_coupon_data ) && isset( $_coupon_data['coupon'] ) ) {
|
||||
$coupon_line['coupon_data'] = $_coupon_data['coupon'];
|
||||
|
@ -1560,39 +1545,36 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
// Add line items
|
||||
foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) {
|
||||
$product = $item->get_product();
|
||||
$hideprefix = ( isset( $filter['all_item_meta'] ) && $filter['all_item_meta'] === 'true' ) ? null : '_';
|
||||
$item_meta = $item->get_formatted_meta_data( $hideprefix );
|
||||
|
||||
$product = $order->get_product_from_item( $item );
|
||||
$meta = new WC_Order_Item_Meta( $item, $product );
|
||||
$item_meta = array();
|
||||
|
||||
foreach ( $meta->get_formatted() as $meta_key => $formatted_meta ) {
|
||||
$item_meta[] = array(
|
||||
'key' => $meta_key,
|
||||
'label' => $formatted_meta['label'],
|
||||
'value' => $formatted_meta['value'],
|
||||
);
|
||||
foreach ( $item_meta as $key => $values ) {
|
||||
$item_meta[ $key ]->label = $values->display_key;
|
||||
unset( $item_meta[ $key ]->display_key );
|
||||
unset( $item_meta[ $key ]->display_value );
|
||||
}
|
||||
|
||||
$line_items[] = array(
|
||||
'id' => $item_id,
|
||||
'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ),
|
||||
'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], 2 ),
|
||||
'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), 2 ),
|
||||
'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ),
|
||||
'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ),
|
||||
'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ),
|
||||
'quantity' => (int) $item['qty'],
|
||||
'tax_class' => ( ! empty( $item['tax_class'] ) ) ? $item['tax_class'] : null,
|
||||
'quantity' => $item->get_quantity(),
|
||||
'tax_class' => $item->get_tax_class(),
|
||||
'name' => $item->get_name(),
|
||||
'product_id' => ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id,
|
||||
'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(),
|
||||
'sku' => is_object( $product ) ? $product->get_sku() : null,
|
||||
'meta' => $item_meta,
|
||||
'refunded_item_id' => (int) $item['refunded_item_id'],
|
||||
'refunded_item_id' => (int) $item->get_meta( 'refunded_item_id' ),
|
||||
);
|
||||
}
|
||||
|
||||
$order_refund = array(
|
||||
'id' => $refund->id,
|
||||
'created_at' => $this->server->format_datetime( $refund->date ),
|
||||
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $refund->get_date_created() ) ) ),
|
||||
'amount' => wc_format_decimal( $refund->get_refund_amount(), 2 ),
|
||||
'reason' => $refund->get_refund_reason(),
|
||||
'line_items' => $line_items
|
||||
|
|
|
@ -289,7 +289,7 @@ class WC_Emails {
|
|||
continue;
|
||||
}
|
||||
|
||||
$product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
|
||||
$product = apply_filters( 'woocommerce_order_item_product', $item->get_product(), $item );
|
||||
$product_exists = is_object( $product );
|
||||
$is_visible = $product_exists && $product->is_visible();
|
||||
|
||||
|
@ -321,7 +321,7 @@ class WC_Emails {
|
|||
'priceCurrency' => $order->get_currency(),
|
||||
'eligibleQuantity' => (object) array(
|
||||
'@type' => 'QuantitativeValue',
|
||||
'value' => apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item )
|
||||
'value' => apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item )
|
||||
),
|
||||
'url' => get_home_url(),
|
||||
);
|
||||
|
|
|
@ -615,17 +615,17 @@ class WC_Form_Handler {
|
|||
// Copy products from the order to the cart
|
||||
foreach ( $order->get_items() as $item ) {
|
||||
// Load all product info including variation data
|
||||
$product_id = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $item['product_id'] );
|
||||
$quantity = (int) $item['qty'];
|
||||
$variation_id = (int) $item['variation_id'];
|
||||
$product_id = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $item->get_product_id() );
|
||||
$quantity = $item->get_quantity();
|
||||
$variation_id = $item->get_variation_id();
|
||||
$variations = array();
|
||||
$cart_item_data = apply_filters( 'woocommerce_order_again_cart_item_data', array(), $item, $order );
|
||||
|
||||
foreach ( $item['item_meta'] as $meta_name => $meta_value ) {
|
||||
if ( taxonomy_is_product_attribute( $meta_name ) ) {
|
||||
$variations[ $meta_name ] = $meta_value[0];
|
||||
} elseif ( meta_is_product_attribute( $meta_name, $meta_value[0], $product_id ) ) {
|
||||
$variations[ $meta_name ] = $meta_value[0];
|
||||
foreach ( $item->get_meta_data() as $meta ) {
|
||||
if ( taxonomy_is_product_attribute( $meta->meta_key ) ) {
|
||||
$variations[ $meta->meta_key ] = $meta->meta_value;
|
||||
} elseif ( meta_is_product_attribute( $meta->meta_key, $meta->meta_value, $product_id ) ) {
|
||||
$variations[ $meta->meta_key ] = $meta->meta_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order );
|
||||
?>
|
||||
</td>
|
||||
<td class="product-quantity"><?php echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', esc_html( $item['qty'] ) ) . '</strong>', $item ); ?></td>
|
||||
<td class="product-quantity"><?php echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', esc_html( $item->get_quantity() ) ) . '</strong>', $item ); ?></td>
|
||||
<td class="product-subtotal"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
@ -53,7 +53,7 @@ foreach ( $items as $item_id => $item ) :
|
|||
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
|
||||
|
||||
?></td>
|
||||
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item ); ?></td>
|
||||
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); ?></td>
|
||||
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -27,7 +27,7 @@ foreach ( $items as $item_id => $item ) :
|
|||
if ( $show_sku && $product->get_sku() ) {
|
||||
echo ' (#' . $product->get_sku() . ')';
|
||||
}
|
||||
echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item );
|
||||
echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item );
|
||||
echo ' = ' . $order->get_formatted_line_subtotal( $item ) . "\n";
|
||||
// allow other plugins to add additional product information here
|
||||
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );
|
||||
|
|
|
@ -31,7 +31,7 @@ if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
|
|||
$product_permalink = apply_filters( 'woocommerce_order_item_permalink', $is_visible ? $product->get_permalink( $item ) : '', $item, $order );
|
||||
|
||||
echo apply_filters( 'woocommerce_order_item_name', $product_permalink ? sprintf( '<a href="%s">%s</a>', $product_permalink, $item->get_name() ) : $item->get_name(), $item, $is_visible );
|
||||
echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', $item['qty'] ) . '</strong>', $item );
|
||||
echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', $item->get_quantity() ) . '</strong>', $item );
|
||||
|
||||
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );
|
||||
|
||||
|
|
Loading…
Reference in New Issue