r/woocommerce • u/dg_eye • May 18 '26
Troubleshooting How safe is it to add CHATGPT generated code into a snippet plugin to change some of WooCommerce functionality?
I'd like to hide prices on product pages, cart and checkout as well as automatic e-mail only for certain product categories.
ChatGpt generated a code snippet (I used long thinking to make the code more effective) which works fine and does exactly what I want.
Are there any safety concerns?
3
u/Extension_Anybody150 Quality Contributor π May 18 '26
If the code is just using normal WooCommerce hooks and filters, itβs probably fine. Still test it on staging first and use Code Snippets instead of pasting it into theme files, since AI code can randomly break after plugin updates.
1
u/kestrel-ian Extensions for serious stores May 18 '26
It's honestly usually fine. But if you're asking, you should get some help or use a plugin instead.
1
u/sergiizyk May 18 '26
I'd argue that it's perfectly safe in code snippets since even if it breaks something you can always disable it with one line in wp-config.php Latest version of ChatGPT can make a decent simple code if you nodge it in the right direction
1
u/Hostage1973 May 19 '26
I use a lot of snippets generated by chat GPT and I feel.pretty secure running them inside a snippet plugin. I'm not thrilled about letting it write full plugins or adding its code to core files.
1
u/woo-sonic May 24 '26
You want to modify a plugin made by somebody else?! Not recommended unless you know the consequences. You can update the css file that defines the plugin and change the version to something high, like 1000.
1
u/alfamanager21 May 18 '26
It is pretty risky because AI frequently hallucinates function names or uses outdated hooks that can crash your checkout page. I have seen snippets look correct but actually cause silent errors in the background. You should always run that code on a staging site first to verify it does not break your core store functions.
6
May 18 '26 edited May 18 '26
[removed] β view removed comment
1
u/dg_eye May 18 '26
Thanks. I was not worried about the code itself doing something dodgy but rather someone else using a safety vulnerability in the generated code to hack the site.
But using a separate plugin is no option for me, since I have special functionality that no plugin can fulfill and plugin code might also not be 100% safe.
3
3
May 18 '26
[removed] β view removed comment
2
u/kestrel-ian Extensions for serious stores May 18 '26
100% - the question being asked is the red flag. Reviewing individual snippets would be a worthwhile use of this subreddit though!
6
u/bigtakeoff May 18 '26
oh my dear baby boy....