can't create simple cart button in WordPress

Discussion in 'Integration' started by dale_sellers, Oct 29, 2014.

  1. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    I'm having great difficulty at creating a simple cart button in WordPress. I configured the code to add the product and send the user to the basket.

    In a regular php page, outside of WordPress, the button code works:
    http://www.lifeleap.org/222.php

    With the same code, in my WordPress page, it does nothing:
    http://www.lifeleap.org/shopping2/

    I thought it might be a WordPress plugin or theme issue, so I created a fresh test install of WordPress, with no plugins, using the Twenty Fourteen theme. But the button on a page still does not work:
    http://lifeleap.org/manage-test-blog/

    Maybe I'm doing something wrong, but I am getting nowhere. I created a support ticket at aMember, and after a week, no luck.

    The support from aMember told me the code should be uncommented. So I came up with this:

    <!-- Button/Link for aMember Shopping Cart -->
    <script type="text/javascript">
    if (typeof cart == "undefined")
    document.write("<script src='/manage/application/cart/views/public/js/cart.js'></script>");
    </script>
    <input type="button" onclick="cart.addBasketExternal(this,6); return false;" value="Enroll Now">
    <!-- End Button/Link for aMember Shopping Cart -->

    But that is pushing code...
    Code:
    ;)
    ... outside of script code. Anyone have any suggestions on how to create a simple cart button in WordPress that adds a product and sends user to the basket? Thank you for any help.
  2. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    The fix was to put the script in the button in a js file, and call it the head using something like:

    Code:
    <script type="text/javascript" src="/js/myscript.js"></script>
    I used the CSS & Javascript Toolbox to accomplish this.

    Hopefully this will help someone if they ever have this issue.
    caesar likes this.
  3. invictum594

    invictum594 New Member

    Joined:
    Mar 25, 2014
    Messages:
    22
    Crap I want to do this, but I'm a total noob when it comes to CSS, what is CSS * Javascript Toolbox and how did you create a JS file?
  4. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    CSS * Javascript Toolbox is a WordPress plugin. Purchase the pro version to support these guys - great plugin, especially with aMember.

Share This Page