Skip to content

Commit

Permalink
Issue #27 Support XML basket discounts (fix to XML order).
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Oct 10, 2015
1 parent dda37c0 commit de84b90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Academe/SagePay/Model/BasketAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ public function toArray()
$structure = array_merge($structure, $this->delivery);
}

// Optional discounts.
if ( ! empty($this->discounts)) {
$structure = array_merge($structure, array('discounts' => $this->discounts));
}

// Shipping details.
if (isset($this->shipping)) {
$structure = array_merge($structure, $this->shipping);
Expand All @@ -228,10 +233,6 @@ public function toArray()
$structure = array_merge($structure, array('hotel' => $this->hotel));
}

if ( ! empty($this->discounts)) {
$structure = array_merge($structure, array('discounts' => $this->discounts));
}

return $structure;
}

Expand Down
1 change: 1 addition & 0 deletions src/Academe/SagePay/Model/XmlAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected function xmlFragment($data)
foreach($data as $key => $value) {
// Skip a level for numeric keys. They are just so we can have a list
// of itentical tags together on the same level.
// So [['key'=>'v1'], ['key'=>'v2']] will give is "<key>v1</key><key>v2</key>"
if (is_numeric($key)) {
$fragment .= $this->xmlFragment($value);
} else {
Expand Down

0 comments on commit de84b90

Please sign in to comment.