Array problem when try to show more than one element of the array into custom alerts and not into default

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)
          icon: 'error',
          title: 'Wrong coupon code for: {$products_db[$p_id]['p_name']}'

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

So… i recognize there’s a language barrier here, but lets give it a try.

The problem you’re having is if you have multiple errors, you dont see multiple messages.
This is almost certainly a Javascript problem, not a PHP one;
It looks like SweetAlert is not designed to have multiple toasts on the screen at the same time. You can await the .fire call, but it’ll show them one after another.

yes if i decided to wait .fire call how can show one after another?

Yes, await’ing the call to fire should fire them one after another, as it forces the asynchronous operation to become synchronous.

you can write the code explaining me the way to fix this issue?