관리-도구
편집 파일: html-order-item.php
<?php /** * Shows an order item * * @package Kkart\Admin * @var object $item The item being displayed * @var int $item_id The id of the item being displayed */ defined( 'ABSPATH' ) || exit; $product = $item->get_product(); $product_link = $product ? admin_url( 'post.php?post=' . $item->get_product_id() . '&action=edit' ) : ''; $thumbnail = $product ? apply_filters( 'kkart_admin_order_item_thumbnail', $product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : ''; $row_class = apply_filters( 'kkart_admin_html_order_item_class', ! empty( $class ) ? $class : '', $item, $order ); ?> <tr class="item <?php echo esc_attr( $row_class ); ?>" data-order_item_id="<?php echo esc_attr( $item_id ); ?>"> <td class="thumb"> <?php echo '<div class="kkart-order-item-thumbnail">' . wp_kses_post( $thumbnail ) . '</div>'; ?> </td> <td class="name" data-sort-value="<?php echo esc_attr( $item->get_name() ); ?>"> <?php echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="kkart-order-item-name">' . wp_kses_post( $item->get_name() ) . '</a>' : '<div class="kkart-order-item-name">' . wp_kses_post( $item->get_name() ) . '</div>'; if ( $product && $product->get_sku() ) { echo '<div class="kkart-order-item-sku"><strong>' . esc_html__( 'SKU:', 'kkart' ) . '</strong> ' . esc_html( $product->get_sku() ) . '</div>'; } if ( $item->get_variation_id() ) { echo '<div class="kkart-order-item-variation"><strong>' . esc_html__( 'Variation ID:', 'kkart' ) . '</strong> '; if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) { echo esc_html( $item->get_variation_id() ); } else { /* translators: %s: variation id */ printf( esc_html__( '%s (No longer exists)', 'kkart' ), esc_html( $item->get_variation_id() ) ); } echo '</div>'; } ?> <input type="hidden" class="order_item_id" name="order_item_id[]" value="<?php echo esc_attr( $item_id ); ?>" /> <input type="hidden" name="order_item_tax_class[<?php echo absint( $item_id ); ?>]" value="<?php echo esc_attr( $item->get_tax_class() ); ?>" /> <?php do_action( 'kkart_before_order_itemmeta', $item_id, $item, $product ); ?> <?php require __DIR__ . '/html-order-item-meta.php'; ?> <?php do_action( 'kkart_after_order_itemmeta', $item_id, $item, $product ); ?> </td> <?php do_action( 'kkart_admin_order_item_values', $product, $item, absint( $item_id ) ); ?> <td class="item_cost" width="1%" data-sort-value="<?php echo esc_attr( $order->get_item_subtotal( $item, false, true ) ); ?>"> <div class="view"> <?php echo kkart_price( $order->get_item_subtotal( $item, false, true ), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> </div> </td> <td class="quantity" width="1%"> <div class="view"> <?php echo '<small class="times">×</small> ' . esc_html( $item->get_quantity() ); $refunded_qty = $order->get_qty_refunded_for_item( $item_id ); if ( $refunded_qty ) { echo '<small class="refunded">-' . esc_html( $refunded_qty * -1 ) . '</small>'; } ?> </div> <div class="edit" style="display: none;"> <input type="number" step="<?php echo esc_attr( apply_filters( 'kkart_quantity_input_step', '1', $product ) ); ?>" min="0" 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" /> </div> <div class="refund" style="display: none;"> <input type="number" step="<?php echo esc_attr( apply_filters( 'kkart_quantity_input_step', '1', $product ) ); ?>" min="0" 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" /> </div> </td> <td class="line_cost" width="1%" data-sort-value="<?php echo esc_attr( $item->get_total() ); ?>"> <div class="view"> <?php echo kkart_price( $item->get_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( $item->get_subtotal() !== $item->get_total() ) { /* translators: %s: discount amount */ echo '<span class="kkart-order-item-discount">' . sprintf( esc_html__( '%s discount', 'kkart' ), kkart_price( kkart_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) ) . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } $refunded = $order->get_total_refunded_for_item( $item_id ); if ( $refunded ) { echo '<small class="refunded">-' . kkart_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } ?> </div> <div class="edit" style="display: none;"> <div class="split-input"> <div class="input"> <label><?php esc_attr_e( 'Before discount', 'kkart' ); ?></label> <input type="text" name="line_subtotal[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( kkart_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( kkart_format_localized_price( $item->get_subtotal() ) ); ?>" class="line_subtotal kkart_input_price" data-subtotal="<?php echo esc_attr( kkart_format_localized_price( $item->get_subtotal() ) ); ?>" /> </div> <div class="input"> <label><?php esc_attr_e( 'Total', 'kkart' ); ?></label> <input type="text" name="line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( kkart_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( kkart_format_localized_price( $item->get_total() ) ); ?>" class="line_total kkart_input_price" data-tip="<?php esc_attr_e( 'After pre-tax discounts.', 'kkart' ); ?>" data-total="<?php echo esc_attr( kkart_format_localized_price( $item->get_total() ) ); ?>" /> </div> </div> </div> <div class="refund" style="display: none;"> <input type="text" name="refund_line_total[<?php echo absint( $item_id ); ?>]" placeholder="<?php echo esc_attr( kkart_format_localized_price( 0 ) ); ?>" class="refund_line_total kkart_input_price" /> </div> </td> <?php $tax_data = kkart_tax_enabled() ? $item->get_taxes() : false; if ( $tax_data ) { 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 ] : ''; if ( '' !== $tax_item_subtotal ) { $round_at_subtotal = 'yes' === get_option( 'kkart_tax_round_at_subtotal' ); $tax_item_total = kkart_round_tax_total( $tax_item_total, $round_at_subtotal ? kkart_get_rounding_precision() : null ); $tax_item_subtotal = kkart_round_tax_total( $tax_item_subtotal, $round_at_subtotal ? kkart_get_rounding_precision() : null ); } ?> <td class="line_tax" width="1%"> <div class="view"> <?php if ( '' !== $tax_item_total ) { echo kkart_price( kkart_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } else { echo '–'; } $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ); if ( $refunded ) { echo '<small class="refunded">-' . kkart_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } ?> </div> <div class="edit" style="display: none;"> <div class="split-input"> <div class="input"> <label><?php esc_attr_e( 'Before discount', 'kkart' ); ?></label> <input type="text" name="line_subtotal_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( kkart_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( kkart_format_localized_price( $tax_item_subtotal ) ); ?>" class="line_subtotal_tax kkart_input_price" data-subtotal_tax="<?php echo esc_attr( kkart_format_localized_price( $tax_item_subtotal ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> </div> <div class="input"> <label><?php esc_attr_e( 'Total', 'kkart' ); ?></label> <input type="text" name="line_tax[<?php echo absint( $item_id ); ?>][<?php echo esc_attr( $tax_item_id ); ?>]" placeholder="<?php echo esc_attr( kkart_format_localized_price( 0 ) ); ?>" value="<?php echo esc_attr( kkart_format_localized_price( $tax_item_total ) ); ?>" class="line_tax kkart_input_price" data-total_tax="<?php echo esc_attr( kkart_format_localized_price( $tax_item_total ) ); ?>" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> </div> </div> </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( kkart_format_localized_price( 0 ) ); ?>" class="refund_line_tax kkart_input_price" data-tax_id="<?php echo esc_attr( $tax_item_id ); ?>" /> </div> </td> <?php } } ?> <td class="kkart-order-edit-line-item" width="1%"> <div class="kkart-order-edit-line-item-actions"> <?php if ( $order->is_editable() ) : ?> <a class="edit-order-item tips" href="#" data-tip="<?php esc_attr_e( 'Edit item', 'kkart' ); ?>"></a><a class="delete-order-item tips" href="#" data-tip="<?php esc_attr_e( 'Delete item', 'kkart' ); ?>"></a> <?php endif; ?> </div> </td> </tr>