• Resolved caleb1

    (@caleb1)


    I am trying to make a link within the woocommerce checkout privacy policy text that opens a popup window.
    Specifically the following code:
    <a href="https://straightawayfarms.com/policies.html" target="popup" rel="noopener">

    But when I do that and click save, it seems to remove the entire “onclick=….” from the link and becomes this:
    <a href="https://straightawayfarms.com/policies.html" target="popup" rel="noopener">

    Almost like it does not allow use of javascript within those settings fields?

    Does anyone know how else I could get a link in that privacy policy text to open as a popup window?
    Thanks.

    • This topic was modified 3 years, 11 months ago by caleb1. Reason: fix the formatting so that the code read as text not applied to the message
    • This topic was modified 3 years, 11 months ago by caleb1.
Viewing 7 replies - 1 through 7 (of 7 total)
  • It’s not allowed. Just add an ID or class selector and write your JS in your child theme.

    You could also copy over the template file over to your child theme and write it there, but I wouldn’t suggest it.

    Thread Starter caleb1

    (@caleb1)

    Thanks for the reply @serafinnyc .
    I am not an expert with code and programming, especially js.

    Do you know where I could find the exact code to use and where to insert it to do what you are suggesting? I tried googling, but I could not find anything specific….

    Really appreciate your help.

    Create a child theme and inside the child theme create a folder called JS and then create a file called custom.js

    Enqeue that file either in your child’s function file or in a custom theme functions.

    If you’re not into coding then look for a plugin called “Insert Header & Footer” and with that you can add JS there.

    Thread Starter caleb1

    (@caleb1)

    Thanks for the response.
    Sorry to keep asking dumb questions, but I add the code to custom header and footer, but how do I tell it to use that code on the items with a class?
    Every time I try to find an answer by googling I can find lots of details on how to add js to a page or site but not to a specific item with an class. I figured out that I can add a function in script and then call it with onclick=”function()”, but the function() is also apparently not allowed in the woocommerce settings.

    Does anyone know how I can tell it to run this code when the item with said class is clicked?

    Thanks again.

    No question is ever dumb. But I will say that this type of question isn’t really supported in this forum. Due to the fact that it is custom work.

    I’m going to forward you to how to trigger a modal/popup. Click here.

    Make sure your policy is somewhere either on the page as a html box or in your footer of your child’s theme. Or use a plugin that can help create these modals for you.

    Thread Starter caleb1

    (@caleb1)

    Thanks for your help. I decided to get a plugin that creates a modal but that uses a shortcode and you cant even insert a shortcode in the woocommerce settings.
    I think I am spending too much time on such a small detail, I think I will decide to live with letting it open in a new tab.

    Thanks again.

    You’re very welcome ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘javascript code in settings?’ is closed to new replies.