Merge pull request #23884 from woocommerce/fix/23875
Prevents taxes columns from being removed when the order is no longer editable
This commit is contained in:
commit
c3a25bb6bf
|
@ -43,7 +43,9 @@ if ( wc_tax_enabled() ) {
|
|||
<th class="line_tax tips" data-tip="<?php echo esc_attr( $column_tip ); ?>">
|
||||
<?php echo esc_attr( $column_label ); ?>
|
||||
<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'] ); ?>">
|
||||
<a class="delete-order-tax" href="#" data-rate_id="<?php echo esc_attr( $tax_id ); ?>"></a>
|
||||
<?php if ( $order->is_editable() ) : ?>
|
||||
<a class="delete-order-tax" href="#" data-rate_id="<?php echo esc_attr( $tax_id ); ?>"></a>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<?php
|
||||
endforeach;
|
||||
|
|
|
@ -1322,8 +1322,14 @@ class WC_AJAX {
|
|||
$order_id = absint( $_POST['order_id'] );
|
||||
$rate_id = absint( $_POST['rate_id'] );
|
||||
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( ! $order->is_editable() ) {
|
||||
throw new Exception( __( 'Order not editable', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
wc_delete_order_item( $rate_id );
|
||||
|
||||
// Need to load order again after deleting to have latest items before calculating.
|
||||
$order = wc_get_order( $order_id );
|
||||
$order->calculate_totals( false );
|
||||
|
||||
|
|
Loading…
Reference in New Issue