Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Sep 24, 2024
1 parent fb967f9 commit b47d2bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Cart/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ public function empty(): void
$this->getModel()->items()->delete();
$this->getModel()->setRelation('items', $this->getModel()->items()->getRelated()->newCollection());

$this->getShipping()->update(['tax' => 0, 'fee' => 0]);
$this->getShipping()->update(['fee' => 0]);
$this->getShipping()->taxes()->delete();

$this->getModel()->calculateDiscount();
}
Expand Down Expand Up @@ -274,7 +275,6 @@ public function isNotEmpty(): bool
public function sync(): void
{
$this->getShipping()->calculateFee();
$this->getShipping()->save();

$this->getShipping()->calculateTaxes();

Expand Down
10 changes: 10 additions & 0 deletions src/Models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ class Item extends Model implements Contract
*/
protected $table = 'bazar_items';

/**
* The "booted" method of the model.
*/
protected static function booted(): void
{
static::deleting(static function (self $item): void {
$item->taxes()->delete();
});
}

/**
* Get the proxied interface.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Property extends Model implements Contract
*/
protected static function booted(): void
{
static::deleted(static function (self $property): void {
static::deleting(static function (self $property): void {
$property->values()->delete();
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ public function getQuantity(): float
public function calculateFee(): float
{
try {
$this->update([
$this->fill([
'fee' => Manager::driver($this->driver)->calculate($this->shippable),
]);
])->save();
} catch (Throwable $exception) {
//
}
Expand Down

0 comments on commit b47d2bd

Please sign in to comment.