{
total_price = $event.detail.total_price;
calculateProgress();
})"
x-init="calculateProgress();"
x-data="{
total_price: 0,
threshold_standard: 3500,
threshold_expedited: 4500,
remaining_standard: '
$35',
remaining_expedited: '
$45',
progress_percentage: 0,
expedited_enabled: true,
standard_message_before: `You're $x away from
free shipping`,
standard_message_after: `CONGRATS! YOU HAVE UNLOCKED FREE SHIPPING!`,
expedited_message_before: `Add $x more for expedited shipping`,
expedited_message_after: `Congratulations! You've unlocked expedited shipping`,
calculateProgress() {
this.total_price = parseFloat(this.total_price) || 0;
const max_threshold = this.expedited_enabled ? this.threshold_expedited : this.threshold_standard;
this.progress_percentage = Math.min((this.total_price / max_threshold) * 100, 100);
// Calculate remaining amounts
const remaining_standard_cents = Math.max(this.threshold_standard - this.total_price, 0);
const remaining_expedited_cents = Math.max(this.threshold_expedited - this.total_price, 0);
this.remaining_standard = Unick.marketMoney(remaining_standard_cents/100);
this.remaining_expedited = Unick.marketMoney(remaining_expedited_cents/100);
}
}">