From 30acd63fec2140f9234e4d2772a2c246e9e68283 Mon Sep 17 00:00:00 2001 From: MarioShatterhand Date: Thu, 17 Mar 2022 21:27:42 +0100 Subject: [PATCH] Adding SupplierPartAuxilaryId and option to change operationAllowed (#2) * Add support for SupplierPartAuxiliaryID * Add option to change operationAllowed Attribute * Add default value for operationAllowed Co-authored-by: mpierzchala --- src/CXml/Models/Messages/ItemIn.php | 28 +++++++++++++++++++ .../Messages/PunchOutOrderMessageHeader.php | 13 +++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/CXml/Models/Messages/ItemIn.php b/src/CXml/Models/Messages/ItemIn.php index 0cdc40a..8e6b184 100644 --- a/src/CXml/Models/Messages/ItemIn.php +++ b/src/CXml/Models/Messages/ItemIn.php @@ -10,6 +10,11 @@ class ItemIn /** @var string Product SKU */ private $supplierPartId; + /** + * @var string Id to enable order / cart restore + */ + private $supplierPartAuxiliaryID; + /** @var float */ private $unitPrice; @@ -56,6 +61,25 @@ public function setSupplierPartId(string $supplierPartId): self return $this; } + /** + * @return string + */ + public function getSupplierPartAuxiliaryID(): string + { + return $this->supplierPartAuxiliaryID; + } + + /** + * @param string $supplierPartAuxiliaryID + * + * @return ItemIn + */ + public function setSupplierPartAuxiliaryID(string $supplierPartAuxiliaryID): self + { + $this->supplierPartAuxiliaryID = $supplierPartAuxiliaryID; + return $this; + } + public function getUnitPrice(): float { return $this->unitPrice; @@ -142,6 +166,10 @@ public function render(\SimpleXMLElement $parentNode, string $currency, string $ $itemIdNode = $node->addChild('ItemID'); $itemIdNode->addChild('SupplierPartID', $this->supplierPartId); + if ($this->supplierPartAuxiliaryID) { + $itemIdNode->addChild('SupplierPartAuxiliaryID', htmlspecialchars($this->supplierPartAuxiliaryID, ENT_XML1 | ENT_COMPAT, 'UTF-8')); + } + // ItemDetails $itemDetailsNode = $node->addChild('ItemDetail'); diff --git a/src/CXml/Models/Messages/PunchOutOrderMessageHeader.php b/src/CXml/Models/Messages/PunchOutOrderMessageHeader.php index 585ee80..1ba6683 100644 --- a/src/CXml/Models/Messages/PunchOutOrderMessageHeader.php +++ b/src/CXml/Models/Messages/PunchOutOrderMessageHeader.php @@ -21,6 +21,9 @@ class PunchOutOrderMessageHeader /** @var string */ private $taxDescription; + /** @var string */ + private $operationAllowed = "create"; + public function getTotalAmount(): float { return $this->totalAmount; @@ -76,10 +79,16 @@ public function setTaxDescription(string $taxDescription): self return $this; } + public function setOperationAllowed(string $operation): self + { + $this->operationAllowed = $operation; + return $this; + } + public function render(\SimpleXMLElement $parentNode, string $currency, string $locale): void { $node = $parentNode->addChild('PunchOutOrderMessageHeader'); - $node->addAttribute('operationAllowed', 'create'); + $node->addAttribute('operationAllowed', $this->operationAllowed); // Total $this->addPriceNode($node, 'Total', $currency, $this->totalAmount); @@ -109,4 +118,4 @@ private function addPriceNode(\SimpleXMLElement $parentNode, string $name, strin ->addAttribute('xml:xml:lang', $locale); } } -} +} \ No newline at end of file