Skip to content

Commit

Permalink
Issue backdrop-contrib#19: Fix line_item_id warnings and double-disco…
Browse files Browse the repository at this point in the history
…unt.
  • Loading branch information
bugfolder committed Sep 9, 2023
1 parent 16af252 commit 84b0d02
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions uc_discounts.module
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,24 @@ function uc_discounts_uc_order($op, $order, $arg2) {
// - Storing new discount line items.
$new_order_line_items = array();

// Delete existing discount line items.
// Delete existing discount line items from the db.
foreach ($existing_line_items as $line_item) {
if ($line_item["type"] == UC_DISCOUNTS_LINE_ITEM_TYPE) {
uc_order_delete_line_item($line_item["line_item_id"]);
if (isset($line_item["line_item_id"])) {
uc_order_delete_line_item($line_item["line_item_id"]);
}
}
// Otherwise store non-discount line item.
// Otherwise keep non-discount line item.
else {
$new_order_line_items[] = $line_item;
}
}

// Add discount line items.
// Add discount line items and store them in the db.
if (!empty($order->uc_discounts_line_items)) {
foreach ($order->uc_discounts_line_items as $line_item) {
if ($line_item['amount'] != 0) {
uc_order_line_item_add($order->order_id, $line_item['type'], $line_item['title'], $line_item['amount'], $line_item['weight'], $line_item['data']);
$line_item = uc_order_line_item_add($order->order_id, $line_item['type'], $line_item['title'], $line_item['amount'], $line_item['weight'], $line_item['data']);
$new_order_line_items[] = $line_item;
}
}
Expand Down

0 comments on commit 84b0d02

Please sign in to comment.