added new html-order-shipping.php to work in order items metabox
This commit is contained in:
parent
ef2bff285a
commit
7e17443be4
|
@ -57,7 +57,8 @@ class WC_Meta_Box_Order_Items {
|
|||
|
||||
<?php
|
||||
// List order items
|
||||
$order_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', array( 'line_item', 'fee' ) ) );
|
||||
$order_items = $order->get_items( apply_filters( 'woocommerce_admin_order_item_types', array( 'line_item', 'fee', 'shipping' ) ) );
|
||||
$shipping_methods = WC()->shipping() ? WC()->shipping->load_shipping_methods() : array();
|
||||
|
||||
foreach ( $order_items as $item_id => $item ) {
|
||||
|
||||
|
@ -67,10 +68,13 @@ class WC_Meta_Box_Order_Items {
|
|||
$item_meta = $order->get_item_meta( $item_id );
|
||||
|
||||
include( 'views/html-order-item.php' );
|
||||
break;
|
||||
break;
|
||||
case 'fee' :
|
||||
include( 'views/html-order-fee.php' );
|
||||
break;
|
||||
break;
|
||||
case 'shipping' :
|
||||
include( 'views/html-order-shipping.php' );
|
||||
break;
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_order_item_' . $item['type'] . '_html', $item_id, $item );
|
||||
|
|
|
@ -1,44 +1,74 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
?>
|
||||
<div class="total_row shipping_row" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<p class="wide">
|
||||
<input type="text" name="shipping_method_title[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="<?php _e( 'Label', 'woocommerce' ); ?>" value="<?php echo esc_attr( $shipping_title ); ?>" class="first" />
|
||||
<input type="hidden" name="shipping_method_id[<?php echo $item_id ? $item_id : 'new][]'; ?>]" value="<?php echo esc_attr( $item_id ); ?>" />
|
||||
</p>
|
||||
<p class="first">
|
||||
<select name="shipping_method[<?php echo $item_id ? $item_id : 'new][]'; ?>]" class="first">
|
||||
<optgroup label="<?php _e( 'Shipping Method', 'woocommerce' ); ?>">
|
||||
<option value=""><?php _e( 'N/A', 'woocommerce' ); ?></option>
|
||||
<?php
|
||||
$found_method = false;
|
||||
<tr class="shipping <?php echo ( ! empty( $class ) ) ? $class : ''; ?>" data-order_item_id="<?php echo $item_id; ?>">
|
||||
<td class="check-column"><input type="checkbox" /></td>
|
||||
|
||||
foreach ( $shipping_methods as $method ) {
|
||||
<td class="thumb"></td>
|
||||
|
||||
if ( strpos( $chosen_method, $method->id ) === 0 )
|
||||
$value = $chosen_method;
|
||||
else
|
||||
$value = $method->id;
|
||||
<td class="name">
|
||||
<div class="view">
|
||||
<?php echo ! empty( $item['name'] ) ? esc_html( $item['name'] ) : __( 'Shipping', 'woocommerce' ); ?>
|
||||
</div>
|
||||
<div class="edit" style="display:none">
|
||||
<input type="text" placeholder="<?php _e( 'Shipping Name', 'woocommerce' ); ?>" name="shipping_method_title[<?php echo $item_id ? $item_id : 'new][]'; ?>]" value="<?php echo ( isset( $item['name'] ) ) ? esc_attr( $item['name'] ) : ''; ?>" />
|
||||
<select name="shipping_method[<?php echo $item_id ? $item_id : 'new][]'; ?>]">
|
||||
<optgroup label="<?php _e( 'Shipping Method', 'woocommerce' ); ?>">
|
||||
<option value=""><?php _e( 'N/A', 'woocommerce' ); ?></option>
|
||||
<?php
|
||||
$found_method = false;
|
||||
|
||||
echo '<option value="' . esc_attr( $value ) . '" ' . selected( $chosen_method == $value, true, false ) . '>' . esc_html( $method->get_title() ) . '</option>';
|
||||
foreach ( $shipping_methods as $method ) {
|
||||
|
||||
if ( $chosen_method == $value )
|
||||
$found_method = true;
|
||||
}
|
||||
$current_method = ( 0 === strpos( $item['method_id'], $method->id ) ) ? $item['method_id'] : $method->id;
|
||||
|
||||
if ( ! $found_method && ! empty( $chosen_method ) ) {
|
||||
echo '<option value="' . esc_attr( $chosen_method ) . '" selected="selected">' . __( 'Other', 'woocommerce' ) . '</option>';
|
||||
} else {
|
||||
echo '<option value="other">' . __( 'Other', 'woocommerce' ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</optgroup>
|
||||
</select>
|
||||
</p>
|
||||
<p class="last">
|
||||
<input type="text" class="shipping_cost wc_input_price" name="shipping_cost[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo esc_attr( wc_format_localized_price( $shipping_cost ) ); ?>" />
|
||||
</p>
|
||||
<?php do_action( 'woocommerce_admin_order_totals_after_shipping_item', $item_id ); ?>
|
||||
<a href="#" class="delete_total_row">×</a>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
echo '<option value="' . esc_attr( $current_method ) . '" ' . selected( $item['method_id'] == $current_method, true, false ) . '>' . esc_html( $method->get_title() ) . '</option>';
|
||||
|
||||
if ( $item['method_id'] == $current_method ) {
|
||||
$found_method = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $found_method && ! empty( $item['method_id'] ) ) {
|
||||
echo '<option value="' . esc_attr( $item['method_id'] ) . '" selected="selected">' . __( 'Other', 'woocommerce' ) . '</option>';
|
||||
} else {
|
||||
echo '<option value="other">' . __( 'Other', 'woocommerce' ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</optgroup>
|
||||
</select>
|
||||
<input type="hidden" name="shipping_method_id[<?php echo $item_id ? $item_id : 'new][]'; ?>]" value="<?php echo esc_attr( $item_id ); ?>" />
|
||||
</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 ( isset( $item['cost'] ) ) ? wc_price( wc_round_tax_total( $item['cost'] ) ) : ''; ?>
|
||||
</div>
|
||||
<div class="edit" style="display:none">
|
||||
<label><?php _e( 'Total', 'woocommerce' ); ?>: <input type="text" name="shipping_cost[<?php echo $item_id ? $item_id : 'new][]'; ?>]" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo ( isset( $item['cost'] ) ) ? esc_attr( wc_format_localized_price( $item['cost'] ) ) : ''; ?>" class="line_total wc_input_price" /></label>
|
||||
</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">
|
||||
<div class="wc-order-edit-line-item-actions">
|
||||
<a class="edit_order_item" href="#"></a><a class="delete_order_item" href="#"></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue