Browse Source

Frontend : page produit

reduction
Guillaume 4 years ago
parent
commit
d163d9ebb2
5 changed files with 62 additions and 6 deletions
  1. +3
    -3
      ShopBundle/Model/PriceTrait.php
  2. +52
    -0
      ShopBundle/Model/ProductFamily.php
  3. +5
    -0
      ShopBundle/Model/ProductPropertyTrait.php
  4. +1
    -1
      ShopBundle/Resources/views/backend/productfamily/form.html.twig
  5. +1
    -2
      ShopBundle/Twig/FrontendTwigExtension.php

+ 3
- 3
ShopBundle/Model/PriceTrait.php View File



public function getPriceByUnitRef() public function getPriceByUnitRef()
{ {
return $this->getPriceInherited() * $this->getUnitInherited()->getCoefficient() ;
return ($this->getPriceInherited() * $this->getUnitInherited()->getCoefficient()) / $this->getQuantityInherited() ;
} }


public function getPriceByUnitRefWithTax() public function getPriceByUnitRefWithTax()


private function calculatePriceWithTax($priceWithoutTax, $taxRateValue) private function calculatePriceWithTax($priceWithoutTax, $taxRateValue)
{ {
$price = floatval($priceWithoutTax) * ($taxRateValue + 1) ;
$price = number_format(( ($price * 100)) / 100, 2) ;
$price = floatval($priceWithoutTax) * ($taxRateValue/100 + 1) ;
$price = round(( ($price * 100)) / 100, 2) ;
return $price ; return $price ;
} }
} }

+ 52
- 0
ShopBundle/Model/ProductFamily.php View File

*/ */
protected $typeExpirationDate; protected $typeExpirationDate;


/**
* @ORM\Column(type="string", length=32, nullable=true)
*/
protected $behaviorAddToCart;


public function __construct() public function __construct()
{ {
return $this; return $this;
} }


public function getProductCategoryParent()
{
$productCategories = $this->getProductCategories() ;

if(count($productCategories) > 0) {
return $productCategories[0]->getParent() ;
}

return false ;
}

public function getProductCategoryChild()
{
$productCategories = $this->getProductCategories() ;
foreach($productCategories as $productCategory) {
if($productCategory->getParent()) {
return $productCategory ;
}
}

return false ;
}

public function getSupplierTaxRate(): ?TaxRate public function getSupplierTaxRate(): ?TaxRate
{ {
return $this->supplierTaxRate; return $this->supplierTaxRate;
return $this; return $this;
} }


public function countProperties(): bool
{
$count = 0 ;

$count += (int) strlen($this->getPropertyAllergens()) > 0 ;
$count += (int) strlen($this->getPropertyComposition()) > 0 ;
$count += (int) strlen($this->getPropertyFragrances()) > 0 ;
$count += (int) strlen($this->getPropertyOrganicLabel()) > 0 ;
$count += (int) ($this->getPropertyExpirationDate() != null) ;

return $count ;
}


public function getBehaviorExpirationDate(): ?string public function getBehaviorExpirationDate(): ?string
{ {
return $this; return $this;
} }


public function getBehaviorAddToCart(): ?string
{
return $this->behaviorAddToCart;
}

public function setBehaviorAddToCart(?string $behaviorAddToCart): self
{
$this->behaviorAddToCart = $behaviorAddToCart;

return $this;
}

} }

+ 5
- 0
ShopBundle/Model/ProductPropertyTrait.php View File

return $this; return $this;
} }


public function getQuantityInherited(): ?float
{
return $this->getQuantity() ;
}

public function getAvailableQuantity(): ?float public function getAvailableQuantity(): ?float
{ {
return $this->availableQuantity; return $this->availableQuantity;

+ 1
- 1
ShopBundle/Resources/views/backend/productfamily/form.html.twig View File

{% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %} {% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %}
{% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %} {% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %}
{% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %} {% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %}
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate }}",{% endif %}
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate|date('d/m/Y') }}",{% endif %}
}; };
window.productUnitPriceValues = { window.productUnitPriceValues = {
{% if formValues.unit %}unit: parseInt({{ formValues.unit.id }}),{% endif %} {% if formValues.unit %}unit: parseInt({{ formValues.unit.id }}),{% endif %}

+ 1
- 2
ShopBundle/Twig/FrontendTwigExtension.php View File



public function formatPrice($price) public function formatPrice($price)
{ {
$price = number_format($price, 2) ;
$price = str_replace('.',',',$price) ;
$price = number_format($price, 2, ',', ' ') ;
$price = $price .' €' ; $price = $price .' €' ;
return $price ; return $price ;
} }

Loading…
Cancel
Save