{
total_price = $event.detail.total_price;
})"
x-init="$nextTick(() => {
if(percentage >= 100){
offer_message = `CONGRATS! YOU HAVE UNLOCKED FREE SHIPPING!`;
}
});
Alpine.effect(() => {
threshold = Alpine.store('shippingThreshold')?.threshold;
calulateFreeShipping(total_price);
const element = document.querySelector('.cart-usps-section .usp-container:last-child .usp-text span');
if (element) {
element.textContent = `OVER ${$store?.shippingThreshold?.thresholdAmount }`;
}
})
$watch('total_price', (value) => {
calulateFreeShipping(value);
});"
x-data="{
remaining_threshold: `
$35.00`,
threshold: 3500,
percentage: 0,
total_price: 0,
free_shipping_after: `CONGRATS! YOU HAVE UNLOCKED FREE SHIPPING!`,
free_shipping_before: `You're $x away from
free shipping`,
offer_message: `You're $x away from
free shipping`,
calulateFreeShipping(total){
this.total_price = total;
this.remaining_threshold = this.threshold - this.total_price;
this.remaining_threshold = Unick.marketMoney(this.remaining_threshold / 100)
this.percentage = Math.round((this.total_price / this.threshold) * 100);
if(this.percentage >= 100){
Alpine.store('shippingThreshold').free_shipping_eligible = true;
}
if(this.percentage < 100){
Alpine.store('shippingThreshold').free_shipping_eligible = false;
}
},
}">
CONGRATS! YOU HAVE UNLOCKED FREE SHIPPING!
You're $35.00 away from free shipping