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-items.php
517 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Order items HTML for meta box. |
| 4 | * |
| 5 | * @package WooCommerce\Admin |
| 6 | */ |
| 7 | |
| 8 | use Automattic\WooCommerce\Enums\OrderStatus; |
| 9 | use Automattic\WooCommerce\Internal\CostOfGoodsSold\CostOfGoodsSoldController; |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | /** |
| 14 | * Allow plugins to determine whether refunds UI should be rendered in the template. |
| 15 | * |
| 16 | * @since 6.4.0 |
| 17 | * |
| 18 | * @param bool $render_refunds If the refunds UI should be rendered. |
| 19 | * @param int $order_id The Order ID. |
| 20 | * @param WC_Order $order The Order object. |
| 21 | */ |
| 22 | $render_refunds = (bool) apply_filters( 'woocommerce_admin_order_should_render_refunds', 0 < $order->get_total() - $order->get_total_refunded() || 0 < absint( $order->get_item_count() - $order->get_item_count_refunded() ), $order->get_id(), $order ); |
| 23 | |
| 24 | global $wpdb; |
| 25 | |
| 26 | $payment_gateway = wc_get_payment_gateway_by_order( $order ); |
| 27 | $line_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', 'line_item' ) ); |
| 28 | $discounts = $order->get_items( 'discount' ); |
| 29 | $line_items_fee = $order->get_items( 'fee' ); |
| 30 | $line_items_shipping = $order->get_items( 'shipping' ); |
| 31 | $cogs_is_enabled = wc_get_container()->get( CostOfGoodsSoldController::class )->feature_is_enabled(); |
| 32 | |
| 33 | if ( wc_tax_enabled() ) { |
| 34 | $order_taxes = $order->get_taxes(); |
| 35 | $tax_classes = WC_Tax::get_tax_classes(); |
| 36 | $classes_options = wc_get_product_tax_class_options(); |
| 37 | $show_tax_columns = count( $order_taxes ) === 1; |
| 38 | } |
| 39 | ?> |
| 40 | <div class="woocommerce_order_items_wrapper wc-order-items-editable"> |
| 41 | <table cellpadding="0" cellspacing="0" class="woocommerce_order_items"> |
| 42 | <thead> |
| 43 | <tr> |
| 44 | <th class="item sortable" colspan="2" data-sort="string-ins"><?php esc_html_e( 'Item', 'woocommerce' ); ?></th> |
| 45 | <?php do_action( 'woocommerce_admin_order_item_headers', $order ); ?> |
| 46 | <?php if ( $cogs_is_enabled ) : ?> |
| 47 | <th class="item_cost_of_goods sortable" data-sort="float"><?php esc_html_e( 'Cost', 'woocommerce' ); ?></th> |
| 48 | <?php endif; ?> |
| 49 | <th class="item_cost sortable" data-sort="float"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th> |
| 50 | <th class="quantity sortable" data-sort="int"><?php esc_html_e( 'Qty', 'woocommerce' ); ?></th> |
| 51 | <th class="line_cost sortable" data-sort="float"><?php esc_html_e( 'Total', 'woocommerce' ); ?></th> |
| 52 | <?php |
| 53 | if ( ! empty( $order_taxes ) ) : |
| 54 | foreach ( $order_taxes as $tax_id => $tax_item ) : |
| 55 | $tax_class = wc_get_tax_class_by_tax_id( $tax_item['rate_id'] ); |
| 56 | $tax_class_name = isset( $classes_options[ $tax_class ] ) ? $classes_options[ $tax_class ] : __( 'Tax', 'woocommerce' ); |
| 57 | $column_label = ! empty( $tax_item['label'] ) ? $tax_item['label'] : __( 'Tax', 'woocommerce' ); |
| 58 | /* translators: %1$s: tax item name %2$s: tax class name */ |
| 59 | $column_tip = sprintf( esc_html__( '%1$s (%2$s)', 'woocommerce' ), $tax_item['name'], $tax_class_name ); |
| 60 | ?> |
| 61 | <th class="line_tax tips" data-tip="<?php echo esc_attr( $column_tip ); ?>"> |
| 62 | <?php echo esc_attr( $column_label ); ?> |
| 63 | <input type="hidden" class="order-tax-id" name="order_taxes[<?php echo esc_attr( $tax_id ); ?>]" value="<?php echo esc_attr( $tax_item['rate_id'] ); ?>"> |
| 64 | <?php if ( $order->is_editable() ) : ?> |
| 65 | <a class="delete-order-tax" href="#" data-rate_id="<?php echo esc_attr( $tax_id ); ?>"></a> |
| 66 | <?php endif; ?> |
| 67 | </th> |
| 68 | <?php |
| 69 | endforeach; |
| 70 | endif; |
| 71 | ?> |
| 72 | <th class="wc-order-edit-line-item" width="1%"> </th> |
| 73 | </tr> |
| 74 | </thead> |
| 75 | <tbody id="order_line_items"> |
| 76 | <?php |
| 77 | foreach ( $line_items as $item_id => $item ) { |
| 78 | do_action( 'woocommerce_before_order_item_' . $item->get_type() . '_html', $item_id, $item, $order ); |
| 79 | |
| 80 | include __DIR__ . '/html-order-item.php'; |
| 81 | |
| 82 | do_action( 'woocommerce_order_item_' . $item->get_type() . '_html', $item_id, $item, $order ); |
| 83 | } |
| 84 | do_action( 'woocommerce_admin_order_items_after_line_items', $order->get_id() ); |
| 85 | ?> |
| 86 | </tbody> |
| 87 | <tbody id="order_fee_line_items"> |
| 88 | <?php |
| 89 | foreach ( $line_items_fee as $item_id => $item ) { |
| 90 | include __DIR__ . '/html-order-fee.php'; |
| 91 | } |
| 92 | do_action( 'woocommerce_admin_order_items_after_fees', $order->get_id() ); |
| 93 | ?> |
| 94 | </tbody> |
| 95 | <tbody id="order_shipping_line_items"> |
| 96 | <?php |
| 97 | $shipping_methods = WC()->shipping() ? WC()->shipping()->load_shipping_methods() : array(); |
| 98 | foreach ( $line_items_shipping as $item_id => $item ) { |
| 99 | include __DIR__ . '/html-order-shipping.php'; |
| 100 | } |
| 101 | do_action( 'woocommerce_admin_order_items_after_shipping', $order->get_id() ); |
| 102 | ?> |
| 103 | </tbody> |
| 104 | <tbody id="order_refunds"> |
| 105 | <?php |
| 106 | $refunds = $order->get_refunds(); |
| 107 | |
| 108 | if ( $refunds ) { |
| 109 | foreach ( $refunds as $refund ) { |
| 110 | include __DIR__ . '/html-order-refund.php'; |
| 111 | } |
| 112 | do_action( 'woocommerce_admin_order_items_after_refunds', $order->get_id() ); |
| 113 | } |
| 114 | ?> |
| 115 | </tbody> |
| 116 | </table> |
| 117 | </div> |
| 118 | <div class="wc-order-data-row wc-order-totals-items wc-order-items-editable"> |
| 119 | <?php |
| 120 | $coupons = $order->get_items( 'coupon' ); |
| 121 | if ( $coupons ) : |
| 122 | ?> |
| 123 | <div class="wc-used-coupons"> |
| 124 | <ul class="wc_coupon_list"> |
| 125 | <li><strong><?php esc_html_e( 'Coupon(s)', 'woocommerce' ); ?></strong></li> |
| 126 | <?php |
| 127 | foreach ( $coupons as $item_id => $item ) : |
| 128 | $coupon_info = $item->get_meta( 'coupon_info' ); |
| 129 | if ( $coupon_info ) { |
| 130 | $coupon_info = json_decode( $coupon_info, true ); |
| 131 | $post_id = $coupon_info[0]; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 132 | } else { |
| 133 | $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE LOWER(post_title) = LOWER(%s) AND post_type = 'shop_coupon' AND post_status = 'publish' AND post_date < %s LIMIT 1;", wc_sanitize_coupon_code( $item->get_code() ), $order->get_date_created()->format( 'Y-m-d H:i:s' ) ) ); // phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited |
| 134 | } |
| 135 | $class = $order->is_editable() ? 'code editable' : 'code'; |
| 136 | ?> |
| 137 | <li class="<?php echo esc_attr( $class ); ?>"> |
| 138 | <?php if ( $post_id ) : ?> |
| 139 | <?php |
| 140 | $post_url = apply_filters( |
| 141 | 'woocommerce_admin_order_item_coupon_url', |
| 142 | add_query_arg( |
| 143 | array( |
| 144 | 'post' => $post_id, |
| 145 | 'action' => 'edit', |
| 146 | ), |
| 147 | admin_url( 'post.php' ) |
| 148 | ), |
| 149 | $item, |
| 150 | $order |
| 151 | ); |
| 152 | ?> |
| 153 | <a href="<?php echo esc_url( $post_url ); ?>" class="tips" data-tip="<?php echo esc_attr( wc_price( $item->get_discount(), array( 'currency' => $order->get_currency() ) ) ); ?>"> |
| 154 | <span><?php echo esc_html( $item->get_code() ); ?></span> |
| 155 | </a> |
| 156 | <?php else : ?> |
| 157 | <span class="tips" data-tip="<?php echo esc_attr( wc_price( $item->get_discount(), array( 'currency' => $order->get_currency() ) ) ); ?>"> |
| 158 | <span><?php echo esc_html( $item->get_code() ); ?></span> |
| 159 | </span> |
| 160 | <?php endif; ?> |
| 161 | <?php if ( $order->is_editable() ) : ?> |
| 162 | <a class="remove-coupon" href="javascript:void(0)" aria-label="Remove" data-code="<?php echo esc_attr( $item->get_code() ); ?>"></a> |
| 163 | <?php endif; ?> |
| 164 | </li> |
| 165 | <?php endforeach; ?> |
| 166 | </ul> |
| 167 | </div> |
| 168 | <?php endif; ?> |
| 169 | <table class="wc-order-totals"> |
| 170 | <tr> |
| 171 | <td class="label"><?php esc_html_e( 'Items Subtotal:', 'woocommerce' ); ?></td> |
| 172 | <td width="1%"></td> |
| 173 | <td class="total"> |
| 174 | <?php echo wc_price( $order->get_subtotal(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 175 | </td> |
| 176 | </tr> |
| 177 | <?php if ( 0 < $order->get_total_discount() ) : ?> |
| 178 | <tr> |
| 179 | <td class="label"><?php esc_html_e( 'Discount:', 'woocommerce' ); ?></td> |
| 180 | <td width="1%"></td> |
| 181 | <td class="total">- |
| 182 | <?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 183 | </td> |
| 184 | </tr> |
| 185 | <?php endif; ?> |
| 186 | <?php if ( abs( $order->get_total_fees() ) > 0 ) : ?> |
| 187 | <tr> |
| 188 | <td class="label"><?php esc_html_e( 'Fees:', 'woocommerce' ); ?></td> |
| 189 | <td width="1%"></td> |
| 190 | <td class="total"> |
| 191 | <?php echo wc_price( $order->get_total_fees(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 192 | </td> |
| 193 | </tr> |
| 194 | <?php endif; ?> |
| 195 | |
| 196 | <?php do_action( 'woocommerce_admin_order_totals_after_discount', $order->get_id() ); ?> |
| 197 | |
| 198 | <?php if ( $order->get_shipping_methods() ) : ?> |
| 199 | <tr> |
| 200 | <td class="label"><?php esc_html_e( 'Shipping:', 'woocommerce' ); ?></td> |
| 201 | <td width="1%"></td> |
| 202 | <td class="total"> |
| 203 | <?php echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 204 | </td> |
| 205 | </tr> |
| 206 | <?php endif; ?> |
| 207 | |
| 208 | <?php do_action( 'woocommerce_admin_order_totals_after_shipping', $order->get_id() ); ?> |
| 209 | |
| 210 | <?php if ( wc_tax_enabled() ) : ?> |
| 211 | <?php foreach ( $order->get_tax_totals() as $code => $tax_total ) : ?> |
| 212 | <tr> |
| 213 | <td class="label"><?php echo esc_html( $tax_total->label ); ?>:</td> |
| 214 | <td width="1%"></td> |
| 215 | <td class="total"> |
| 216 | <?php |
| 217 | // We use wc_round_tax_total here because tax may need to be round up or round down depending upon settings, whereas wc_price alone will always round it down. |
| 218 | echo wc_price( wc_round_tax_total( $tax_total->amount ), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 219 | ?> |
| 220 | </td> |
| 221 | </tr> |
| 222 | <?php endforeach; ?> |
| 223 | <?php endif; ?> |
| 224 | |
| 225 | <?php do_action( 'woocommerce_admin_order_totals_after_tax', $order->get_id() ); ?> |
| 226 | |
| 227 | <tr> |
| 228 | <td class="label"><?php esc_html_e( 'Order Total', 'woocommerce' ); ?>:</td> |
| 229 | <td width="1%"></td> |
| 230 | <td class="total"> |
| 231 | <?php echo wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 232 | </td> |
| 233 | </tr> |
| 234 | |
| 235 | </table> |
| 236 | |
| 237 | <div class="clear"></div> |
| 238 | |
| 239 | <?php if ( in_array( $order->get_status(), array( OrderStatus::PROCESSING, OrderStatus::COMPLETED, OrderStatus::REFUNDED ), true ) && ! empty( $order->get_date_paid() ) ) : ?> |
| 240 | |
| 241 | <table class="wc-order-totals" style="border-top: 1px solid #999; margin-top:12px; padding-top:12px"> |
| 242 | <tr> |
| 243 | <td class="<?php echo $order->get_total_refunded() ? 'label' : 'label label-highlight'; ?>"><?php esc_html_e( 'Paid', 'woocommerce' ); ?>: <br /></td> |
| 244 | <td width="1%"></td> |
| 245 | <td class="total"> |
| 246 | <?php echo wc_price( $order->get_total(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 247 | </td> |
| 248 | </tr> |
| 249 | <tr> |
| 250 | <td> |
| 251 | <span class="description"> |
| 252 | <?php |
| 253 | if ( $order->get_payment_method_title() ) { |
| 254 | /* translators: 1: payment date. 2: payment method */ |
| 255 | echo esc_html( sprintf( __( '%1$s via %2$s', 'woocommerce' ), $order->get_date_paid()->date_i18n( get_option( 'date_format' ) ), $order->get_payment_method_title() ) ); |
| 256 | } else { |
| 257 | echo esc_html( $order->get_date_paid()->date_i18n( get_option( 'date_format' ) ) ); |
| 258 | } |
| 259 | ?> |
| 260 | </span> |
| 261 | </td> |
| 262 | <td colspan="2"></td> |
| 263 | </tr> |
| 264 | </table> |
| 265 | |
| 266 | <div class="clear"></div> |
| 267 | |
| 268 | <?php endif; ?> |
| 269 | |
| 270 | <?php if ( $order->get_total_refunded() ) : ?> |
| 271 | <table class="wc-order-totals" style="border-top: 1px solid #999; margin-top:12px; padding-top:12px"> |
| 272 | <tr> |
| 273 | <td class="label refunded-total"><?php esc_html_e( 'Refunded', 'woocommerce' ); ?>:</td> |
| 274 | <td width="1%"></td> |
| 275 | <td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td> |
| 276 | </tr> |
| 277 | |
| 278 | <?php do_action( 'woocommerce_admin_order_totals_after_refunded', $order->get_id() ); ?> |
| 279 | |
| 280 | <tr> |
| 281 | <td class="label label-highlight"><?php esc_html_e( 'Net Payment', 'woocommerce' ); ?>:</td> |
| 282 | <td width="1%"></td> |
| 283 | <td class="total"> |
| 284 | <?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 285 | </td> |
| 286 | </tr> |
| 287 | |
| 288 | </table> |
| 289 | <?php endif; ?> |
| 290 | |
| 291 | <?php if ( $cogs_is_enabled ) : ?> |
| 292 | <div class="clear"></div> |
| 293 | |
| 294 | <table class="wc-order-totals"> |
| 295 | <tr> |
| 296 | <td class="label cost-total"><?php esc_html_e( 'Cost Total', 'woocommerce' ); ?>:</td> |
| 297 | <td width="1%"></td> |
| 298 | <td class="total cost-total"> |
| 299 | <?php echo wp_kses_post( $order->get_cogs_total_value_html() ); ?> |
| 300 | </td> |
| 301 | </tr> |
| 302 | </table> |
| 303 | <?php endif; ?> |
| 304 | |
| 305 | <div class="clear"></div> |
| 306 | |
| 307 | <table class="wc-order-totals"> |
| 308 | <?php do_action( 'woocommerce_admin_order_totals_after_total', $order->get_id() ); ?> |
| 309 | </table> |
| 310 | |
| 311 | <div class="clear"></div> |
| 312 | </div> |
| 313 | <div class="wc-order-data-row wc-order-bulk-actions wc-order-data-row-toggle"> |
| 314 | <p class="add-items"> |
| 315 | <?php if ( $order->is_editable() ) : ?> |
| 316 | <button type="button" class="button add-line-item"><?php esc_html_e( 'Add item(s)', 'woocommerce' ); ?></button> |
| 317 | <?php if ( wc_coupons_enabled() ) : ?> |
| 318 | <button type="button" class="button add-coupon"><?php esc_html_e( 'Apply coupon', 'woocommerce' ); ?></button> |
| 319 | <?php endif; ?> |
| 320 | <?php else : ?> |
| 321 | <span class="description"><?php echo wc_help_tip( __( 'To edit this order change the status back to "Pending payment"', 'woocommerce' ) ); ?> <?php esc_html_e( 'This order is no longer editable.', 'woocommerce' ); ?></span> |
| 322 | <?php endif; ?> |
| 323 | <?php if ( $render_refunds ) : ?> |
| 324 | <button type="button" class="button refund-items"><?php esc_html_e( 'Refund', 'woocommerce' ); ?></button> |
| 325 | <?php endif; ?> |
| 326 | <?php |
| 327 | // Allow adding custom buttons. |
| 328 | do_action( 'woocommerce_order_item_add_action_buttons', $order ); |
| 329 | ?> |
| 330 | <?php if ( $order->is_editable() ) : ?> |
| 331 | <button type="button" class="button button-primary calculate-action"><?php esc_html_e( 'Recalculate', 'woocommerce' ); ?></button> |
| 332 | <?php endif; ?> |
| 333 | </p> |
| 334 | </div> |
| 335 | <div class="wc-order-data-row wc-order-add-item wc-order-data-row-toggle" style="display:none;"> |
| 336 | <button type="button" class="button add-order-item"><?php esc_html_e( 'Add product(s)', 'woocommerce' ); ?></button> |
| 337 | <button type="button" class="button add-order-fee"><?php esc_html_e( 'Add fee', 'woocommerce' ); ?></button> |
| 338 | <button type="button" class="button add-order-shipping"><?php esc_html_e( 'Add shipping', 'woocommerce' ); ?></button> |
| 339 | <?php if ( wc_tax_enabled() ) : ?> |
| 340 | <button type="button" class="button add-order-tax"><?php esc_html_e( 'Add tax', 'woocommerce' ); ?></button> |
| 341 | <?php endif; ?> |
| 342 | <?php |
| 343 | // Allow adding custom buttons. |
| 344 | do_action( 'woocommerce_order_item_add_line_buttons', $order ); |
| 345 | ?> |
| 346 | <button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button> |
| 347 | <button type="button" class="button button-primary save-action"><?php esc_html_e( 'Save', 'woocommerce' ); ?></button> |
| 348 | </div> |
| 349 | <?php if ( $render_refunds ) : ?> |
| 350 | <div class="wc-order-data-row wc-order-refund-items wc-order-data-row-toggle" style="display: none;"> |
| 351 | <table class="wc-order-totals"> |
| 352 | <?php if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) : ?> |
| 353 | <tr> |
| 354 | <td class="label"><label for="restock_refunded_items"><?php esc_html_e( 'Restock refunded items', 'woocommerce' ); ?>:</label></td> |
| 355 | <td class="total"><input type="checkbox" id="restock_refunded_items" name="restock_refunded_items" <?php checked( apply_filters( 'woocommerce_restock_refunded_items', true ) ); ?> /></td> |
| 356 | </tr> |
| 357 | <?php endif; ?> |
| 358 | <tr> |
| 359 | <td class="label"><?php esc_html_e( 'Amount already refunded', 'woocommerce' ); ?>:</td> |
| 360 | <td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td> |
| 361 | </tr> |
| 362 | <tr> |
| 363 | <td class="label"><?php esc_html_e( 'Total available to refund', 'woocommerce' ); ?>:</td> |
| 364 | <td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td> |
| 365 | </tr> |
| 366 | <tr> |
| 367 | <td class="label"> |
| 368 | <label for="refund_amount"> |
| 369 | <?php echo wc_help_tip( __( 'Refund the line items above. This will show the total amount to be refunded', 'woocommerce' ) ); ?> |
| 370 | <?php esc_html_e( 'Refund amount', 'woocommerce' ); ?>: |
| 371 | </label> |
| 372 | </td> |
| 373 | <td class="total"> |
| 374 | <input type="text" id="refund_amount" name="refund_amount" class="wc_input_price" |
| 375 | <?php |
| 376 | if ( wc_tax_enabled() ) { |
| 377 | // If taxes are enabled, using this refund amount can cause issues due to taxes not being refunded also. |
| 378 | // The refunds should be added to the line items, not the order as a whole. |
| 379 | echo 'readonly'; |
| 380 | } |
| 381 | ?> |
| 382 | /> |
| 383 | <div class="clear"></div> |
| 384 | </td> |
| 385 | </tr> |
| 386 | <tr> |
| 387 | <td class="label"> |
| 388 | <label for="refund_reason"> |
| 389 | <?php echo wc_help_tip( __( 'Note: the refund reason will be visible by the customer.', 'woocommerce' ) ); ?> |
| 390 | <?php esc_html_e( 'Reason for refund (optional):', 'woocommerce' ); ?> |
| 391 | </label> |
| 392 | </td> |
| 393 | <td class="total"> |
| 394 | <input type="text" id="refund_reason" name="refund_reason" /> |
| 395 | <div class="clear"></div> |
| 396 | </td> |
| 397 | </tr> |
| 398 | </table> |
| 399 | <div class="clear"></div> |
| 400 | <div class="refund-actions"> |
| 401 | <?php |
| 402 | $refund_amount = '<span class="wc-order-refund-amount">' . wc_price( 0, array( 'currency' => $order->get_currency() ) ) . '</span>'; |
| 403 | $gateway_name = false !== $payment_gateway ? ( ! empty( $payment_gateway->method_title ) ? $payment_gateway->method_title : $payment_gateway->get_title() ) : __( 'Payment gateway', 'woocommerce' ); |
| 404 | |
| 405 | if ( false !== $payment_gateway && $payment_gateway->can_refund_order( $order ) ) { |
| 406 | /* translators: refund amount, gateway name */ |
| 407 | echo '<button type="button" class="button button-primary do-api-refund">' . sprintf( esc_html__( 'Refund %1$s via %2$s', 'woocommerce' ), wp_kses_post( $refund_amount ), esc_html( $gateway_name ) ) . '</button>'; |
| 408 | } |
| 409 | ?> |
| 410 | <?php /* translators: refund amount */ ?> |
| 411 | <button type="button" class="button button-primary do-manual-refund tips" data-tip="<?php esc_attr_e( 'You will need to manually issue a refund through your payment gateway after using this.', 'woocommerce' ); ?>"><?php printf( esc_html__( 'Refund %s manually', 'woocommerce' ), wp_kses_post( $refund_amount ) ); ?></button> |
| 412 | <button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button> |
| 413 | <input type="hidden" id="refunded_amount" name="refunded_amount" value="<?php echo esc_attr( $order->get_total_refunded() ); ?>" /> |
| 414 | <div class="clear"></div> |
| 415 | </div> |
| 416 | </div> |
| 417 | <?php endif; ?> |
| 418 | |
| 419 | <script type="text/template" id="tmpl-wc-modal-add-products"> |
| 420 | <div class="wc-backbone-modal"> |
| 421 | <div class="wc-backbone-modal-content"> |
| 422 | <section class="wc-backbone-modal-main" role="main"> |
| 423 | <header class="wc-backbone-modal-header"> |
| 424 | <h1><?php esc_html_e( 'Add products', 'woocommerce' ); ?></h1> |
| 425 | <button class="modal-close modal-close-link dashicons dashicons-no-alt"> |
| 426 | <span class="screen-reader-text">Close modal panel</span> |
| 427 | </button> |
| 428 | </header> |
| 429 | <article> |
| 430 | <form action="" method="post"> |
| 431 | <table class="widefat"> |
| 432 | <thead> |
| 433 | <tr> |
| 434 | <th><?php esc_html_e( 'Product', 'woocommerce' ); ?></th> |
| 435 | <th><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th> |
| 436 | </tr> |
| 437 | </thead> |
| 438 | <?php |
| 439 | $row = ' |
| 440 | <td><select class="wc-product-search" name="item_id" data-allow_clear="true" data-display_stock="true" data-exclude_type="variable" data-placeholder="' . esc_attr__( 'Search for a product…', 'woocommerce' ) . '"></select></td> |
| 441 | <td><input type="number" step="1" min="0" max="9999" autocomplete="off" name="item_qty" placeholder="1" size="4" class="quantity" /></td>'; |
| 442 | ?> |
| 443 | <tbody data-row="<?php echo esc_attr( $row ); ?>"> |
| 444 | <tr> |
| 445 | <?php echo $row; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 446 | </tr> |
| 447 | </tbody> |
| 448 | </table> |
| 449 | </form> |
| 450 | </article> |
| 451 | <footer> |
| 452 | <div class="wc-backbone-modal-buttons"> |
| 453 | <button id="btn-ok" class="button button-primary button-large"><?php esc_html_e( 'Add', 'woocommerce' ); ?></button> |
| 454 | </div> |
| 455 | </footer> |
| 456 | </section> |
| 457 | </div> |
| 458 | </div> |
| 459 | <div class="wc-backbone-modal-backdrop modal-close"></div> |
| 460 | </script> |
| 461 | |
| 462 | <script type="text/template" id="tmpl-wc-modal-add-tax"> |
| 463 | <div class="wc-backbone-modal"> |
| 464 | <div class="wc-backbone-modal-content"> |
| 465 | <section class="wc-backbone-modal-main" role="main"> |
| 466 | <header class="wc-backbone-modal-header"> |
| 467 | <h1><?php esc_html_e( 'Add tax', 'woocommerce' ); ?></h1> |
| 468 | <button class="modal-close modal-close-link dashicons dashicons-no-alt"> |
| 469 | <span class="screen-reader-text">Close modal panel</span> |
| 470 | </button> |
| 471 | </header> |
| 472 | <article> |
| 473 | <form action="" method="post"> |
| 474 | <table class="widefat"> |
| 475 | <thead> |
| 476 | <tr> |
| 477 | <th> </th> |
| 478 | <th><?php esc_html_e( 'Rate name', 'woocommerce' ); ?></th> |
| 479 | <th><?php esc_html_e( 'Tax class', 'woocommerce' ); ?></th> |
| 480 | <th><?php esc_html_e( 'Rate code', 'woocommerce' ); ?></th> |
| 481 | <th><?php esc_html_e( 'Rate %', 'woocommerce' ); ?></th> |
| 482 | </tr> |
| 483 | </thead> |
| 484 | <?php |
| 485 | $rates = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates ORDER BY tax_rate_name LIMIT 100" ); |
| 486 | foreach ( $rates as $rate ) { |
| 487 | echo ' |
| 488 | <tr> |
| 489 | <td><input type="radio" id="add_order_tax_' . absint( $rate->tax_rate_id ) . '" name="add_order_tax" value="' . absint( $rate->tax_rate_id ) . '" /></td> |
| 490 | <td><label for="add_order_tax_' . absint( $rate->tax_rate_id ) . '">' . esc_html( WC_Tax::get_rate_label( $rate ) ) . '</label></td> |
| 491 | <td>' . ( isset( $classes_options[ $rate->tax_rate_class ] ) ? esc_html( $classes_options[ $rate->tax_rate_class ] ) : '-' ) . '</td> |
| 492 | <td>' . esc_html( WC_Tax::get_rate_code( $rate ) ) . '</td> |
| 493 | <td>' . esc_html( WC_Tax::get_rate_percent( $rate ) ) . '</td> |
| 494 | </tr> |
| 495 | '; |
| 496 | } |
| 497 | ?> |
| 498 | </table> |
| 499 | <?php if ( absint( $wpdb->get_var( "SELECT COUNT(tax_rate_id) FROM {$wpdb->prefix}woocommerce_tax_rates;" ) ) > 100 ) : ?> |
| 500 | <p> |
| 501 | <label for="manual_tax_rate_id"><?php esc_html_e( 'Or, enter tax rate ID:', 'woocommerce' ); ?></label><br/> |
| 502 | <input type="number" name="manual_tax_rate_id" id="manual_tax_rate_id" step="1" placeholder="<?php esc_attr_e( 'Optional', 'woocommerce' ); ?>" /> |
| 503 | </p> |
| 504 | <?php endif; ?> |
| 505 | </form> |
| 506 | </article> |
| 507 | <footer> |
| 508 | <div class="wc-backbone-modal-buttons"> |
| 509 | <button id="btn-ok" class="button button-primary button-large"><?php esc_html_e( 'Add', 'woocommerce' ); ?></button> |
| 510 | </div> |
| 511 | </footer> |
| 512 | </section> |
| 513 | </div> |
| 514 | </div> |
| 515 | <div class="wc-backbone-modal-backdrop modal-close"></div> |
| 516 | </script> |
| 517 |