Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Adds ability to attach items to a purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 26, 2016
1 parent a276659 commit 9fdb5ca
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,19 @@ protected function append(array $params, SimpleXMLElement $type)
{
foreach ($params as $key => $value) {
if (is_array($value)) {
$parent = $type->addChild($key);
if ($key === 'items') {
foreach ($value as $item) {
$parent = $type->addChild('item');
$parent->addChild('name', isset($item['name']) ? $item['name'] : '');
$parent->addChild('quantity', isset($item['quantity']) ? $item['quantity'] : '');
$parent->addChild('product_code', isset($item['product_code']) ? $item['product_code'] : '');
$parent->addChild('extended_amount', isset($item['extended_amount']) ? $item['extended_amount'] : '');
}
} else {
$parent = $type->addChild($key);

$this->append($value, $parent);
$this->append($value, $parent);
}
} else {
$type->addChild($key, $value);
}
Expand Down

0 comments on commit 9fdb5ca

Please sign in to comment.