• Resolved GreenRain37

    (@greenrain37)


    Site: Example

    Link: Instructions

    I have discount code box which requires javascript to indicate when code is valid.

    Javascript file is here: wp-admin/js/discount.js

    Final step in the instruction is to paste this into the “website section”:

    <script type="text/javascript" src="https://yourwebsite.com/discount.js"></script>

    Since the path is /wp-admin/js/discount.js, I change to:

    <script type="text/javascript" src="https://yourwebsite.com/wp-admin/js/discount.js"></script>

    I paste in PayPal page, nothing.

    I paste in themefunctions.php, whitescreen.

    Therefore I don’t know what to do.

    Anyone know a solution?

    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • why there’s that file in wp-admin? Did you put it there? If yes … not a great choice, but whatever.. ??

    So take a look here:
    https://volatylthemes.com/footer/

    Thread Starter GreenRain37

    (@greenrain37)

    technically it is supposed to be .com/discount.js and right now is .com/wp-admin/js/discount.js

    i do not understand the process itself of how this script will activate on the PayPal form, or how to implement (where to paste script)…

    Thread Starter GreenRain37

    (@greenrain37)

    @d4z_c0nf

    I do not have a child theme… these snippets have child theme in them.

    Also I do not know where to paste the script to activate on PayPal form.

    Thread Starter GreenRain37

    (@greenrain37)

    ┈┈╱╱▏╱╱▏
    ┈┈▇╱▏▇╱▏
    ┈┈▇╱▏▇╱▏
    ┈┈▇▇▇▇╱▏
    ┈┈▇╱▏▇╱▏
    ┈┈▇╱┈▇╱┈
    ______________
    ┈┈╱╱╱╱╱▏
    ┈┈▇▇▇▇╱┈
    ┈┈▇╱▏┈┈┈
    ┈┈▇▇▇┈┈┈
    ┈┈▇╱╱╱╱▏
    ┈┈▇▇▇▇╱┈
    _____________
    ┈╱╱▏┈┈┈
    ┈▇╱▏┈┈┈
    ┈▇╱▏┈┈┈
    ┈▇╱▏┈┈┈
    ┈▇╱╱╱╱▏
    ┈▇▇▇▇╱┈
    _____________
    ┈╱╱▏┈┈┈
    ┈▇╱▏┈┈┈
    ┈▇╱▏┈┈┈
    ┈▇╱▏┈┈┈
    ┈▇╱╱╱╱▏
    ┈▇▇▇▇╱┈
    ┈╱╱╱╱╱▏
    ┈▇▇▇▇╱▏
    ┈▇╱▏▇╱▏
    ┈▇╱▏▇╱▏
    ┈▇╱╱▇╱▏
    ┈▇▇▇▇╱┈

    Here is what I done so far:

    I went to this link and copy HTML snippet:

    // Add scripts to wp_footer()
    function child_theme_footer_script() { ?>
        <script type="text/javascript" src="https://drivesafe2015.org/wp-admin/js/discount.js"></script>
    <?php }
    add_action( 'wp_footer', 'footer_script' );

    Still, when I use promo code box there is no result.

    For example you can try code 5OFF and nothing happens (supposed to be javascript popup window.

    Where did you add that code snippet? I would remove it and add it to your site this way:

    1. Install the Header and Footer plugin. This plugin will allow you to add script to the head section of your site.
    2. After installing and activating the plugin, go to Setting → Header and Footer and copy & paste the link into the Code to be added on HEAD section of every page field:
      <script type="text/javascript" src="https://drivesafe2015.org/wp-admin/js/discount.js"></script>
    Thread Starter GreenRain37

    (@greenrain37)

    @d4z_c0nf

    Either this does not work or I did something wrong (probably the latter).

    @crouchingbruin

    I downloaded the plugin and pasted the above code into both head section of every page and home page fields and the PayPal discount code box script still is not working.

    When I do a view source on your site, I see the link, so the code is there and available.

    You need to make a change to your discount.js code, though. These two array definitions:

    var coupons = new Array (  // place to put coupon codes
      "5OFF",                 // 1st coupon value - comma seperated
      "50FF",                 // 2nd coupon value - add all you want
    );
    var coupdc  = new Array (  // place to put discounts for coupon vals
      25,
      25,
    );

    You need to remove the comma after the last value in each array so it looks like this:

    var coupons = new Array (  // place to put coupon codes
      "5OFF",                 // 1st coupon value - comma seperated
      "50FF"                  // 2nd coupon value - add all you want
    );
    var coupdc  = new Array (  // place to put discounts for coupon vals
      25,
      25
    );

    Thread Starter GreenRain37

    (@greenrain37)

    IT WORKS!

    The problem was the commas; there were 3 values originally, and we left the commas unknowingly.

    Thank you so much to both for your help ??

    Thread Starter GreenRain37

    (@greenrain37)

    [resolved]

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to upload javascript?’ is closed to new replies.