html-order-download-permission.php
6 years ago
html-order-fee.php
3 months ago
html-order-item-meta.php
4 years ago
html-order-item.php
9 months ago
html-order-items.php
1 month ago
html-order-notes.php
1 month ago
html-order-refund.php
3 months ago
html-order-shipping.php
3 months ago
html-product-attribute-inner.php
1 month ago
html-product-attribute.php
3 years ago
html-product-data-advanced.php
5 months ago
html-product-data-attributes.php
1 month ago
html-product-data-general.php
2 months ago
html-product-data-inventory.php
4 months ago
html-product-data-linked-products.php
3 months ago
html-product-data-panel.php
1 year ago
html-product-data-shipping.php
3 years ago
html-product-data-variations.php
1 month ago
html-product-download.php
4 months ago
html-product-variation-download.php
4 months ago
html-variation-admin.php
1 month ago
html-order-item.php
222 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Shows an order item |
| 4 | * |
| 5 | * @package WooCommerce\Admin |
| 6 | * @var WC_Order_Item $item The item being displayed |
| 7 | * @var int $item_id The id of the item being displayed |
| 8 | */ |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | use Automattic\WooCommerce\Internal\CostOfGoodsSold\CostOfGoodsSoldController; |
| 13 | |
| 14 | $product = $item->get_product(); |
| 15 | $product_link = $product ? admin_url( 'post.php?post=' . $item->get_product_id() . '&action=edit' ) : ''; |
| 16 | $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : ''; |
| 17 | $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empty( $class ) ? $class : '', $item, $order ); |
| 18 | $wc_price_arg = array( 'currency' => $order->get_currency() ); |
| 19 | $is_visible = $product && $product->is_visible(); |
| 20 | |
| 21 | /** |
| 22 | * Filter the order item name. |
| 23 | * |
| 24 | * @since 9.9.0 |
| 25 | * @param string $item_name The order item's name. |
| 26 | * @param WC_Order_Item $item The order item object. |
| 27 | * @param bool $is_visible Item's product visibility in the catalog. |
| 28 | */ |
| 29 | $item_name = apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, $is_visible ); |
| 30 | |
| 31 | ?> |
| 32 | <tr class="item <?php echo esc_attr( $row_class ); ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>"> |
| 33 | <td class="thumb"> |
| 34 | <?php echo '<div class="wc-order-item-thumbnail">' . wp_kses_post( $thumbnail ) . '</div>'; ?> |
| 35 | </td> |
| 36 | <td class="name" data-sort-value="<?php echo esc_attr( $item_name ); ?>"> |
| 37 | <?php |
| 38 | echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . wp_kses_post( $item_name ) . '</a>' : '<div class="wc-order-item-name">' . wp_kses_post( $item_name ) . '</div>'; |
| 39 | |
| 40 | if ( $product && $product->get_sku() ) { |
| 41 | echo '<div class="wc-order-item-sku"><strong>' . esc_html__( 'SKU:', 'woocommerce' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>'; |
| 42 | } |
| 43 | |
| 44 | if ( $item->get_variation_id() ) { |
| 45 | echo '<div class="wc-order-item-variation"><strong>' . esc_html__( 'Variation ID:', 'woocommerce' ) . '</strong> '; |
| 46 | if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) { |
| 47 | echo esc_html( $item->get_variation_id() ); |
| 48 | } else { |
| 49 | /* translators: %s: variation id */ |
| 50 | printf( esc_html__( '%s (No longer exists)', 'woocommerce' ), esc_html( $item->get_variation_id() ) ); |
| 51 | } |
| 52 | echo '</div>'; |
| 53 | } |
| 54 | ?> |
| 55 | <input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" /> |
| 56 | <input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" /> |
| 57 | |
| 58 | <?php do_action( 'woocommerce_before_order_itemmeta', $item_id, $item, $product ); ?> |
| 59 | <?php require __DIR__ . '/html-order-item-meta.php'; ?> |
| 60 | <?php do_action( 'woocommerce_after_order_itemmeta', $item_id, $item, $product ); ?> |
| 61 | </td> |
| 62 | |
| 63 | <?php do_action( 'woocommerce_admin_order_item_values', $product, $item, absint( $item_id ) ); ?> |
| 64 | |
| 65 | <?php if ( wc_get_container()->get( CostOfGoodsSoldController::class )->feature_is_enabled() ) : ?> |
| 66 | <td class="item_cost_of_goods" width="1%" data-sort-value="<?php echo esc_attr( $item->get_cogs_value() ); ?>"> |
| 67 | <?php $tooltip_text = $item->get_cogs_value_per_unit_tooltip_text(); ?> |
| 68 | <div class="view" |
| 69 | <?php |
| 70 | if ( $tooltip_text ) { |
| 71 | echo " title='" . esc_attr( $tooltip_text ) . "'"; } |
| 72 | ?> |
| 73 | > |
| 74 | <?php |
| 75 | echo wp_kses_post( $item->get_cogs_value_html() ); |
| 76 | |
| 77 | $refunded_cost = $order->get_cogs_refunded_for_item( $item_id ); |
| 78 | echo wp_kses_post( $item->get_cogs_refund_value_html( $refunded_cost, $wc_price_arg, $order ) ); |
| 79 | ?> |
| 80 | </div> |
| 81 | </td> |
| 82 | <?php endif; ?> |
| 83 | <td class="item_cost" width="1%" data-sort-value="<?php echo esc_attr( $order->get_item_subtotal( $item, false, true ) ); ?>"> |
| 84 | <div class="view"> |
| 85 | <?php |
| 86 | echo wc_price( $order->get_item_subtotal( $item, false, true ), $wc_price_arg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 87 | ?> |
| 88 | </div> |
| 89 | </td> |
| 90 | <td class="quantity" width="1%"> |
| 91 | <div class="view"> |
| 92 | <?php |
| 93 | echo '<small class="times">×</small> ' . esc_html( $item->get_quantity() ); |
| 94 | |
| 95 | $refunded_qty = -1 * $order->get_qty_refunded_for_item( $item_id ); |
| 96 | |
| 97 | if ( $refunded_qty ) { |
| 98 | echo '<small class="refunded">' . esc_html( $refunded_qty * -1 ) . '</small>'; |
| 99 | } |
| 100 | ?> |
| 101 | </div> |
| 102 | <?php |
| 103 | $step = $product ? $product->get_purchase_quantity_step() : 1; |
| 104 | |
| 105 | /** |
| 106 | * Filter to change the product quantity stepping in the order editor of the admin area. |
| 107 | * |
| 108 | * @since 5.8.0 |
| 109 | * @param string $step The current step amount to be used in the quantity editor. |
| 110 | * @param WC_Product $product The product that is being edited. |
| 111 | * @param string $context The context in which the quantity editor is shown, 'edit' or 'refund'. |
| 112 | */ |
| 113 | $step_edit = apply_filters( 'woocommerce_quantity_input_step_admin', $step, $product, 'edit' ); |
| 114 | $step_refund = apply_filters( 'woocommerce_quantity_input_step_admin', $step, $product, 'refund' ); |
| 115 | |
| 116 | /** |
| 117 | * Filter to change the product quantity minimum in the order editor of the admin area. |
| 118 | * |
| 119 | * @since 5.8.0 |
| 120 | * @param string $step The current minimum amount to be used in the quantity editor. |
| 121 | * @param WC_Product $product The product that is being edited. |
| 122 | * @param string $context The context in which the quantity editor is shown, 'edit' or 'refund'. |
| 123 | */ |
| 124 | $min_edit = apply_filters( 'woocommerce_quantity_input_min_admin', '0', $product, 'edit' ); |
| 125 | $min_refund = apply_filters( 'woocommerce_quantity_input_min_admin', '0', $product, 'refund' ); |
| 126 | ?> |
| 127 | <div class="edit" style="display: none;"> |
| 128 | <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" /> |
| 129 | </div> |
| 130 | <div class="refund" style="display: none;"> |
| 131 | <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" /> |
| 132 | </div> |
| 133 | </td> |
| 134 | <td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( $item->get_total() ); ?>"> |
| 135 | <div class="view"> |
| 136 | <?php |
| 137 | echo wc_price( $item->get_total(), $wc_price_arg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 138 | |
| 139 | if ( $item->get_subtotal() !== $item->get_total() ) { |
| 140 | /* translators: %s: discount amount */ |
| 141 | echo '<span class="wc-order-item-discount">' . sprintf( esc_html__( '%s discount', 'woocommerce' ), wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), $wc_price_arg ) ) . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 142 | } |
| 143 | |
| 144 | $refunded = -1 * $order->get_total_refunded_for_item( $item_id ); |
| 145 | |
| 146 | if ( $refunded ) { |
| 147 | echo '<small class="refunded">' . wc_price( $refunded, $wc_price_arg ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 148 | } |
| 149 | ?> |
| 150 | </div> |
| 151 | <div class="edit" style="display: none;"> |
| 152 | <div class="split-input"> |
| 153 | <div class="input"> |
| 154 | <label><?php esc_attr_e( 'Before discount', 'woocommerce' ); ?></label> |
| 155 | <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() ) ); ?>" /> |
| 156 | </div> |
| 157 | <div class="input"> |
| 158 | <label><?php esc_attr_e( 'Total', 'woocommerce' ); ?></label> |
| 159 | <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() ) ); ?>" /> |
| 160 | </div> |
| 161 | </div> |
| 162 | </div> |
| 163 | <div class="refund" style="display: none;"> |
| 164 | <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" /> |
| 165 | </div> |
| 166 | </td> |
| 167 | |
| 168 | <?php |
| 169 | $tax_data = wc_tax_enabled() ? $item->get_taxes() : false; |
| 170 | |
| 171 | if ( $tax_data ) { |
| 172 | foreach ( $order_taxes as $tax_item ) { |
| 173 | $tax_item_id = $tax_item->get_rate_id(); |
| 174 | $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : ''; |
| 175 | $tax_item_subtotal = isset( $tax_data['subtotal'][ $tax_item_id ] ) ? $tax_data['subtotal'][ $tax_item_id ] : ''; |
| 176 | |
| 177 | ?> |
| 178 | <td class="line_tax" width="1%"> |
| 179 | <div class="view"> |
| 180 | <?php |
| 181 | if ( '' !== $tax_item_total ) { |
| 182 | echo wc_price( wc_round_tax_total( $tax_item_total ), $wc_price_arg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 183 | } else { |
| 184 | echo '–'; |
| 185 | } |
| 186 | |
| 187 | $refunded = -1 * $order->get_tax_refunded_for_item( $item_id, $tax_item_id ); |
| 188 | |
| 189 | if ( $refunded ) { |
| 190 | echo '<small class="refunded">' . wc_price( $refunded, $wc_price_arg ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 191 | } |
| 192 | ?> |
| 193 | </div> |
| 194 | <div class="edit" style="display: none;"> |
| 195 | <div class="split-input"> |
| 196 | <div class="input"> |
| 197 | <label><?php esc_attr_e( 'Before discount', 'woocommerce' ); ?></label> |
| 198 | <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 ); ?>" /> |
| 199 | </div> |
| 200 | <div class="input"> |
| 201 | <label><?php esc_attr_e( 'Total', 'woocommerce' ); ?></label> |
| 202 | <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 ); ?>" /> |
| 203 | </div> |
| 204 | </div> |
| 205 | </div> |
| 206 | <div class="refund" style="display: none;"> |
| 207 | <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 ); ?>" /> |
| 208 | </div> |
| 209 | </td> |
| 210 | <?php |
| 211 | } |
| 212 | } |
| 213 | ?> |
| 214 | <td class="wc-order-edit-line-item" width="1%"> |
| 215 | <div class="wc-order-edit-line-item-actions"> |
| 216 | <?php if ( $order->is_editable() ) : ?> |
| 217 | <a class="edit-order-item tips" href="#" data-tip="<?php esc_attr_e( 'Edit item', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Edit item', 'woocommerce' ); ?>"></a><a class="delete-order-item tips" href="#" data-tip="<?php esc_attr_e( 'Delete item', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Delete item', 'woocommerce' ); ?>"></a> |
| 218 | <?php endif; ?> |
| 219 | </div> |
| 220 | </td> |
| 221 | </tr> |
| 222 |