Skip to content

Commit

Permalink
Fix error on cart items not existing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jade-GG committed Jan 20, 2025
1 parent 2734670 commit f395e6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions resources/js/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ function init() {
},

hasCart() {
return this.cart?.id && this.cart.items.length
return this.cart?.id && this.cart.items?.length
},

canOrder() {
return this.cart.items.every((item) => item.is_available)
return this.cart.items?.every((item) => item.is_available)
},
},
watch: {
Expand Down
4 changes: 2 additions & 2 deletions resources/js/stores/useCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const cart = computed({
getAttributeValues()
.then((response) => {
if (!response?.data?.customAttributeMetadata?.items) {
value.items = value.items.map((item) => {
value.items = value.items?.map((item) => {
item.is_available = checkAvailability(item)

return item
Expand All @@ -138,7 +138,7 @@ export const cart = computed({
]),
)

value.items = value.items.map((cartItem) => {
value.items = value.items?.map((cartItem) => {
cartItem.is_available = checkAvailability(cartItem)
cartItem.product.attribute_values = {}

Expand Down

0 comments on commit f395e6d

Please sign in to comment.