/** * Adds line items to the request * * @since 2.0.0 * @return array */ protected function get_line_items() { $line_items = array(); // order line items foreach (SV_WC_Helper::get_order_line_items($this->order) as $item) { if ($item->item_total >= 0) { $line_items[] = array('itemId' => SV_WC_Helper::str_truncate($item->id, 31), 'name' => SV_WC_Helper::str_to_sane_utf8(SV_WC_Helper::str_truncate($item->name, 31)), 'description' => SV_WC_Helper::str_to_sane_utf8(SV_WC_Helper::str_truncate($item->description, 255)), 'quantity' => $item->quantity, 'unitPrice' => SV_WC_Helper::number_format($item->item_total)); } } // order fees foreach ($this->order->get_fees() as $fee_id => $fee) { if ($this->order->get_item_total($fee) >= 0) { $line_items[] = array('itemId' => SV_WC_Helper::str_truncate($fee_id, 31), 'name' => SV_WC_Helper::str_truncate(htmlentities($fee['name'], ENT_QUOTES, 'UTF-8', false), 31), 'description' => __('Order Fee', 'woocommerce-gateway-authorize-net-cim'), 'quantity' => 1, 'unitPrice' => SV_WC_Helper::number_format($this->order->get_item_total($fee))); } } // maximum of 30 line items per order if (count($line_items) > 30) { $line_items = array_slice($line_items, 0, 30); } return $line_items; }