Skip to content

Commit e9bd8f1

Browse files
committed
feat: Modify Item class to support multiple classified tax categories and improve XML serialization
1 parent e3c3358 commit e9bd8f1

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Item.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class Item implements XmlSerializable
2727
/** @var string|null Sellers item identification. */
2828
private ?string $sellersItemIdentification = null;
2929

30-
/** @var ClassifiedTaxCategory|null Classified tax category. */
31-
private ?ClassifiedTaxCategory $classifiedTaxCategory = null;
30+
/** @var array|null Classified tax category. */
31+
private ?array $classifiedTaxCategory = [];
3232

3333
/**
3434
* Set the item description.
@@ -159,10 +159,10 @@ public function getSellersItemIdentification(): ?string
159159
/**
160160
* Set the classified tax category.
161161
*
162-
* @param ClassifiedTaxCategory|null $classifiedTaxCategory
162+
* @param array|null $classifiedTaxCategory
163163
* @return self
164164
*/
165-
public function setClassifiedTaxCategory(?ClassifiedTaxCategory $classifiedTaxCategory): self
165+
public function setClassifiedTaxCategory(?array $classifiedTaxCategory): self
166166
{
167167
$this->classifiedTaxCategory = $classifiedTaxCategory;
168168
return $this;
@@ -171,9 +171,9 @@ public function setClassifiedTaxCategory(?ClassifiedTaxCategory $classifiedTaxCa
171171
/**
172172
* Get the classified tax category.
173173
*
174-
* @return ClassifiedTaxCategory|null
174+
* @return array|null
175175
*/
176-
public function getClassifiedTaxCategory(): ?ClassifiedTaxCategory
176+
public function getClassifiedTaxCategory(): ?array
177177
{
178178
return $this->classifiedTaxCategory;
179179
}
@@ -227,9 +227,11 @@ public function xmlSerialize(Writer $writer): void
227227

228228
// Write ClassifiedTaxCategory element if provided.
229229
if (!empty($this->classifiedTaxCategory)) {
230-
$writer->write([
231-
Schema::CAC . 'ClassifiedTaxCategory' => $this->classifiedTaxCategory,
232-
]);
230+
foreach($this->classifiedTaxCategory as $classifiedTaxCategory){
231+
$writer->write([
232+
Schema::CAC . 'ClassifiedTaxCategory' => $classifiedTaxCategory
233+
]);
234+
}
233235
}
234236
}
235237
}

0 commit comments

Comments
 (0)