diff --git a/README.md b/README.md index 1acb494..bc69ab3 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Create an Order $order = new \API2Client\Entities\Order (); $order->setProjectId (0); -$order->setAmount (144); +$order->setAmount (174); $order->setBonusesAmount (0); $billingInfo = new \API2Client\Entities\Order\BillingInfo (); @@ -131,10 +131,11 @@ $order->addProductInfo ($productInfo2); $externalProduct = new \API2Client\Entities\Order\ProductInfo (); -$externalProduct->setProductId (0); -$externalProduct->setPrice (33); -$externalProduct->setName ('Headspace Journey Subscription'); -$externalProduct->setType ('external'); +$externalProduct->setProductId (0); +$externalProduct->setPrice (33); +$externalProduct->setFinalPrice (30); +$externalProduct->setName ('Headspace Journey Subscription'); +$externalProduct->setType ('external'); $order->addProductInfo ($externalProduct); diff --git a/src/API2Client/Entities/Order/ProductInfo.php b/src/API2Client/Entities/Order/ProductInfo.php index cbcf58c..191188a 100644 --- a/src/API2Client/Entities/Order/ProductInfo.php +++ b/src/API2Client/Entities/Order/ProductInfo.php @@ -24,6 +24,11 @@ class ProductInfo */ protected $price; + /** + * @var float + */ + protected $finalPrice; + /** @var boolean */ protected $exclusive; @@ -84,6 +89,22 @@ public function getAdditionalInfo () return $this->additionalInfo; } + /** + * @param float $finalPrice + */ + public function setFinalPrice ($finalPrice) + { + $this->finalPrice = $finalPrice; + } + + /** + * @return float + */ + public function getFinalPrice () + { + return $this->finalPrice != null ? $this->finalPrice : $this->getPrice() ; + } + /** * @param float $price */ @@ -195,6 +216,7 @@ public function toArray () 'discountCodeList' => $this->getDiscountCodeList (), 'name' => $this->getName (), 'price' => $this->getPrice (), + 'finalPrice' => $this->getFinalPrice (), 'productId' => $this->getProductId () ? $this->getProductId () : 0, 'type' => $this->getType (), ); diff --git a/src/API2Client/Setters/OrderItemFactory.php b/src/API2Client/Setters/OrderItemFactory.php index e7c5816..7e33a86 100644 --- a/src/API2Client/Setters/OrderItemFactory.php +++ b/src/API2Client/Setters/OrderItemFactory.php @@ -38,6 +38,7 @@ public function create ($data) $productInfo = new ProductInfo (); $productInfo->setName ($this->getValue ('name', $product, '')); $productInfo->setPrice ($this->getValue ('price', $product, 0)); + $productInfo->setFinalPrice ($this->getValue ('finalPrice', $product)); $productInfo->setProductId ($this->getValue ('productId', $product, 0)); $productInfo->setType ($this->getValue ('type', $product, ''));