Move filter at the top of the template

This commit is contained in:
xristos3490 2022-02-16 21:56:24 +02:00
parent 741f5015e0
commit 45b9eebcda
2 changed files with 13 additions and 13 deletions

View File

@ -38,17 +38,6 @@ class WC_Meta_Box_Order_Items {
$order = $theorder;
$data = get_post_meta( $post->ID );
/**
* Allow plugins to determine whether refunds UI should be rendered in the template.
*
* @since 6.3.0
*
* @param $order_id The Order ID.
* @param $order The Order object.
* @return bool
*/
$should_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 );
include __DIR__ . '/views/html-order-items.php';
}

View File

@ -7,6 +7,17 @@
defined( 'ABSPATH' ) || exit;
/**
* Allow plugins to determine whether refunds UI should be rendered in the template.
*
* @since 6.3.0
*
* @param $order_id The Order ID.
* @param $order The Order object.
* @return bool
*/
$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 );
global $wpdb;
$payment_gateway = wc_get_payment_gateway_by_order( $order );
@ -282,7 +293,7 @@ if ( wc_tax_enabled() ) {
<?php else : ?>
<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>
<?php endif; ?>
<?php if ( $should_render_refunds ) : ?>
<?php if ( $render_refunds ) : ?>
<button type="button" class="button refund-items"><?php esc_html_e( 'Refund', 'woocommerce' ); ?></button>
<?php endif; ?>
<?php
@ -308,7 +319,7 @@ if ( wc_tax_enabled() ) {
<button type="button" class="button cancel-action"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button>
<button type="button" class="button button-primary save-action"><?php esc_html_e( 'Save', 'woocommerce' ); ?></button>
</div>
<?php if ( $should_render_refunds ) : ?>
<?php if ( $render_refunds ) : ?>
<div class="wc-order-data-row wc-order-refund-items wc-order-data-row-toggle" style="display: none;">
<table class="wc-order-totals">
<?php if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) : ?>