Invalid JSON generated for variation data containing quotes (“)
-
WooSL outputs variation data into a
data-variationattribute and later stores it in a cookie.
When a variation label contains a double quote (e.g.5.5" x 95"), the plugin generates invalid JSON. This causesJSON.parse()to throw and breaks the Save for Later functionality.Steps to reproduce
- Create a variable product with an attribute value containing quotes, e.g.:
5.5" x 95" - Add the product to the WooSL Save for Later list.
- Click Save / Add again.
Actual result
A JavaScript error occurs:
Uncaught SyntaxError: Expected ',' or '}' after property value in JSON at JSON.parse at woosl_add_productThe stored cookie contains invalid JSON, for example:
"variation":"{"attribute_size-h-x-w":"5.5" x 95""}"Recreate the issue on https://swedishdoorco.com/ – sing up as a user, add items to cart and click save for later and inspect the console. You will see the errors I’m referring to.
Let me know when you release a fix.
Thanks,
Greg - Create a variable product with an attribute value containing quotes, e.g.:
You must be logged in to reply to this topic.