moved the coupons to order items metabox
This commit is contained in:
parent
f0bf3e9e7e
commit
0a71c4498d
|
@ -57,7 +57,7 @@ class WC_Meta_Box_Order_Items {
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// List order items
|
// List order items
|
||||||
$order_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', array( 'line_item', 'fee', 'shipping' ) ) );
|
$order_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', array( 'line_item', 'fee', 'shipping', 'coupon' ) ) );
|
||||||
$shipping_methods = WC()->shipping() ? WC()->shipping->load_shipping_methods() : array();
|
$shipping_methods = WC()->shipping() ? WC()->shipping->load_shipping_methods() : array();
|
||||||
|
|
||||||
foreach ( $order_items as $item_id => $item ) {
|
foreach ( $order_items as $item_id => $item ) {
|
||||||
|
@ -75,6 +75,9 @@ class WC_Meta_Box_Order_Items {
|
||||||
case 'shipping' :
|
case 'shipping' :
|
||||||
include( 'views/html-order-shipping.php' );
|
include( 'views/html-order-shipping.php' );
|
||||||
break;
|
break;
|
||||||
|
case 'coupon' :
|
||||||
|
include( 'views/html-order-coupon.php' );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_action( 'woocommerce_order_item_' . $item['type'] . '_html', $item_id, $item );
|
do_action( 'woocommerce_order_item_' . $item['type'] . '_html', $item_id, $item );
|
||||||
|
@ -105,7 +108,7 @@ class WC_Meta_Box_Order_Items {
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span class="label"><?php _e( 'Order Total', 'woocommerce' ); ?>:</span>
|
<span class="label"><?php _e( 'Order Total', 'woocommerce' ); ?>:</span>
|
||||||
<span class="total">-<?php echo wc_price( $order->get_total() ); ?></span>
|
<span class="total"><?php echo wc_price( $order->get_total() ); ?></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -83,25 +83,6 @@ class WC_Meta_Box_Order_Totals {
|
||||||
?>" />
|
?>" />
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$coupons = $order->get_items( array( 'coupon' ) );
|
|
||||||
|
|
||||||
if ( $coupons ) {
|
|
||||||
?>
|
|
||||||
<div class="totals_group">
|
|
||||||
<ul class="wc_coupon_list"><?php
|
|
||||||
foreach ( $coupons as $item_id => $item ) {
|
|
||||||
|
|
||||||
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item['name'] ) );
|
|
||||||
|
|
||||||
$link = $post_id ? add_query_arg( array( 'post' => $post_id, 'action' => 'edit' ), admin_url( 'post.php' ) ) : add_query_arg( array( 's' => $item['name'], 'post_status' => 'all', 'post_type' => 'shop_coupon' ), admin_url( 'edit.php' ) );
|
|
||||||
|
|
||||||
echo '<li class="tips code" data-tip="' . esc_attr( wc_price( $item['discount_amount'] ) ) . '"><a href="' . esc_url( $link ) . '"><span>' . esc_html( $item['name'] ). '</span></a></li>';
|
|
||||||
}
|
|
||||||
?></ul>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $refunds = $order->get_refunds() ) {
|
if ( $refunds = $order->get_refunds() ) {
|
||||||
?>
|
?>
|
||||||
<div class="totals_group">
|
<div class="totals_group">
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<tr class="shipping <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_item_id="<?php echo $item_id; ?>">
|
||||||
|
<td class="check-column"></td>
|
||||||
|
|
||||||
|
<td class="thumb"></td>
|
||||||
|
|
||||||
|
<td class="name">
|
||||||
|
<div class="view">
|
||||||
|
<?php
|
||||||
|
$coupon_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item['name'] ) );
|
||||||
|
|
||||||
|
$coupon_url = $coupon_id ? add_query_arg( array( 'post' => $coupon_id, 'action' => 'edit' ), admin_url( 'post.php' ) ) : add_query_arg( array( 's' => $item['name'], 'post_status' => 'all', 'post_type' => 'shop_coupon' ), admin_url( 'edit.php' ) );
|
||||||
|
|
||||||
|
echo '<a href="' . esc_url( $coupon_url ) . '"><span>' . esc_html( $item['name'] ). '</span></a>';
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<?php if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) : ?>
|
||||||
|
|
||||||
|
<td class="tax_class" width="1%"></td>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<td class="quantity" width="1%">1</td>
|
||||||
|
|
||||||
|
<td class="line_cost" width="1%">
|
||||||
|
<div class="view">
|
||||||
|
<?php echo wc_price( $item['discount_amount'] ); ?>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<?php if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) : ?>
|
||||||
|
|
||||||
|
<td class="line_tax" width="1%"></td>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<td class="wc-order-edit-line-item"></td>
|
||||||
|
</tr>
|
Loading…
Reference in New Issue