2023-06-11 12:14:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modules\Cart;
|
|
|
|
|
|
|
|
use JsonSerializable;
|
|
|
|
use Modules\Support\Money;
|
|
|
|
use Modules\Tax\Entities\TaxRate;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
use Modules\Coupon\Entities\Coupon;
|
|
|
|
use Modules\Product\Entities\Product;
|
2023-12-03 14:07:47 +00:00
|
|
|
use Modules\Product\Entities\ProductVariant;
|
2023-06-11 12:14:03 +00:00
|
|
|
use Modules\Shipping\Facades\ShippingMethod;
|
|
|
|
use Darryldecode\Cart\Cart as DarryldecodeCart;
|
2023-12-03 14:07:47 +00:00
|
|
|
use Modules\Variation\Entities\VariationValue;
|
2023-06-11 12:14:03 +00:00
|
|
|
use Modules\Product\Services\ChosenProductOptions;
|
2023-12-03 14:07:47 +00:00
|
|
|
use Modules\Product\Services\ChosenProductVariations;
|
|
|
|
use Darryldecode\Cart\Exceptions\InvalidItemException;
|
|
|
|
use Darryldecode\Cart\Exceptions\InvalidConditionException;
|
2023-06-11 12:14:03 +00:00
|
|
|
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
|
|
|
|
|
|
|
class Cart extends DarryldecodeCart implements JsonSerializable
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Get the current instance.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
public function instance(): static
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
/**
|
|
|
|
* Clear the cart.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
public function clear(): void
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
|
|
|
parent::clear();
|
|
|
|
|
|
|
|
$this->clearCartConditions();
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
/**
|
|
|
|
* Store a new item to the cart.
|
|
|
|
*
|
|
|
|
* @param int $productId
|
2023-12-03 14:07:47 +00:00
|
|
|
* @param $variantId
|
2023-06-11 12:14:03 +00:00
|
|
|
* @param int $qty
|
|
|
|
* @param array $options
|
|
|
|
*
|
|
|
|
* @return void
|
2023-12-03 14:07:47 +00:00
|
|
|
* @throws InvalidItemException
|
2023-06-11 12:14:03 +00:00
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
public function store($productId, $variantId, $qty, $options = []): void
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
|
|
|
$options = array_filter($options);
|
2023-12-03 14:07:47 +00:00
|
|
|
$variations = [];
|
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
$product = Product::with('files', 'categories', 'taxClass')->findOrFail($productId);
|
2023-12-03 14:07:47 +00:00
|
|
|
$variant = ProductVariant::find($variantId);
|
|
|
|
$item = $variant ?? $product;
|
|
|
|
|
|
|
|
if ($variant) {
|
|
|
|
$uids = collect(explode('.', $variant->uids));
|
|
|
|
$rawVariations = $uids->map(function ($uid) {
|
|
|
|
return VariationValue::where('uid', $uid)->get()->pluck('id', 'variation.id');
|
|
|
|
});
|
|
|
|
|
|
|
|
foreach ($rawVariations as $variation) {
|
|
|
|
foreach ($variation as $variationId => $variationValueId) {
|
|
|
|
$variations[$variationId] = $variationValueId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$chosenVariations = new ChosenProductVariations($product, $variations);
|
2023-06-11 12:14:03 +00:00
|
|
|
$chosenOptions = new ChosenProductOptions($product, $options);
|
|
|
|
|
|
|
|
$this->add([
|
2023-12-03 14:07:47 +00:00
|
|
|
'id' => md5("product_id.{$product->id}:options." . serialize($options) . "product_id.{$product->id}:variations." . serialize($variations)),
|
2023-06-11 12:14:03 +00:00
|
|
|
'name' => $product->name,
|
2023-12-03 14:07:47 +00:00
|
|
|
'price' => $item->selling_price->amount(),
|
2023-06-11 12:14:03 +00:00
|
|
|
'quantity' => $qty,
|
|
|
|
'attributes' => [
|
|
|
|
'product' => $product,
|
2023-12-03 14:07:47 +00:00
|
|
|
'variant' => $variant,
|
|
|
|
'item' => $item,
|
|
|
|
'variations' => $chosenVariations->getEntities(),
|
2023-06-11 12:14:03 +00:00
|
|
|
'options' => $chosenOptions->getEntities(),
|
|
|
|
'created_at' => time(),
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function updateQuantity($id, $qty)
|
|
|
|
{
|
|
|
|
$this->update($id, [
|
|
|
|
'quantity' => [
|
|
|
|
'relative' => false,
|
|
|
|
'value' => $qty,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Total quantity of the given cartItem
|
|
|
|
* in the Cart.
|
|
|
|
*
|
|
|
|
* @param CartItem $cartItem
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function addedQty(CartItem $cartItem): int
|
|
|
|
{
|
|
|
|
$items = $this->items()->filter(function ($cartItemAlias) use ($cartItem) {
|
|
|
|
if ($cartItem->variant && $cartItemAlias->variant) {
|
|
|
|
return $cartItemAlias->variant->id === $cartItem->variant->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $cartItemAlias->product->id === $cartItem->product->id;
|
|
|
|
});
|
|
|
|
|
|
|
|
return $items->sum('qty');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function items()
|
|
|
|
{
|
|
|
|
return $this->getContent()
|
|
|
|
->sortBy('attributes.created_at')
|
|
|
|
->map(function ($item) {
|
|
|
|
return new CartItem($item);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function crossSellProducts()
|
|
|
|
{
|
|
|
|
return $this->getAllProducts()
|
|
|
|
->load([
|
|
|
|
'crossSellProducts' => function ($query) {
|
|
|
|
$query->forCard();
|
|
|
|
},
|
|
|
|
])
|
|
|
|
->pluck('crossSellProducts')
|
|
|
|
->flatten();
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function getAllProducts(): EloquentCollection
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
return $this->items()->map(function ($cartItem) {
|
|
|
|
return $cartItem->product;
|
|
|
|
})->flatten()->pipe(function ($products) {
|
|
|
|
return new EloquentCollection($products);
|
|
|
|
});
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function reduceStock()
|
|
|
|
{
|
|
|
|
$this->manageStock(function ($cartItem) {
|
2023-12-03 14:07:47 +00:00
|
|
|
$cartItem->item->decrement('qty', $cartItem->qty);
|
2023-06-11 12:14:03 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function restoreStock()
|
|
|
|
{
|
|
|
|
$this->manageStock(function ($cartItem) {
|
|
|
|
$cartItem->product->increment('qty', $cartItem->qty);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
/**
|
|
|
|
* @throws InvalidConditionException
|
|
|
|
*/
|
2023-06-11 12:14:03 +00:00
|
|
|
public function addShippingMethod($shippingMethod)
|
|
|
|
{
|
|
|
|
$this->removeShippingMethod();
|
|
|
|
|
|
|
|
$this->condition(
|
|
|
|
new CartCondition([
|
|
|
|
'name' => $shippingMethod->label,
|
|
|
|
'type' => 'shipping_method',
|
|
|
|
'target' => 'total',
|
2023-12-03 14:07:47 +00:00
|
|
|
'value' => $this->coupon()?->free_shipping ? 0 : $shippingMethod->cost->amount(),
|
2023-06-11 12:14:03 +00:00
|
|
|
'order' => 1,
|
|
|
|
'attributes' => [
|
|
|
|
'shipping_method' => $shippingMethod,
|
|
|
|
],
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->refreshFreeShippingCoupon();
|
|
|
|
|
|
|
|
return $this->shippingMethod();
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function removeShippingMethod()
|
|
|
|
{
|
|
|
|
$this->removeConditionsByType('shipping_method');
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function coupon()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
if (!$this->hasCoupon()) {
|
|
|
|
return new NullCartCoupon();
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
$couponCondition = $this->getConditionsByType('coupon')->first();
|
|
|
|
$coupon = Coupon::with('products', 'categories')->find($couponCondition->getAttribute('coupon_id'));
|
|
|
|
|
|
|
|
return new CartCoupon($this, $coupon, $couponCondition);
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function hasCoupon()
|
|
|
|
{
|
|
|
|
if ($this->getConditionsByType('coupon')->isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$couponId = $this->getConditionsByType('coupon')
|
|
|
|
->first()
|
|
|
|
->getAttribute('coupon_id');
|
|
|
|
|
|
|
|
return Coupon::where('id', $couponId)->exists();
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function applyCoupon(Coupon $coupon)
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
$this->removeCoupon();
|
|
|
|
|
|
|
|
try {
|
|
|
|
$this->condition(
|
|
|
|
new CartCondition([
|
|
|
|
'name' => $coupon->code,
|
|
|
|
'type' => 'coupon',
|
|
|
|
'target' => 'total',
|
|
|
|
'value' => $this->getCouponValue($coupon),
|
|
|
|
'order' => 2,
|
|
|
|
'attributes' => [
|
|
|
|
'coupon_id' => $coupon->id,
|
|
|
|
],
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
} catch (InvalidConditionException $e) {
|
|
|
|
if (app()->hasDebugModeEnabled()) {
|
|
|
|
$message = $e->getMessage();
|
|
|
|
} else {
|
|
|
|
$message = trans('core::something_went_wrong');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (request()->ajax()) {
|
|
|
|
return response()->json(
|
|
|
|
[
|
|
|
|
'message' => $message,
|
|
|
|
],
|
|
|
|
400
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function removeCoupon()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
$this->removeConditionsByType('coupon');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function shippingMethod()
|
|
|
|
{
|
|
|
|
if (!$this->hasShippingMethod()) {
|
|
|
|
return new NullCartShippingMethod();
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
return new CartShippingMethod($this, $this->getConditionsByType('shipping_method')->first());
|
|
|
|
}
|
2023-06-11 12:14:03 +00:00
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function hasShippingMethod()
|
|
|
|
{
|
|
|
|
return $this->getConditionsByType('shipping_method')->isNotEmpty();
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function couponAlreadyApplied(Coupon $coupon)
|
|
|
|
{
|
|
|
|
return $this->coupon()->code() === $coupon->code;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function discount()
|
|
|
|
{
|
|
|
|
return $this->coupon()->value();
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function addTaxes($request)
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
$this->removeTaxes();
|
2023-06-11 12:14:03 +00:00
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
$this->findTaxes($request)->each(/**
|
|
|
|
* @throws InvalidConditionException
|
|
|
|
*/
|
|
|
|
function ($taxRate) {
|
|
|
|
$this->condition(
|
|
|
|
new CartCondition([
|
|
|
|
'name' => $taxRate->id,
|
|
|
|
'type' => 'tax',
|
|
|
|
'target' => 'total',
|
|
|
|
'value' => "+{$taxRate->rate}%",
|
|
|
|
'order' => 3,
|
|
|
|
'attributes' => [
|
|
|
|
'tax_rate_id' => $taxRate->id,
|
|
|
|
],
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
});
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function removeTaxes()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
$this->removeConditionsByType('tax');
|
|
|
|
}
|
2023-06-11 12:14:03 +00:00
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
return json_encode($this->jsonSerialize());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function jsonSerialize(): array
|
|
|
|
{
|
|
|
|
return $this->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'items' => $this->items(),
|
|
|
|
'quantity' => $this->getTotalQuantity(),
|
|
|
|
'availableShippingMethods' => $this->availableShippingMethods(),
|
|
|
|
'subTotal' => $this->subTotal(),
|
|
|
|
'shippingMethodName' => $this->shippingMethod()->name(),
|
|
|
|
'shippingCost' => $this->shippingCost(),
|
|
|
|
'coupon' => $this->coupon(),
|
|
|
|
'taxes' => $this->taxes(),
|
|
|
|
'total' => $this->total(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function availableShippingMethods(): Collection
|
|
|
|
{
|
|
|
|
if ($this->allItemsAreVirtual()) {
|
|
|
|
return collect();
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
return ShippingMethod::available();
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function allItemsAreVirtual()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
return $this->items()->every(function (CartItem $cartItem) {
|
|
|
|
return $cartItem->product->is_virtual;
|
|
|
|
});
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function subTotal()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
return Money::inDefaultCurrency($this->getSubTotal())->add($this->optionsPrice());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function shippingCost()
|
|
|
|
{
|
|
|
|
return $this->shippingMethod()->cost();
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function taxes()
|
|
|
|
{
|
|
|
|
if (!$this->hasTax()) {
|
|
|
|
return new Collection();
|
|
|
|
}
|
|
|
|
|
|
|
|
$taxConditions = $this->getConditionsByType('tax');
|
|
|
|
$taxRates = TaxRate::whereIn('id', $this->getTaxRateIds($taxConditions))->get();
|
|
|
|
|
|
|
|
return $taxConditions->map(function ($taxCondition) use ($taxRates) {
|
|
|
|
$taxRate = $taxRates->where('id', $taxCondition->getAttribute('tax_rate_id'))->first();
|
|
|
|
|
|
|
|
return new CartTax($this, $taxRate, $taxCondition);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function hasTax()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
return $this->getConditionsByType('tax')->isNotEmpty();
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
public function total()
|
|
|
|
{
|
|
|
|
return $this->subTotal()
|
|
|
|
->add($this->shippingMethod()->cost())
|
|
|
|
->subtract($this->coupon()->value())
|
|
|
|
->add($this->tax());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
public function tax()
|
|
|
|
{
|
|
|
|
return Money::inDefaultCurrency($this->calculateTax());
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
private function manageStock($callback)
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
$this->items()
|
|
|
|
->filter(function ($cartItem) {
|
|
|
|
return $cartItem->item->manage_stock;
|
|
|
|
})
|
|
|
|
->each($callback);
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
private function refreshFreeShippingCoupon()
|
|
|
|
{
|
|
|
|
if ($this->coupon()->isFreeShipping()) {
|
|
|
|
$this->applyCoupon($this->coupon()->entity());
|
|
|
|
}
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
|
|
|
private function getCouponValue($coupon)
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
if ($coupon->is_percent) {
|
|
|
|
return "-{$coupon->value}%";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "-{$coupon->value->amount()}";
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
private function findTaxes($request)
|
|
|
|
{
|
|
|
|
return $this->items()
|
|
|
|
->groupBy('tax_class_id')
|
|
|
|
->flatten()
|
|
|
|
->map(function (CartItem $cartItem) use ($request) {
|
|
|
|
return $cartItem->findTax($request->only(['billing', 'shipping']));
|
|
|
|
})
|
|
|
|
->filter();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function optionsPrice()
|
|
|
|
{
|
|
|
|
return Money::inDefaultCurrency($this->calculateOptionsPrice());
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
private function calculateOptionsPrice()
|
|
|
|
{
|
|
|
|
return $this->items()->sum(function ($cartItem) {
|
|
|
|
return $cartItem
|
|
|
|
->optionsPrice()
|
|
|
|
->multiply($cartItem->qty)
|
|
|
|
->amount();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
private function getTaxRateIds($taxConditions)
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
return $taxConditions->map(function ($taxCondition) {
|
|
|
|
return $taxCondition->getAttribute('tax_rate_id');
|
|
|
|
});
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
private function calculateTax()
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
2023-12-03 14:07:47 +00:00
|
|
|
return $this->taxes()->sum(function ($cartTax) {
|
|
|
|
return $cartTax->amount()->amount();
|
|
|
|
});
|
2023-06-11 12:14:03 +00:00
|
|
|
}
|
|
|
|
}
|