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:
Gerhard Potgieter 2019-07-04 09:25:49 +02:00 committed by GitHub
commit c3a25bb6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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;

View File

@ -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 );