Skip to content

Commit

Permalink
Adding SupplierPartAuxilaryId and option to change operationAllowed (#2)
Browse files Browse the repository at this point in the history
* Add support for SupplierPartAuxiliaryID

* Add option to change operationAllowed Attribute

* Add default value for operationAllowed

Co-authored-by: mpierzchala <m.pierzchala@pureinteractive.pl>
  • Loading branch information
MarioShatterhand and mpierzchala committed Mar 17, 2022
1 parent b126147 commit 30acd63
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/CXml/Models/Messages/ItemIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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');

Expand Down
13 changes: 11 additions & 2 deletions src/CXml/Models/Messages/PunchOutOrderMessageHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class PunchOutOrderMessageHeader
/** @var string */
private $taxDescription;

/** @var string */
private $operationAllowed = "create";

public function getTotalAmount(): float
{
return $this->totalAmount;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -109,4 +118,4 @@ private function addPriceNode(\SimpleXMLElement $parentNode, string $name, strin
->addAttribute('xml:xml:lang', $locale);
}
}
}
}

0 comments on commit 30acd63

Please sign in to comment.