Skip to content

Commit

Permalink
adding calculated information (#92)
Browse files Browse the repository at this point in the history
Co-authored-by: ArthurLashermes <alashermes@openstudio.fr>
  • Loading branch information
ArthurLashermes and ArthurLashermes authored Jul 24, 2024
1 parent 5897230 commit a090180
Showing 1 changed file with 169 additions and 0 deletions.
169 changes: 169 additions & 0 deletions Model/Api/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,77 @@ class CartItem extends BaseApiModel
*/
protected $quantity;

/**
* @var float
* @OA\Property(
* type="number",
* format="float",
* )
*/
protected $calculatedTotalPrice;

/**
* @var float
* @OA\Property(
* type="number",
* format="float",
* )
*/
protected $calculatedTotalPromoPrice;

/**
* @var float
* @OA\Property(
* type="number",
* format="float",
* )
*/
protected $calculatedTotalTaxedPrice;

/**
* @var float
* @OA\Property(
* type="number",
* format="float",
* )
*/
protected $calculatedTotalPromoTaxedPrice;

/**
* @var float
* @OA\Property(
* type="number",
* format="float",
* )
*/
protected $calculatedRealPrice;

/**
* @var float
* @OA\Property(
* type="number",
* format="float",
* )
*/
protected $calculatedRealTaxedPrice;

/**
* @var float
* @OA\Property(
* type="number",
* format="float",
* )
*/
protected $calculatedRealTotalPrice;

/**
* @var float
* @OA\Property(
* type="number",
* format="float",
* )
*/
protected $calculatedRealTotalTaxedPrice;
/**
* Create a new OpenApi CartItem from a Thelia CartItem and a Country, then returns it.
*
Expand Down Expand Up @@ -129,6 +200,16 @@ public function fillFromTheliaCartItemAndCountry(TheliaCartItem $cartItem, Count
]
);
$this->quantity = $cartItem->getQuantity();
//reproduce cart loop comportement
$this->calculatedTotalPrice = $cartItem->getTotalPrice();
$this->calculatedTotalPromoPrice = $cartItem->getTotalPromoPrice();
$this->calculatedTotalTaxedPrice = $cartItem->getTotalTaxedPrice($country);
$this->calculatedTotalPromoTaxedPrice = $cartItem->getTotalTaxedPromoPrice($country);

$this->calculatedRealPrice = $cartItem->getRealPrice();
$this->calculatedRealTaxedPrice = $cartItem->getRealTaxedPrice($country);
$this->calculatedRealTotalPrice = $cartItem->getTotalRealPrice();
$this->calculatedRealTotalTaxedPrice = $cartItem->getTotalTaxedPrice($country);

/** If there are PSE specific images, we use them. Otherwise, we just use the product images */
$modelFactory = $this->modelFactory;
Expand Down Expand Up @@ -306,4 +387,92 @@ public function setQuantity($quantity)

return $this;
}

public function getCalculatedRealPrice(): float
{
return $this->calculatedRealPrice;
}

public function setCalculatedRealPrice(float $calculatedRealPrice): CartItem
{
$this->calculatedRealPrice = $calculatedRealPrice;
return $this;
}

public function getCalculatedRealTaxedPrice(): float
{
return $this->calculatedRealTaxedPrice;
}

public function setCalculatedRealTaxedPrice(float $calculatedRealTaxedPrice): CartItem
{
$this->calculatedRealTaxedPrice = $calculatedRealTaxedPrice;
return $this;
}

public function getCalculatedRealTotalPrice(): float
{
return $this->calculatedRealTotalPrice;
}

public function setCalculatedRealTotalPrice(float $calculatedRealTotalPrice): CartItem
{
$this->calculatedRealTotalPrice = $calculatedRealTotalPrice;
return $this;
}

public function getCalculatedRealTotalTaxedPrice(): float
{
return $this->calculatedRealTotalTaxedPrice;
}

public function setCalculatedRealTotalTaxedPrice(float $calculatedRealTotalTaxedPrice): CartItem
{
$this->calculatedRealTotalTaxedPrice = $calculatedRealTotalTaxedPrice;
return $this;
}

public function getCalculatedTotalPrice(): float
{
return $this->calculatedTotalPrice;
}

public function setCalculatedTotalPrice(float $calculatedTotalPrice): CartItem
{
$this->calculatedTotalPrice = $calculatedTotalPrice;
return $this;
}

public function getCalculatedTotalPromoPrice(): float
{
return $this->calculatedTotalPromoPrice;
}

public function setCalculatedTotalPromoPrice(float $calculatedTotalPromoPrice): CartItem
{
$this->calculatedTotalPromoPrice = $calculatedTotalPromoPrice;
return $this;
}

public function getCalculatedTotalPromoTaxedPrice(): float
{
return $this->calculatedTotalPromoTaxedPrice;
}

public function setCalculatedTotalPromoTaxedPrice(float $calculatedTotalPromoTaxedPrice): CartItem
{
$this->calculatedTotalPromoTaxedPrice = $calculatedTotalPromoTaxedPrice;
return $this;
}

public function getCalculatedTotalTaxedPrice(): float
{
return $this->calculatedTotalTaxedPrice;
}

public function setCalculatedTotalTaxedPrice(float $calculatedTotalTaxedPrice): CartItem
{
$this->calculatedTotalTaxedPrice = $calculatedTotalTaxedPrice;
return $this;
}
}

0 comments on commit a090180

Please sign in to comment.