Skip to content

Commit

Permalink
Add virtual property on cart api model
Browse files Browse the repository at this point in the history
  • Loading branch information
zawaze committed Mar 26, 2021
1 parent 60a263c commit bc1714a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.0.1</version>
<version>1.0.2</version>
<authors>
<author>
<name>Vincent Lopes-Vicente</name>
Expand Down
32 changes: 29 additions & 3 deletions Model/Api/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ class Cart extends BaseApiModel
*/
protected $currency;

/**
* @var boolean
* @OA\Property(
* type="boolean"
* )
*/
protected $virtual;

/**
* @var array
* @OA\Property(
Expand Down Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bc1714a

Please sign in to comment.