2012-11-27 16:22:47 +00:00
|
|
|
<?php
|
2015-01-14 11:46:03 +00:00
|
|
|
/**
|
|
|
|
* Shows an order item
|
|
|
|
*
|
2020-08-05 16:36:24 +00:00
|
|
|
* @package WooCommerce\Admin
|
2015-01-14 11:46:03 +00:00
|
|
|
* @var object $item The item being displayed
|
|
|
|
* @var int $item_id The id of the item being displayed
|
|
|
|
*/
|
2019-03-06 16:17:33 +00:00
|
|
|
|
2019-03-06 16:39:28 +00:00
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
|
2016-08-19 14:08:00 +00:00
|
|
|
$product = $item->get_product();
|
2016-10-13 14:18:44 +00:00
|
|
|
$product_link = $product ? admin_url( 'post.php?post=' . $item->get_product_id() . '&action=edit' ) : '';
|
2016-08-19 14:08:00 +00:00
|
|
|
$thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : '';
|
2017-11-21 16:22:43 +00:00
|
|
|
$row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empty( $class ) ? $class : '', $item, $order );
|
2016-03-21 14:58:14 +00:00
|
|
|
?>
|
2017-11-21 16:22:43 +00:00
|
|
|
<tr class="item <?php echo esc_attr( $row_class ); ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>">
|
2016-03-21 14:58:14 +00:00
|
|
|
<td class="thumb">
|
2016-08-19 14:08:00 +00:00
|
|
|
<?php echo '<div class="wc-order-item-thumbnail">' . wp_kses_post( $thumbnail ) . '</div>'; ?>
|
2012-10-19 14:05:23 +00:00
|
|
|
</td>
|
2016-08-19 14:08:00 +00:00
|
|
|
<td class="name" data-sort-value="<?php echo esc_attr( $item->get_name() ); ?>">
|
2016-03-21 14:58:14 +00:00
|
|
|
<?php
|
2018-11-15 19:42:22 +00:00
|
|
|
echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . wp_kses_post( $item->get_name() ) . '</a>' : '<div class="wc-order-item-name">' . wp_kses_post( $item->get_name() ) . '</div>';
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
if ( $product && $product->get_sku() ) {
|
|
|
|
echo '<div class="wc-order-item-sku"><strong>' . esc_html__( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>';
|
|
|
|
}
|
2016-03-22 17:13:39 +00:00
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
if ( $item->get_variation_id() ) {
|
|
|
|
echo '<div class="wc-order-item-variation"><strong>' . esc_html__( 'Variation ID:', 'woocommerce' ) . '</strong> ';
|
|
|
|
if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) {
|
|
|
|
echo esc_html( $item->get_variation_id() );
|
|
|
|
} else {
|
|
|
|
/* translators: %s: variation id */
|
2019-03-06 16:17:33 +00:00
|
|
|
printf( esc_html__( '%s (No longer exists)', 'woocommerce' ), esc_html( $item->get_variation_id() ) );
|
2016-03-22 17:13:39 +00:00
|
|
|
}
|
2018-03-05 18:59:17 +00:00
|
|
|
echo '</div>';
|
|
|
|
}
|
2016-03-22 17:13:39 +00:00
|
|
|
?>
|
2012-11-09 21:15:15 +00:00
|
|
|
<input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" />
|
2016-08-19 14:08:00 +00:00
|
|
|
<input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" />
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2017-11-21 17:50:30 +00:00
|
|
|
<?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $product ); ?>
|
2020-08-26 21:46:44 +00:00
|
|
|
<?php require __DIR__ . '/html-order-item-meta.php'; ?>
|
2017-11-21 17:50:30 +00:00
|
|
|
<?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $product ); ?>
|
2012-10-19 14:05:23 +00:00
|
|
|
</td>
|
|
|
|
|
2016-08-19 14:08:00 +00:00
|
|
|
<?php do_action( 'woocommerce_admin_order_item_values', $product, $item, absint( $item_id ) ); ?>
|
2012-10-19 14:05:23 +00:00
|
|
|
|
2014-11-26 15:37:06 +00:00
|
|
|
<td class="item_cost" width="1%" data-sort-value="<?php echo esc_attr( $order->get_item_subtotal( $item, false, true ) ); ?>">
|
2014-11-11 13:40:44 +00:00
|
|
|
<div class="view">
|
|
|
|
<?php
|
2019-12-19 16:14:03 +00:00
|
|
|
echo wc_price( $order->get_item_subtotal( $item, false, true ), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
2014-11-11 13:40:44 +00:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</td>
|
2012-10-19 14:05:23 +00:00
|
|
|
<td class="quantity" width="1%">
|
2013-08-15 15:49:09 +00:00
|
|
|
<div class="view">
|
2014-07-25 16:32:16 +00:00
|
|
|
<?php
|
2019-03-06 16:17:33 +00:00
|
|
|
echo '<small class="times">×</small> ' . esc_html( $item->get_quantity() );
|
|
|
|
|
|
|
|
$refunded_qty = $order->get_qty_refunded_for_item( $item_id );
|
2014-07-25 15:48:19 +00:00
|
|
|
|
2019-03-06 16:17:33 +00:00
|
|
|
if ( $refunded_qty ) {
|
|
|
|
echo '<small class="refunded">-' . esc_html( $refunded_qty * -1 ) . '</small>';
|
2018-03-05 18:59:17 +00:00
|
|
|
}
|
2014-07-25 15:48:19 +00:00
|
|
|
?>
|
2013-08-15 15:49:09 +00:00
|
|
|
</div>
|
2021-09-13 10:38:15 +00:00
|
|
|
<?php
|
|
|
|
$step = apply_filters( 'woocommerce_quantity_input_step', '1', $product );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter to change the product quantity stepping in the order editor of the admin area.
|
|
|
|
*
|
|
|
|
* @since 5.8.0
|
|
|
|
* @param string $step The current step amount to be used in the quantity editor.
|
|
|
|
* @param WC_Product $product The product that is being edited.
|
|
|
|
* @param string $context The context in which the quantity editor is shown, 'edit' or 'refund'.
|
|
|
|
*/
|
|
|
|
$step_edit = apply_filters( 'woocommerce_quantity_input_step_admin', $step, $product, 'edit' );
|
|
|
|
$step_refund = apply_filters( 'woocommerce_quantity_input_step_admin', $step, $product, 'refund' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter to change the product quantity minimum in the order editor of the admin area.
|
|
|
|
*
|
|
|
|
* @since 5.8.0
|
|
|
|
* @param string $step The current minimum amount to be used in the quantity editor.
|
|
|
|
* @param WC_Product $product The product that is being edited.
|
|
|
|
* @param string $context The context in which the quantity editor is shown, 'edit' or 'refund'.
|
|
|
|
*/
|
|
|
|
$min_edit = apply_filters( 'woocommerce_quantity_input_min_admin', '0', $product, 'edit' );
|
|
|
|
$min_refund = apply_filters( 'woocommerce_quantity_input_min_admin', '0', $product, 'refund' );
|
|
|
|
?>
|
2014-07-19 04:08:02 +00:00
|
|
|
<div class="edit" style="display: none;">
|
2021-09-13 10:38:15 +00:00
|
|
|
<input type="number" step="<?php echo esc_attr( $step_edit ); ?>" min="<?php echo esc_attr( $min_edit ); ?>" autocomplete="off" name="order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" value="<?php echo esc_attr( $item->get_quantity() ); ?>" data-qty="<?php echo esc_attr( $item->get_quantity() ); ?>" size="4" class="quantity" />
|
2013-08-15 15:49:09 +00:00
|
|
|
</div>
|
2014-07-24 09:56:32 +00:00
|
|
|
<div class="refund" style="display: none;">
|
2021-09-13 10:38:15 +00:00
|
|
|
<input type="number" step="<?php echo esc_attr( $step_refund ); ?>" min="<?php echo esc_attr( $min_refund ); ?>" max="<?php echo absint( $item->get_quantity() ); ?>" autocomplete="off" name="refund_order_item_qty[<?php echo absint( $item_id ); ?>]" placeholder="0" size="4" class="refund_order_item_qty" />
|
2013-08-15 15:49:09 +00:00
|
|
|
</div>
|
2012-10-19 14:05:23 +00:00
|
|
|
</td>
|
2016-08-19 14:08:00 +00:00
|
|
|
<td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( $item->get_total() ); ?>">
|
2013-08-15 15:49:09 +00:00
|
|
|
<div class="view">
|
2013-08-16 15:43:26 +00:00
|
|
|
<?php
|
2019-03-06 16:17:33 +00:00
|
|
|
echo wc_price( $item->get_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
2013-08-16 16:00:49 +00:00
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
if ( $item->get_subtotal() !== $item->get_total() ) {
|
2019-03-06 16:39:28 +00:00
|
|
|
/* translators: %s: discount amount */
|
|
|
|
echo '<span class="wc-order-item-discount">' . sprintf( esc_html__( '%s discount', 'woocommerce' ), wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) ) . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
2018-03-05 18:59:17 +00:00
|
|
|
}
|
2016-03-21 18:35:00 +00:00
|
|
|
|
2019-03-06 16:39:28 +00:00
|
|
|
$refunded = $order->get_total_refunded_for_item( $item_id );
|
|
|
|
|
|
|
|
if ( $refunded ) {
|
|
|
|
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
2018-03-05 18:59:17 +00:00
|
|
|
}
|
2013-08-16 15:43:26 +00:00
|
|
|
?>
|
2013-08-15 15:49:09 +00:00
|
|
|
</div>
|
2014-07-22 15:46:28 +00:00
|
|
|
<div class="edit" style="display: none;">
|
2014-07-22 15:44:02 +00:00
|
|
|
<div class="split-input">
|
2016-03-21 18:35:00 +00:00
|
|
|
<div class="input">
|
2019-03-06 16:39:28 +00:00
|
|
|
<label><?php esc_attr_e( 'Before discount', 'woocommerce' ); ?></label>
|
2017-11-21 17:50:30 +00:00
|
|
|
<input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_subtotal() ) ); ?>" class="line_subtotal wc_input_price" data-subtotal="<?php echo esc_attr( wc_format_localized_price( $item->get_subtotal() ) ); ?>" />
|
2016-03-21 18:35:00 +00:00
|
|
|
</div>
|
|
|
|
<div class="input">
|
2019-03-06 16:39:28 +00:00
|
|
|
<label><?php esc_attr_e( 'Total', 'woocommerce' ); ?></label>
|
2017-11-21 17:50:30 +00:00
|
|
|
<input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" class="line_total wc_input_price" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'woocommerce' ); ?>" data-total="<?php echo esc_attr( wc_format_localized_price( $item->get_total() ) ); ?>" />
|
2016-03-21 18:35:00 +00:00
|
|
|
</div>
|
2014-07-22 15:44:02 +00:00
|
|
|
</div>
|
2016-03-22 14:54:02 +00:00
|
|
|
</div>
|
|
|
|
<div class="refund" style="display: none;">
|
2017-11-21 17:50:30 +00:00
|
|
|
<input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_total wc_input_price" />
|
2016-03-22 14:54:02 +00:00
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<?php
|
2019-03-06 16:17:33 +00:00
|
|
|
$tax_data = wc_tax_enabled() ? $item->get_taxes() : false;
|
|
|
|
|
|
|
|
if ( $tax_data ) {
|
2018-03-05 18:59:17 +00:00
|
|
|
foreach ( $order_taxes as $tax_item ) {
|
|
|
|
$tax_item_id = $tax_item->get_rate_id();
|
|
|
|
$tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : '';
|
|
|
|
$tax_item_subtotal = isset( $tax_data['subtotal'][ $tax_item_id ] ) ? $tax_data['subtotal'][ $tax_item_id ] : '';
|
2019-07-19 14:03:13 +00:00
|
|
|
|
2020-01-23 12:06:49 +00:00
|
|
|
if ( '' !== $tax_item_subtotal ) {
|
|
|
|
$round_at_subtotal = 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' );
|
|
|
|
$tax_item_total = wc_round_tax_total( $tax_item_total, $round_at_subtotal ? wc_get_rounding_precision() : null );
|
|
|
|
$tax_item_subtotal = wc_round_tax_total( $tax_item_subtotal, $round_at_subtotal ? wc_get_rounding_precision() : null );
|
|
|
|
}
|
2018-03-05 18:59:17 +00:00
|
|
|
?>
|
|
|
|
<td class="line_tax" width="1%">
|
|
|
|
<div class="view">
|
|
|
|
<?php
|
|
|
|
if ( '' !== $tax_item_total ) {
|
2019-03-06 16:17:33 +00:00
|
|
|
echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
2018-03-05 18:59:17 +00:00
|
|
|
} else {
|
|
|
|
echo '–';
|
|
|
|
}
|
2016-03-21 18:35:00 +00:00
|
|
|
|
2019-03-06 16:17:33 +00:00
|
|
|
$refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id );
|
|
|
|
|
|
|
|
if ( $refunded ) {
|
|
|
|
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
2018-03-05 18:59:17 +00:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<div class="edit" style="display: none;">
|
|
|
|
<div class="split-input">
|
|
|
|
<div class="input">
|
2019-03-06 16:39:28 +00:00
|
|
|
<label><?php esc_attr_e( 'Before discount', 'woocommerce' ); ?></label>
|
2018-03-05 18:59:17 +00:00
|
|
|
<input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" class="line_subtotal_tax wc_input_price" data-subtotal_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_subtotal ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
|
|
|
|
</div>
|
|
|
|
<div class="input">
|
2019-03-06 16:39:28 +00:00
|
|
|
<label><?php esc_attr_e( 'Total', 'woocommerce' ); ?></label>
|
2018-03-05 18:59:17 +00:00
|
|
|
<input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" class="line_tax wc_input_price" data-total_tax="<?php echo esc_attr( wc_format_localized_price( $tax_item_total ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
|
2016-03-21 18:35:00 +00:00
|
|
|
</div>
|
2016-03-22 14:54:02 +00:00
|
|
|
</div>
|
2018-03-05 18:59:17 +00:00
|
|
|
</div>
|
|
|
|
<div class="refund" style="display: none;">
|
|
|
|
<input type="text" name="refund_line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( wc_format_localized_price( 0 ) ); ?>" class="refund_line_tax wc_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" />
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<?php
|
2016-03-22 14:54:02 +00:00
|
|
|
}
|
2018-03-05 18:59:17 +00:00
|
|
|
}
|
2016-03-22 14:54:02 +00:00
|
|
|
?>
|
2016-03-21 18:35:00 +00:00
|
|
|
<td class="wc-order-edit-line-item" width="1%">
|
2016-03-21 14:58:14 +00:00
|
|
|
<div class="wc-order-edit-line-item-actions">
|
|
|
|
<?php if ( $order->is_editable() ) : ?>
|
2016-03-22 14:54:02 +00:00
|
|
|
<a class="edit-order-item tips" href="#" data-tip="<?php esc_attr_e( 'Edit item', 'woocommerce' ); ?>"></a><a class="delete-order-item tips" href="#" data-tip="<?php esc_attr_e( 'Delete item', 'woocommerce' ); ?>"></a>
|
2016-03-21 14:58:14 +00:00
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
2013-08-15 15:49:09 +00:00
|
|
|
</td>
|
2014-06-11 18:18:33 +00:00
|
|
|
</tr>
|