The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Add to Cart and Colorbox Cart Duplication

jodycollierjodycollier Member
in Help edited July 2011
I don't know what's going on, but I simply added some "view cart"/"proceed to checkout" buttons to some of the pages on my site (http://welding-tv.com/the-store). It was working just fine up till now... When I add one item to the cart, it pops up this window, with a correct cart on top; but the bottom cart shows two of the item. If i try to checkout using the bottom cart, it says my cart is empty. But if i use the top form, it actually shows two items on the checkout page, though i only pressed "add to cart" once, and only one was displayed in the cart.

Help! About to run into some major problems due to this. It's probably user error... but i have no idea what caused it.

Screen-shot-2011-07-22-at-11.20.05-AM.png
Comments
  • fixed... i think.

    have no idea why this fixed it, but i removed this code from the header.php css file, and all seems to work just fine.

    <!-- BEGIN FOXYCART FILES -->
    <link rel="stylesheet" href="http://static.foxycart.com/scripts/colorbox/1.3.16/style1_fc/colorbox.css"; type="text/css" media="screen" charset="utf-8" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"; type="text/javascript" charset="utf-8"></script>
    <script src="http://cdn.foxycart.com/welding-tv/foxycart.complete.3.js"; type="text/javascript" charset="utf-8"></script>
    <!-- END FOXYCART FILES -->

    That seems to have fixed it. Am I about to run into more problems I'm just not foreseeing? :)
  • brettbrett FoxyCart Team
    It sounds like you may have had those files included twice, especially if it's still working after you've removed those files. So you should be fine at this point. Definitely let us know if you do run into any problems though. We're here to help.
  • flinx777flinx777 Member
    edited August 2011
    I'm having the same problems as the example above with 2 carts going into the modal window. I'm attempting to check against an array of values based on what is added to an input form before adding product to cart.

    So for example, this input field:
    <input id="couponNum" name="Coupon Number" type="text" />
    

    When the customer adds a a coupon code into this field, on submit of the form, I need to check against an array to check if that coupon code is in the array. I can get the function to work, but when the value does exist in the array, I get 2 carts in the modal window. Not sure what I'm doing wrong.
  • brettbrett FoxyCart Team
    @flinx777, your issue is that you have javascript validation that's doing a $(this).submit();, so your add-to-cart form is being submitted twice, since the FoxyCart javascript also submits it.

    The solution is to use the preprocess event for any add-to-cart link or form validation.
    http://wiki.foxycart.com/static/redirect/javascript
    Usually it's as easy as moving your existing validation inside a preprocess event, and making sure to remove the .submit() calls (and instead just return true to let FoxyCart do its thing.
Sign In or Register to comment.