Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig committed Aug 21, 2024
2 parents ef6be36 + 107ed12 commit 9593d98
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion classes/traits/ShippingMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public function getAvailableShippingMethods()
public function setShippingMethod(?ShippingMethod $method)
{
$this->shipping_method_id = $method ? $method->id : null;
$this->save();
if ($this->exists) {
$this->save();
}
}

/**
Expand Down
8 changes: 5 additions & 3 deletions classes/traits/cart/CartSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function byUser(?User $user)
}

$cart = self::orderBy('created_at', 'DESC')
->firstOrCreate(['customer_id' => $user->customer->id]);
->firstOrNew(['customer_id' => $user->customer->id]);

if ( ! $cart->shipping_address_id || ! $cart->billing_address_id) {
if ( ! $cart->shipping_address_id) {
Expand All @@ -27,7 +27,9 @@ public static function byUser(?User $user)
if ( ! $cart->billing_address_id) {
$cart->billing_address_id = $user->customer->default_billing_address_id;
}
$cart->save();
if ($cart->exists) {
$cart->save();
}
}

return $cart;
Expand All @@ -47,7 +49,7 @@ protected static function bySession(): Cart
Cookie::queue('cart_session_id', $sessionId, 9e6);
Session::put('cart_session_id', $sessionId);

return self::orderBy('created_at', 'DESC')->firstOrCreate(['session_id' => $sessionId]);
return self::orderBy('created_at', 'DESC')->firstOrNew(['session_id' => $sessionId]);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,5 @@ v3.4.1:
- 'Prevent from adding too many queue jobs for UniquePropertyValue'
v3.4.2:
- 'Fixed demo seeder with new users plugin'
v3.4.3:
- 'Only create carts once a product is added'

0 comments on commit 9593d98

Please sign in to comment.