I added the code in the same way and the same code as shown in these two post. Could you please see these link and their directions because I can not explain you where i added these codes.
I sorted this out i changed the position of code from product liquid template and it worked.
Thank you so much.
Lets get in touch.
awesome. Please mark my message as solution :)