I'm need to remove the quote marks from the product name because it is messing up the Data Layer.

$product['name'] = $item->getName();

How can I do it in the above code? Thanks

  • Does that mean your product names are like this 'name' ? – Kingshuk Deb Apr 27 '17 at 19:05
  • No some my product names have quote marks in them, for example, Natures Grace "Grace" Figurine. And I get errors: Uncaught SyntaxError: Unexpected identifier – Freejoy Apr 27 '17 at 19:11

Try this

$product['name'] = str_replace('"', '', $item->getName()); // This will remove all double quotes from product name.
  • How could I add that to the above code? It seems I remember Magento having some kind of code for this. Not sure. – Freejoy Apr 27 '17 at 19:17
  • Updated the code. Check now. – Kingshuk Deb Apr 27 '17 at 19:22
  • If the answer helps kindly try to accept it. – Kingshuk Deb Apr 27 '17 at 19:34
  • I think it will work, but I might have the wrong place targeted. : ) Be back – Freejoy Apr 27 '17 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.