An error has occurred while processing coupon code. See console log for more details


  • Your avatar
    tanidisit    
     18 days ago
    0

    Hello,


    In Joomla ‎4.4.14 and VirtueMart 4.6.4 with PHP 8.3.30 I have a problem with coupons.


    Specifically, I have created a coupon with a 10% discount, I have set the dates correctly, it is published and when I go to apply it to my cart it displays the following message:

    Invalid Token, in view=cart task=updatecart

    An error has occurred while processing coupon code. See console log for more details.


    The coupon is named BeYourValentine.

    You can try applying it to the following link: https://athanasios.jewelry/index.php?option=com_virtuemart&view=cart&task=vmsendcart&v=2&data=Lcg7DoAgEAXAu7x6C0QNulcxxBCkoFAUsDCEu_uJ5UxBdMnl2ZqYwYJ-Hvn6ZMO5h222YXFggOCzWxN4KvBgOSpJMOACJZ7UhEGCGyX6jtC-U6uuNw


    Could you help us?

  • Your avatar
    seyi    
     18 days ago
    0

    Hello,

    I see you are using vp one page checkout.  Have you updated this to the latest?  There is a change in Virtuemart that requires the session token.  And looking at the processing of ajax that vponepage is sending, it is not sending the token, which is why you are receiving the error.
  • Your avatar
    tanidisit    
     17 days ago
    0

    Thank you for your prompt response,


    I am using the latest version of vp one page checkout.


    Because I do not have the necessary knowledge to find a solution, related to the non-functioning of the Token. I tried to get help before answering you, from AI.


    I quote below the tests I performed, in case they help to find a solution. I hope you can help me. Thank you.


    Troubleshooting steps already taken:

    1. Session Configuration:

      • Switched Session Handler from "Database" to "Filesystem".

      • Set Shared Sessions to "No".

      • Disabled Track Session.

      • Verified Session Lifetime is set to 60 minutes.

    2. Environment Settings:

      • Error Reporting set to "None" (to prevent PHP 8.3 notices from breaking JSON responses).

      • Verified Cookie Domain/Path are empty and Force HTTPS is enabled for the entire site.

    3. Code & Template Checks:

      • Tested with both the VP One Page Checkout and the Default VirtueMart Cart layout. The issue persists in both.

      • Modified default_coupon.php to manually include

        <?php
         
        echo JHtml::_('form.token'); 
        ?>
        .

      • Cleared Joomla and Browser cache multiple times.

    4. Network/Console Analysis:

      • Browser Console: Returns SyntaxError: JSON.parse: unexpected character because the server returns a full HTML page (Redirect 303) instead of JSON.

      • Network Payload: Confirmed that during the task=setcoupon POST request, the Joomla Security Token is missing from the request headers/payload, even when the token is present in the HTML form.

  • Your avatar
    tanidisit    
     17 days ago
    0

    I would like to thank you for your time and to inform you that I have found a solution. I updated VirtueMart from version 4.6.4 to 4.6.6 and the coupon application is working properly.