Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product Comments module displays raw JSON instead of updating the DOM #36093

Open
2 tasks done
jak78 opened this issue May 3, 2024 · 17 comments
Open
2 tasks done

Product Comments module displays raw JSON instead of updating the DOM #36093

jak78 opened this issue May 3, 2024 · 17 comments
Labels
8.1.x Branch Bug Type: Bug FO Category: Front Office NMI Status: issue needs more information Productcomments Module: productcomments

Comments

@jak78
Copy link

jak78 commented May 3, 2024

Prerequisites

Describe the bug and add attachments

When I submit the form to submit a product comment using the native Prestashop Product Comments module, the raw JSON is displayed. Feel free to watch the enclosed screen recording.
The behavior is the same wether the form submission is an error (error message) or a success (no error message).
I can reproduce the issue on both Chrome (latest version) & Firefox (latest version)

Screen.Recording.2024-05-04.at.00.10.19.mp4

Expected behavior

I would expect the HTML page to be updated instead and display a message to the user.

Steps to reproduce

  1. Go to a product page
  2. Click the button to show the product comment form
  3. Submit a comment

PrestaShop version(s) where the bug happened

8.1.5

PHP version(s) where the bug happened

8.1.12

If your bug is related to a module, specify its name and its version

product comments 7.0.0

Your company or customer's name goes here (if applicable).

No response

@jak78 jak78 added Bug Type: Bug New New issue not yet processed by QA labels May 3, 2024
@spanishsnapper
Copy link

Same error present on 8.1.3 (PHP version 8.2)

Screenshot 2024-05-05 at 09 41 49 Screenshot 2024-05-05 at 09 42 03

@leemyongpakva
Copy link

leemyongpakva commented May 9, 2024

@spanishsnapper This bug comes from my recent implementation for @jak78 request make rating mandatory. If you use a theme with override module template (like hummingbird for example), you need add these two lines (inside <script> tag)

  var productCommentMandatoryMessage = '{l s='Please choose a rating for your review.' d='Modules.Productcomments.Shop' js=1}';
  var ratingChosen = false;  

at the very top of your theme's modules/productcomments/views/templates/hook/post-comment-modal.tpl file to make new implementation works correctly.
You can see an example for hummingbird theme at modules/productcomments/views/templates/hook/post-comment-modal.tpl

@spanishsnapper
Copy link

That fixed it - Thank you @leemyongpakva

@jak78
Copy link
Author

jak78 commented May 12, 2024

@leemyongpakva thanks for implementing my suggestion. I use the classic theme version 2.1.1, there is no module template override, but I have the issue. Is there a workaround? I'd love to help solve the issue but I'm a beginner: feel free to provide me with instructions.

@leemyongpakva
Copy link

@jak78 I think it was a cache issue in your case. You can try CONFIGURE > Advanced Parameters > Performance > Clear Cache in Back-Office, and Clear browser cache in Front-Office.

@jak78
Copy link
Author

jak78 commented May 13, 2024 via email

@leemyongpakva
Copy link

Yes, we usually call it Smarty cache. I see you use Classic theme but with its child_classic also. If you have no module template override in your child_classic theme, then I only have one solution left for you (: copy your_site_root/modules/productcomments/views/templates/hook/post-comment-modal.tpl file to your_site_root/themes/classic/modules/productcomments/views/templates/hook folder.

@spanishsnapper
Copy link

@jak78 I see your site is en françias.
I also had to regenerate translations to make sure I had a translation for the new variable on a site that was in Spanish.
Before I did it, the invalid translation was causing a javascript error that prevented the subsequent code from executing.
You could try that to see if it solves issue.

@jak78
Copy link
Author

jak78 commented May 13, 2024

Yes, we usually call it Smarty cache. I see you use Classic theme but with its child_classic also. If you have no module template override in your child_classic theme, then I only have one solution left for you (: copy your_site_root/modules/productcomments/views/templates/hook/post-comment-modal.tpl file to your_site_root/themes/classic/modules/productcomments/views/templates/hook folder.

Thanks @leemyongpakva - I've just done that, then cleaned the Smarty cache and the browser cache, but the issue persists.

@jak78
Copy link
Author

jak78 commented May 13, 2024

@leemyongpakva I've figured out the issue 🎉
One translation contained a ' character. That triggered a JavaScript error as seen on the screenshot below:
Screenshot 2024-05-13 at 14 20 51
I've escaped the character in the translation string and now it works!
Screenshot 2024-05-13 at 14 25 18

@jak78
Copy link
Author

jak78 commented May 13, 2024

I guess there would be some escaping to implement in the module

@leemyongpakva
Copy link

@jak78 Great, we still need some improvements on this feature.

@florine2623
Copy link
Contributor

@jak78 ,

I can't reproduce your issue on my end :

Screen.Recording.2024-05-15.at.14.56.01.mov

I'm using productcomments v7.0.0, PS 8.1.5 and PHP 8.1.13.

@leemyongpakva , does this issue needs a PR ? Should I keep it open ?

Thanks!

@florine2623 florine2623 added Waiting for author Status: action required, waiting for author feedback FO Category: Front Office NMI Status: issue needs more information Productcomments Module: productcomments 8.1.x Branch and removed New New issue not yet processed by QA labels May 15, 2024
@jak78
Copy link
Author

jak78 commented May 15, 2024

@florine2623 did you try to use a ' character in a transation string as described here?

@leemyongpakva
Copy link

@florine2623 Yes, this issue really a need a PR to solve escaping for special character in JS message variables (jak78 case) and 3rd party themes that have its own productcomments template override (spanishsnapper case).

@leemyongpakva
Copy link

leemyongpakva commented May 15, 2024

@jak78 Is ' character above shipped with original productcomments module or customized by yourself ?

@jak78
Copy link
Author

jak78 commented May 15, 2024

@jak78 Is ' character above shipped with original productcomments module or customized by yourself ?

@leemyongpakva the French translation string for 'Please choose a rating for your review.' is missing from the productcomments module translation. I had to customize the string to ensure that the text is displayed in French. My French translation contains a ' character.

@paulnoelcholot paulnoelcholot removed the Waiting for author Status: action required, waiting for author feedback label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.1.x Branch Bug Type: Bug FO Category: Front Office NMI Status: issue needs more information Productcomments Module: productcomments
Projects
None yet
Development

No branches or pull requests

5 participants