From d3b9efcc05545979113087fa68fceacb22d8e73d Mon Sep 17 00:00:00 2001 From: Bastien Tafforeau Date: Fri, 24 Nov 2023 16:00:51 +0100 Subject: [PATCH] Adding Product class --- src/Category/Category.php | 8 ++ src/Product/Exception/ProductException.php | 28 +++++ src/Product/Product.php | 126 +++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 src/Category/Category.php create mode 100644 src/Product/Exception/ProductException.php create mode 100644 src/Product/Product.php diff --git a/src/Category/Category.php b/src/Category/Category.php new file mode 100644 index 000000000..87c2620a4 --- /dev/null +++ b/src/Category/Category.php @@ -0,0 +1,8 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\Product\Exception; + +use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException; + +class ProductException extends PsCheckoutException +{ + +} diff --git a/src/Product/Product.php b/src/Product/Product.php new file mode 100644 index 000000000..1136e445c --- /dev/null +++ b/src/Product/Product.php @@ -0,0 +1,126 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\Product; + +use PrestaShop\Module\PrestashopCheckout\Amount\Amount; + +class Product +{ + /** @var string */ + private $name; + + /** @var Amount */ + private $unitPrice; + + /** @var int */ + private $quantity; + + /** @var boolean */ + private $isInStock; + + /** @var boolean */ + private $isAvailableForOrder; + + /** @var string */ + private $sku; + + /** @var string */ + private $category; + + /** @var Amount */ + private $tax; + + public function __construct($name, $unitPrice, $quantity, $isInStock, $isAvailableForOrder, $sku = '', $category = '', $tax = null) + { + $this->name = $name; + $this->unitPrice = $unitPrice; + $this->quantity = $quantity; + $this->isInStock = $isInStock; + $this->isAvailableForOrder = $isAvailableForOrder; + $this->sku = $sku; + $this->category = $category; + $this->tax = $tax; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return Amount + */ + public function getUnitPrice() + { + return $this->unitPrice; + } + + /** + * @return string + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * @return bool + */ + public function isInStock() + { + return $this->isInStock; + } + + /** + * @return bool + */ + public function isAvailableForOrder() + { + return $this->isAvailableForOrder; + } + + /** + * @return string + */ + public function getSku() + { + return $this->sku; + } + + /** + * @return string + */ + public function getCategory() + { + return $this->category; + } + + /** + * @return Amount + */ + public function getTax() + { + return $this->tax; + } +}