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

This topic has 4 replies, 3 voices, and was last updated 9 years, 7 months ago ago by Eva Kemp

  • Avatar: stear
    stear
    Participant
    September 17, 2014 at 13:30

    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
    Support staff
    September 17, 2014 at 14:03

    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
    September 17, 2014 at 14:36

    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
    Support staff
    September 17, 2014 at 15:24

    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.

  • Viewing 4 results - 1 through 4 (of 4 total)

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

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.