setTimeout(() => popup.open=false,200))"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-200"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
x-cloak
x-data="{
animate:false,
popup_step: 1,
email: '',
gdpr: null,
coupon: null,
applyDiscount(callback) {
axios
.post(
'/handler-router',
qs.stringify({
internal: true,
module: 'Form',
method: 'apply_popup_discount',
coupon: this.coupon
})
)
.then((response) => {
if (response.data.status === 'success') {
callback()
}
if(response.data.message) {
window.messages.add(response.data.status, response.data.message);
}
})
.catch((error) => {
console.error(error);
});
},
submitStep() {
axios
.post(
'/handler-router',
qs.stringify({
internal: true,
module: 'Form',
method: 'submit_popup_email',
email: this.email,
gdpr: this.gdpr ? 1 : 0,
gtm: JSON.stringify(Alpine.store('Tracking').gtm)
})
)
.then((response) => {
if (response.data.status === 'success') {
this.coupon = response.data.data.coupon
if(this.coupon) {
this.popup_step = 2;
} else {
this.popup_step = 3;
}
popup.available = false
popup.submited = true
localStorage.setItem('popup_hidden', true)
}
if(response.data.status !== 'success' && response.data.message) {
window.messages.add(response.data.status, response.data.message);
}
})
.catch((error) => {
console.error(error);
});
},
cancelStep(callback) {
axios
.post(
'/handler-router',
qs.stringify({
internal: true,
module: 'Form',
method: 'cancel_popup_email',
email: this.email,
gdpr: this.gdpr ? 1 : 0,
})
)
.then((response) => {
if (response.data.status === 'success') {
callback()
localStorage.setItem('popup_hidden', true)
}
if(response.data.status !== 'success' && response.data.message) {
window.messages.add(response.data.status, response.data.message);
}
})
.catch((error) => {
console.error(error);
});
}
}"
x-init="$nextTick (() => setTimeout(() => animate=true, popup.delay))"
>
Great, you get a discount!
Click on the button below to activate the discount code. Or you can enter it manually in the 1st step of the shopping cart.
{
animate=false;
$nextTick(() => setTimeout(() => popup.open=false,200))
})"
class="mt-8 block w-full rounded-2xl border border-nutrend-600 bg-nutrend-600 px-8 py-3 text-center text-base font-semibold text-white transition-colors hover:border-nutrend-700 hover:bg-nutrend-700 hover:text-white focus:outline-none md:px-12 md:py-4 md:text-base"
>
Activate discount
{
animate=false;
$nextTick(() => setTimeout(() => popup.open=false,200))
})"
>