Index: uc_order/uc_order.order_pane.inc =================================================================== --- uc_order/uc_order.order_pane.inc (revision 96) +++ uc_order/uc_order.order_pane.inc (working copy) @@ -490,8 +490,12 @@ } } } - if (intval($arg1['li_delete_id']) > 0) { + if (intval($arg1['li_delete_id']) > 0) { + $line_item = uc_order_get_line_item($arg1['li_delete_id']); uc_order_delete_line_item($arg1['li_delete_id']); + if($line_item->type == 'tax'){ + variable_set('uc_tax_disabled_order_' . $line_item->order_id, TRUE); + } drupal_set_message(t('Line item removed.')); } return; Index: uc_order/uc_order.line_item.inc =================================================================== --- uc_order/uc_order.line_item.inc (revision 96) +++ uc_order/uc_order.line_item.inc (working copy) @@ -137,6 +137,14 @@ } /** + * Return line item by ID + */ +function uc_order_get_line_item($id){ + $result = db_query("SELECT * FROM {uc_order_line_items} WHERE line_item_id = %d", $id); + return db_fetch_object($result); +} + +/** * Add a line item to an order. */ function uc_order_line_item_add($order_id, $type, $title, $amount, $weight = NULL, $data = NULL) { Index: uc_taxes/uc_taxes.module =================================================================== --- uc_taxes/uc_taxes.module (revision 96) +++ uc_taxes/uc_taxes.module (working copy) @@ -159,54 +159,56 @@ function uc_taxes_order($op, $arg1, $arg2) { switch ($op) { case 'save': - $changes = array(); - $callback = _line_item_data('tax', 'callback'); - $line_items = $callback('load', $arg1); - $context = array( - 'revision' => 'formatted', - 'type' => 'line_item', - 'subject' => array( - 'order' => $arg1, - ), - ); - if (is_array($arg1->line_items)) { - //drupal_set_message('
'. var_export($arg1->line_items, TRUE) .'
'); - foreach ($arg1->line_items as $i => $line) { - if ($line['type'] == 'tax') { - $delete = TRUE; - foreach ($line_items as $id => $new_line) { - if ($new_line['title'] == $line['title']) { - if ($new_line['amount'] != $line['amount']) { - $context['subject']['line_item'] = $new_line; - uc_order_update_line_item($line['line_item_id'], $new_line['title'], $new_line['amount'], $new_line['data']); - $arg1->line_items[$i]['amount'] = $new_line['amount']; - $changes[] = t('Changed %title to %amount.', array('%amount' => uc_price($new_line['amount'], $context), '%title' => $new_line['title'])); + if(!variable_get('uc_tax_disabled_order_' . $arg1->order_id, FALSE)){ + $changes = array(); + $callback = _line_item_data('tax', 'callback'); + $line_items = $callback('load', $arg1); + $context = array( + 'revision' => 'formatted', + 'type' => 'line_item', + 'subject' => array( + 'order' => $arg1, + ), + ); + if (is_array($arg1->line_items)) { + //drupal_set_message('
'. var_export($arg1->line_items, TRUE) .'
'); + foreach ($arg1->line_items as $i => $line) { + if ($line['type'] == 'tax') { + $delete = TRUE; + foreach ($line_items as $id => $new_line) { + if ($new_line['title'] == $line['title']) { + if ($new_line['amount'] != $line['amount']) { + $context['subject']['line_item'] = $new_line; + uc_order_update_line_item($line['line_item_id'], $new_line['title'], $new_line['amount'], $new_line['data']); + $arg1->line_items[$i]['amount'] = $new_line['amount']; + $changes[] = t('Changed %title to %amount.', array('%amount' => uc_price($new_line['amount'], $context), '%title' => $new_line['title'])); + } + unset($line_items[$id]); + $delete = FALSE; + break; } - unset($line_items[$id]); - $delete = FALSE; - break; } + if ($delete) { + uc_order_delete_line_item($line['line_item_id']); + unset($arg1->line_items[$i]); + $changes[] = t('Removed %title.', array('%title' => $line['title'])); + } } - if ($delete) { - uc_order_delete_line_item($line['line_item_id']); - unset($arg1->line_items[$i]); - $changes[] = t('Removed %title.', array('%title' => $line['title'])); - } } } - } - if (is_array($line_items)) { - foreach ($line_items as $line) { - uc_order_line_item_add($arg1->order_id, $line['id'], $line['title'], $line['amount'], $line['weight'], $line['data']); - $line['type'] = 'tax'; - $arg1->line_items[] = $line; - $context['subject']['line_item'] = $line; - $changes[] = t('Added %amount for %title.', array('%amount' => uc_price($line['amount'], $context), '%title' => $line['title'])); + if (is_array($line_items)) { + foreach ($line_items as $line) { + uc_order_line_item_add($arg1->order_id, $line['id'], $line['title'], $line['amount'], $line['weight'], $line['data']); + $line['type'] = 'tax'; + $arg1->line_items[] = $line; + $context['subject']['line_item'] = $line; + $changes[] = t('Added %amount for %title.', array('%amount' => uc_price($line['amount'], $context), '%title' => $line['title'])); + } } + if (count($changes)) { + uc_order_log_changes($arg1->order_id, $changes); + } } - if (count($changes)) { - uc_order_log_changes($arg1->order_id, $changes); - } break; } }