You are here

function uc_discounts_get_order_discount_line_items in Ubercart Discounts (Alternative) 7.2

Returns existing discounts line items for order.

Parameters

object $order:

Return value

array Array of ubercart order line items.

1 call to uc_discounts_get_order_discount_line_items()
uc_discounts_apply in uc_discounts/uc_discounts.module
Applies the discounts to an order by creating the necessary line items.

File

uc_discounts/uc_discounts.module, line 2328

Code

function uc_discounts_get_order_discount_line_items($order) {
  if (is_array($order->line_items)) {
    $existing_line_items = $order->line_items;
  }
  else {
    $existing_line_items = uc_order_load_line_items($order, TRUE);
  }
  $line_items = array();
  foreach ($existing_line_items as $line_item) {

    // If line item type is UC_DISCOUNTS_LINE_ITEM_TYPE then add it to array.
    if ($line_item["type"] == UC_DISCOUNTS_LINE_ITEM_TYPE) {
      $line_items[] = $line_item;
    }
  }
  return $line_items;
}