I’m using sweet alert version two V2 with PHP, but it doesn’t work correctly.
I have a normal, default javascript browser alert and work correctly with PHP.
I have coupon validation, array, the default alert shows me a message like this “correct | worong… code for P_ID: *** and P_NAME: ***”; (error or success depend of the result) but work correctly for show message per each product entered coupon code into the input.
But the problem is that when I try to use SWEET ALERT 2 or whatever other libraries like (sweet alert v1,sweet alert v2,izitoast… and others)
I need to have same work exactly result like default browser alert with PHP.
this is the code (default browser alert WORK PERFECT):
echo "<script>alert('No coupon code for: {$products_db[$p_id]['p_name']}');</script>";
this is the code (whatever other libraries…):
echo "<script>
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 10000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
icon: 'error',
title: 'Wrong coupon code for: {$products_db[$p_id]['p_name']}'
})
</script>";
and finally here are the images to explain the context (please click on links): (NOTE: the quantity of products showed in every alert depends on the products in to array, each alert for each product coupon code entered and validated)
pics of context for explain default browser alert here:
first alert (correct update quantity when onclick update cart button)
second alert for second product in array detected
third alert for third product in array detected
pics of context for explain other custom alerts libraries here:
(work perfectly for only one product in the array…but the problem its in the array have more than one… and dont show in any way)
custom alert HERE THE ERROR