From bc1714a945804bc1a1274475166d3eca8a4957fc Mon Sep 17 00:00:00 2001 From: Bertrand Tourlonias Date: Fri, 26 Mar 2021 16:24:05 +0100 Subject: [PATCH] Add virtual property on cart api model --- Config/module.xml | 2 +- Model/Api/Cart.php | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Config/module.xml b/Config/module.xml index 5f2bf3d..882cac1 100644 --- a/Config/module.xml +++ b/Config/module.xml @@ -20,7 +20,7 @@ en_US fr_FR - 1.0.1 + 1.0.2 Vincent Lopes-Vicente diff --git a/Model/Api/Cart.php b/Model/Api/Cart.php index 22782ca..6907902 100644 --- a/Model/Api/Cart.php +++ b/Model/Api/Cart.php @@ -98,6 +98,14 @@ class Cart extends BaseApiModel */ protected $currency; + /** + * @var boolean + * @OA\Property( + * type="boolean" + * ) + */ + protected $virtual; + /** * @var array * @OA\Property( @@ -154,7 +162,8 @@ function ($theliaCartItem) use ($modelFactory, $deliveryCountry) { ->setCoupons($coupons) ->setTotal($theliaModel->getTaxedAmount($deliveryCountry, false, null)) ->setCurrency($theliaModel->getCurrency()->getSymbol()) - ->setItems($cartItems); + ->setItems($cartItems) + ->setVirtual($theliaModel->isVirtual()); } /** @@ -247,6 +256,24 @@ public function setDiscount($discount) return $this; } + /** + * @return boolean + */ + public function getVirtual() + { + return $this->virtual; + } + + /** + * @param boolean $virtual + * @return Cart + */ + public function setVirtual($virtual) + { + $this->virtual = $virtual; + return $this; + } + /** * @return float */ @@ -334,8 +361,7 @@ protected function getEstimatedPostageForCountry(\Thelia\Model\Cart $cart, Count $deliveryModules = ModuleQuery::create() ->filterByActivate(1) ->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL) - ->find() - ; + ->find(); $virtual = $cart->isVirtual(); $postage = null;