This snippet from upcoming 2.0 code may help meet the need you're working on ...
Code:
// itemized contents
$itemizedItemsArray = array();
reset($this->order->products);
for ($i = 0, $n = sizeof($this->order->products); $i < $n && $i < 30; $i ++)
{
$lineItem = $this->order->products[$i]['id'] . '<|>';
$lineItem .= substr(htmlentities($this->order->products[$i]['name'], ENT_QUOTES, 'UTF-8'), 0, 30) . '<|>';
if (isset($this->order->products[$i]['attributes']))
{
$attribs = ' (';
for ($j = 0, $m = sizeof($this->order->products[$i]['attributes']); $j < $m; $j ++)
{
$attribs .= $this->order->products[$i]['attributes'][$j]['option'] . ' - ' . $this->order->products[$i]['attributes'][$j]['value'] . '; ';
}
$attribs .= ')';
}
$lineItem .= substr(htmlentities($this->order->products[$i]['description'] . $attribs, ENT_QUOTES, 'UTF-8'), 0, 255) . '<|>';
$lineItem .= $this->order->products[$i]['qty'] . '<|>';
$lineItem .= number_format($this->order->products[$i]['final_price'], 2, '.', '') . '<|>';
$lineItem .= 'Y';
$itemizedItemsArray[] = $lineItem;
// track one-time charges
if ($this->order->products[$i]['onetime_charges'] != 0)
{
$itemizedItemsArray[] = 'OTC' . '<|>' . 'One Time Charges' . '<|>' . '(One Time Charges related to ' . substr(htmlentities($this->order->products[$i]['name'], ENT_QUOTES, 'UTF-8'), 0, 200) . ')' . '<|>' . '1' . '<|>' . number_format($this->order->products[$i]['onetime_charges'], 2, '.', '') . '<|>' . 'Y';
}
}
$submit_data['x_line_item'] = $itemizedItemsArray;
(You'll have to edit the above and change all the $this->order references to just $order or else it won't work in your current version.)
Bookmarks