Country Prices | Homeparty | Shop | Order

This commit is contained in:
Kevin Adametz 2021-08-27 18:53:12 +02:00
parent 51d81d8ec6
commit 39d1e93416
284 changed files with 784 additions and 216 deletions

View file

@ -342,11 +342,54 @@ class Product extends Model
return $ctax !== null ? $ctax : $tax;
}
public function getFormattedPriceOldWith(Bool $net = true, Bool $ufactor = true, $country = null)
{
$price = isset($this->attributes['price_old']) ? $this->attributes['price_old'] : null;
$cprice = $country ? $this->getCPriceOld($country) : null;
$price = $cprice ? $cprice : $price;
$price = $net ? $this->calcPriceNet($price, $country) : $price;
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
$price = round($price, 2);
return isset($price) ? Util::formatNumber($price) : "";
}
public function getFormattedTax($country = null)
{
return isset($this->attributes['tax']) ? Util::formatNumber($this->getTaxWith($country), 0) : "";
}
public function getBasePriceFormattedFullWith(Bool $net = true, Bool $ufactor = true, $country = null){
$price = $this->getPriceWith($net, $ufactor, $country);
if($price = $this->getBasePriceWith($price)){
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return Util::formatNumber($price) . ' € / 100 '.$this->getUnitType();
}
//l kg
if($unit === 3 || $unit === 4){
return Util::formatNumber($price) . ' € / 1 '.$this->getUnitType();
}
}
return "";
}
public function getBasePriceWith($price){
if(isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0){
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return $price * 100 / $this->attributes['contents_total'];
}
//l kg
if($unit === 3 || $unit === 4){
return $price * 1000 / $this->attributes['contents_total'];
}
}
return "";
}
public function getBasePriceFormattedFull(){
if($price = $this->getBasePrice()){
$unit = $this->attributes['unit'];
@ -383,6 +426,8 @@ class Product extends Model
}
return "";
}
public function getUnitType(){
return isset($this->unitTypes[$this->unit]) ? $this->unitTypes[$this->unit] : '-';
}