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.

Additional Donation Amt

kscotbarrkscotbarr Member
in Bugs & Feature Requests edited October 2008
Our organization is a non-profit and is running our "store" on a "suggested donation" basis. I've gone in and modified (using jQuery) our cart and checkout verbage to reflect that these are donations and not purchases. This is all fine and good.

What we'd like to also do is give people the option of adding an additional donation at checkout. I set this all up using the tax field as my additional donation line. Everything is dandy until the total is updated when I choose a shipping option or click submit, then the additional donation gets zeroed out.

Can you point me in the right direction as to how to make this work?

I'll whisper a link to our development site. Thanks.
  • brettbrett FoxyCart Team
    This has actually come up once or twice before...
    The best way to do this is on the add-to-cart, not on the checkout. It is possible to manipulate the tax calculation in 032, though, so you could conceivably do it there, but it's definitely an involved hack. (I'm not sure about 040 at this point, but all the js is rewritten so it'll either be much easier or much more difficult.)

    You could also modify all the language in 040 using the "language" page on the admin. No more jQuery language hacks necessary!

    Another option for an additional donation on checkout could be...
    - Create a donation form on the checkout page.
    - Check the JSON on pageload. If no extra donation exists in the cart, display the form, hide the checkout.
    - If they say "No, No extra donation please," hide the form and display the checkout.
    - If they do donate, post back to the cart but redirect back to checkout with &cart=checkout
    - If the JSON has the extra donation product in it, hide the form and display the checkout.

    That could work?
  • The language page is really helpful, thanks.

    I'd like to try and make the additional donation on checkout work using the process you suggested. My only hang up is writing the conditional statement to check the JSON object. I'm thinking that I would treat the additional donation as a product and give it a code of, say, "000". Then I would check the JSON object to see if a product with that code existed. Can you help with my syntax? I'm guessing it would be something like:
    <script type="text/javascript">
    $j(document).ready(function() {
    	//check for Additional Donation
    	var addDonation = 0;
    	var productCount = fc_json.product_count;
    	while (i <= productCount) {
    		if (fc_json.product[i].code == '000') {
    			addDonation = addDonation + 1;
    	//if there is an additional donation in the cart, hide the add donation form
    	if (addDonation < 1) {
    	} else {
    		//if there isn't an additional donation, hide the cart

    I'm pretty new to javascript so please excuse any glaring errors. Thanks for your help.
  • lukeluke FoxyCart Team
    This is a little beyond the support we generally provide since you're asking about other technologies (JSON and JavaScript), not just about FoxyCart. We're also fans of handing out fishing poles instead of fish. You're on the right track here. Check out this page for more info on how to use the JSON:
    As for JavaScript, google "javascript tutorial" and you'll probably find a lot of great tools to get you started. w3schools is also an excellent reference that I use quite often. Give that a try and if you're still stuck, please feel free to post back here and we'll help you out further.
  • Fair enough, thanks. Let me know if you ever hear of someone else implementing the same sort of functionality. I'll work on this and post back if I get it working.
Sign In or Register to comment.