Support » Plugin: Custom CSS and JavaScript » Having trouble with my JavaScript working

  • Resolved Morgan



    Downloaded the plugin and am enjoying it. However, I am having trouble using it to create some functionality that I want to achieve using WooCommerce and the WooCommerce Product Bundles plugin, specifically.

    In essence, I have some JavaScript that works when used outside the plugin, but when I move it into the plugin, it no longer works. Now it’s likely that this is an error on my side, but regardless, I can’t seem to get it to work. Any help would be appreciated.

    Here is the code:

    <script type=”text/javascript”>
    jQuery( document ).ready(function() {
    jQuery(‘#smartphone-type’).on(‘change’, function() {
    if (jQuery(‘#smartphone-type’).val() == ‘iPhone’) {
    jQuery(‘.has_qty_input .bundled_qty’).val(‘1’);
    } else {
    jQuery(‘.has_qty_input .bundled_qty’).val(0);

    My site is The above JavaScript – when working – should update the quantity of one product (anything with the smartphone-type attribute) to 1 or 0 based on the selection of the type of smartphone made by the user.

    Thanks for the help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Potent Plugins


    Hi there,
    Thanks for getting in touch! Please remove the <script> tags from the start and end of your script – they aren’t necessary and will cause problems if included. That should fix things!

    If you’d like to share your experience using the plugin, you can rate it at 🙂

    Thread Starter Morgan



    Thanks for the quick reply.

    Setting the syntax of my code aside, here is what I am trying to achieve. On my site, I use WooCommerce and a WooCommerce extension called Product Bundles.

    I am somewhat undecided on a theme, but I know that I am going to use Product Bundles. And I want the functionality I described above to work regardless of the theme I choose (and I don’t want to have to re-code it or port the code to a new theme if I decide to switch themes).

    So, with that context, is this the kind of thing that your plugin is designed to achieve / deliver?

    Plugin Author Potent Plugins


    This plugin will allow you to run a custom Javascript on all pages of your site, and this should work regardless of which theme you use. As far as whether your Javascript code itself will be compatible with any theme, that really depends on your code and how it’s written, not on the plugin. Looking at your code, it looks like you’re using IDs and class names that shouldn’t be theme-dependent, but I can’t say for sure.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Having trouble with my JavaScript working’ is closed to new replies.