Coupon functionality in a completely custom cart

vossavantvossavant Member
in Help edited December 2010
Guys,

My apologies in advance for completely jettisoning the default cart in favor of a built-from-scratch cart, then asking you to help me troubleshoot it.

However, my client had some pretty intense custom requirements for the cart -- like showing MSRP, total savings, and product thumbnails -- so simply restyling the default cart wasn't enough.

Now I've been asked to add coupon functionality. I've been able to add the "Add coupon" link, get the box to show, and the discount to apply. The problem comes when I apply the coupon in the cart. When I hit enter to apply the coupon, nothing happens visually. In the default cart, the coupon name and total discount are shown, and the grand total is updated to reflect the discount.

In my custom cart (I suggest going here and adding the product to the cart; then enter code XMAS5), I can't determine how you guys get the coupon discount to show and the grand total to update. I tried finding a function in the source code, but no luck. (If you proceed to checkout, you'll notice that the discount is applied, but in the cart there is no visual cue that this happened.)

Would you be able to share how this piece is injected into the code? I'm fairly certain I can figure out the rest with jQuery. Thanks in advance.

EDIT: Brett, I stumbled across a burst of productivity you left on Github, and suspect this may hold the key. I'm going to give this a closer look after my stomach isn't so angry at me for being utterly devoid of food.
Comments
  • lukeluke FoxyCart Team
    Hey vossavant. As for updating the cart, we're just calling fc_UpdateCart() which submits the form on the cart with the input named coupon filled in. Once a valid coupon has been added to the cart update, the totals for the transaction will be correct on our side. If you're building out a custom cart completely... you're probably creating a lot more work than you need to. 071 has product thumbnails built in by default and MSRP and total savings should be pretty simple to do with some product attributes and some jQuery. You could just grab everything you need out of the fc_json and adjust the cart display however you like. But anyway... if you're moving in the right direction and it works for you, more power to you. Just keep in mind, if you need to upgrade the store in the future, you might be hurting yourself by not keeping things standard.

    My stomach often yells at me when I get coding and forget about things like lunch and dinner. :)
  • brettbrett FoxyCart Team
    I really love that cart. A lot. We need a template language. (We need to rebuild shipping first though ;)
Sign In or Register to comment.