I am storing the value of a textfield which is in the backend (woocommerce product) into a variable then displaying it on the front end. I had no issues with this until recent updates. Now this code seems to break WPML. The woocommerce multilingual product translation page does not load with this file active. The file is in my child theme in a woocommerce sub-folder.
woocommerce/single-product/stock.php
The full (quite short) file is here https://pastebin.com/GEgSi4jt
The lines that cause the problem are the ones that try to store the value of the textfield in the backend in the variable $baba_stock_message
Later I echo this message to the front end.
Am I doing the storage of that variable the wrong way?
wrapping that line in
if (function_exists('types_render_field')) {
stops WPML breaking but I am not sure if my textfield will still be displayed on the front end.
You can see my WP error log for when this is active and woocommerce multilingual fails to load her if needed. It si short just the relevant parts https://pastebin.com/BxfTkVjX
types_render_field is only available on the front end, not in the back end, which is probably why checking the function exists appears to fix the issue.