Escape javascript variable ? - by stear - on WordPress WooCommerce support

Solved3 replies3 participantsUpdated by Eva Kemp

  • Avatar: stear
    stear
    Participant

    Hi

    Some strings are stored in javascript variable (“successfully added to your shopping cart” for example) but they are not escaped. There is no problem with the english default string but if the translated string have quote (‘) it will create a javascript syntax error.

    3 Answers

    Avatar: Robert Hall
    Robert Hall
    Participant

    Hello,

    Please provide us with wp-admin and FTP credentials in Private Content.
    Also show us screenshots where is the problem.

    Regards,
    Robert Hall.

    Avatar: stear
    stear
    Participant

    I’ve already fixed the problem by changing the translated string.

    The problem is in your php generated javascript code for add to cart ajax.

    example

    var successfullyAdded = ‘successfully added to your shopping cart’;

    The variable isn’t escaped so if there is a quote in the translated string there will be a javascript syntax error.

    Avatar: Eva
    Eva Kemp
    Participant

    Hello,

    That’s great you’ve fixed the issue yourself.
    If you have any questions feel free to ask us.

    Have a nice day!
    Regards,
    Eva Kemp.

The issue related to '‘Escape javascript variable ?’' has been successfully resolved, and the topic is now closed for further responses