{
this.cartQuantities[variant.id] = variant.cartQuantity;
});
// Update cart quantities initially
// required to ensure the the isBackorder is correctly set initially
this.updateCartQuantities();
// Update cart quantities when cart changes
document.addEventListener("cart:change", () => this.updateCartQuantities());
document.addEventListener("cart:refresh", () => this.updateCartQuantities());
// Update cart item has backorder or preorder property when cart changes
document.addEventListener("cart:change", () => this.updateCartItemHasBackorderOrPreorderProperty());
document.addEventListener("cart:refresh", () => this.updateCartItemHasBackorderOrPreorderProperty());
},
async updateCartItemHasBackorderOrPreorderProperty() {
try {
const cart = await fetch(`${Shopify.routes.root}cart.js`).then(r => r.json());
this.variants.forEach(variant => {
const variant_cart_items = cart.items.filter(item => item.variant_id == variant.id);
if (variant_cart_items.length > 0) {
const hasProperty = (item) => {
if (!item.properties) return false;
const preorderText = "Preorder";
return item.properties.hasOwnProperty(preorderText) ||
item.properties.hasOwnProperty("_is_preorder");
};
const allHaveProperty = variant_cart_items.every(item => hasProperty(item));
const allDontHaveProperty = variant_cart_items.every(item => !hasProperty(item));
if (allHaveProperty || allDontHaveProperty) {
// All items are consistent - either all have it or all dont have it
variant.cartItemHasBackorderOrPreorderProperty = allHaveProperty;
} else {
// Mixed state - some have it, some dont (inconsistent)
variant.cartItemHasBackorderOrPreorderProperty = false;
}
if (variant.id === this.selectedVariantId) {
this.cartItemHasBackorderOrPreorderProperty = variant.cartItemHasBackorderOrPreorderProperty;
}
}
});
} catch (error) {
console.error("Error fetching cart:", error);
}
},
async updateCartQuantities() {
try {
const cart = await fetch(`${Shopify.routes.root}cart.js`).then(r => r.json());
this.cartQuantities = {};
cart.items.forEach(item => {
if (!this.cartQuantities[item.variant_id]) {
this.cartQuantities[item.variant_id] = 0;
}
this.cartQuantities[item.variant_id] += item.quantity;
});
this.variants.forEach(variant => {
const cartQuantity = this.cartQuantities[variant.id] || 0;
variant.cartQuantity = cartQuantity;
if (variant.id === this.selectedVariantId) {
if (variant.cartQuantity >= variant.inventoryQuantity) {
if (this.hasRequiredPreorderTag == true) {
this.isPreorder = true
this.isBackorder = false
} else {
this.isBackorder = true
this.isPreorder = false
}
} else {
this.isBackorder = false
this.isPreorder = false
}
this.cartQuantity = variant.cartQuantity;
}
});
} catch (error) {
console.error("Error fetching cart:", error);
}
},
get remainingBackorderQuantity() {
if (!this.useBackorderMaxQuantity) return "1";
const variant = this.variants.find(v => v.id === this.selectedVariantId);
if (!variant) return "1";
const cartQty = this.cartQuantities[this.selectedVariantId] || 0;
return variant.backorderDeliveryQuantity + variant.inventoryQuantity - cartQty;
},
get backorderMessage() {
return "Preorder delivery date [placeholder]".replace("[placeholder]", this.backorderDate);
}
}'
@change="(e) => {
const currId = $el.querySelector('input[name=\'id\']').value;
const newVariant = variants.find(variant => variant.id === currId);
if (!newVariant) return;
inventoryQuantity = newVariant.inventoryQuantity;
cartQuantity = newVariant.cartQuantity;
isEligibleForBackorder = newVariant.isEligibleForBackorder;
cartItemHasBackorderOrPreorderProperty = newVariant.cartItemHasBackorderOrPreorderProperty;
backorderDate = newVariant.variantBackorderDate;
selectedVariantId = newVariant.id;
if (cartQuantity >= inventoryQuantity) {
if (newVariant.stock === 'preorder') {
isPreorder = true
isBackorder = false
} else if (newVariant.stock === 'backorder') {
isBackorder = true
isPreorder = false
}
} else {
isBackorder = false
isPreorder = false
}
}"
>
Description
Simple catsuit in dorlastan. Dorlastan is a stretchy and soft material that is widely used for gymnastics clothing. It has a slightly shiny surface and fits the body. We recommend your regular size - over time, after a little use, the suit will become looser/give a little. [This item cannot be exchanged or returned due to the club logo. [/b] We encourage exchanges within the club.
Please note that when you purchase an item with a club logo, it cannot be exchanged or returned.