mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 18:54:33 +00:00
StyleCI
This commit is contained in:
@@ -4,10 +4,12 @@ namespace Gloudemans\Shoppingcart\Calculation;
|
|||||||
|
|
||||||
use Gloudemans\Shoppingcart\CartItem;
|
use Gloudemans\Shoppingcart\CartItem;
|
||||||
|
|
||||||
class DefaultCalculator {
|
class DefaultCalculator
|
||||||
static function getAttribute(string $attribute, CartItem $cartItem) {
|
{
|
||||||
|
public static function getAttribute(string $attribute, CartItem $cartItem)
|
||||||
|
{
|
||||||
$decimals = config('cart.format.decimals', 2);
|
$decimals = config('cart.format.decimals', 2);
|
||||||
|
|
||||||
switch ($attribute) {
|
switch ($attribute) {
|
||||||
case 'discount':
|
case 'discount':
|
||||||
return $cartItem->price * ($cartItem->getDiscountRate() / 100);
|
return $cartItem->price * ($cartItem->getDiscountRate() / 100);
|
||||||
@@ -31,4 +33,4 @@ class DefaultCalculator {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ namespace Gloudemans\Shoppingcart\Calculation;
|
|||||||
|
|
||||||
use Gloudemans\Shoppingcart\CartItem;
|
use Gloudemans\Shoppingcart\CartItem;
|
||||||
|
|
||||||
class GrossPrice {
|
class GrossPrice
|
||||||
static function getAttribute(string $attribute, CartItem $cartItem) {
|
{
|
||||||
|
public static function getAttribute(string $attribute, CartItem $cartItem)
|
||||||
|
{
|
||||||
$decimals = config('cart.format.decimals', 2);
|
$decimals = config('cart.format.decimals', 2);
|
||||||
|
|
||||||
switch ($attribute) {
|
switch ($attribute) {
|
||||||
case 'priceNet':
|
case 'priceNet':
|
||||||
return round($cartItem->price / (1 + ($cartItem->taxRate / 100)), $decimals);
|
return round($cartItem->price / (1 + ($cartItem->taxRate / 100)), $decimals);
|
||||||
@@ -33,4 +35,4 @@ class GrossPrice {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -397,8 +397,8 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
case 'weightTotal':
|
case 'weightTotal':
|
||||||
return round($this->weight * $this->qty, $decimals);
|
return round($this->weight * $this->qty, $decimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
return call_user_func(config('cart.calculator', DefaultCalculator::class) . '::getAttribute', $attribute, $this);
|
return call_user_func(config('cart.calculator', DefaultCalculator::class).'::getAttribute', $attribute, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -528,4 +528,4 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
{
|
{
|
||||||
return $this->discountRate;
|
return $this->discountRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user