Click to See Complete Forum and Search --> : Updating checkout page


rostok
02-08-2007, 07:44 PM
Hopefully I will manage to explain my problem and you will have a solution for it :).
I have a checkout page, coded in PHP (by some other coder, not available anymore). On the page I have one table containing shopping cart items and one submission form, to collect all information from the customer. When the page is loaded, the table is filled with data from the temporary data table through SQL query (collected on the previous page, shopping cart page), except for the field about the amount of the sales tax, which is not yet known because I don’t know anything about the customer. So I have a shopping cart table and a blank form below that, ready to be filled with customer’s information.

Now, my question is: How can I calculate and fill the sales tax field in the shopping cart table, if the customer chooses his state from the drop down list in the form? I must say here that the sales tax is only applicable for residents of just one state, Vermont, because the company is based in Vermont. For instance, if the customer chooses Vermont as his state, how this can be translated into sales tax amount, added into the field in the shopping cart table and recalculated the total amount? Should the page be reloaded, with changed value of some variable for the sales tax? Should the JavaScript be used?

After this recalculation, the customer hits the “Make Purchase” button and the form is submitted and the receipt for the purchase is sent.

I’m not very familiar with PHP or JavaScript, so any help is greatly appreciated.


Thanks,
Robert

CarolineBogart
02-09-2007, 04:08 AM
You can do a javascript call to display the tax but you must not depend on that for your final value because it's easy to hack.

You would set the state dropdown to to a postback of the form. You would grab the state, set the tax, and re draw the form using the posted values so that the fields are still filled in when the page is returned to the user.

rostok
02-09-2007, 04:28 AM
Caroline, thank you for your reply.
Now, I perfectly understand your answer about grabbing the changed state etc., but don't know how to code it :(. If I post the code I have to modify, is it appropriate for you to give me some suggestions?

thank you :)

CarolineBogart
02-09-2007, 11:15 AM
sure it's pretty easy. on the select do an submit form on change, in the php build each form item according to its posted value such as
input type=text name=firstname value=$_POST["firstname"]

rostok
02-09-2007, 11:49 AM
You make it sound like it is the easiest thing on earth to do that, lol. Anyway, I appreciate your effort to explain me such a basic stuff, but as I said, I’m not very good with coding, PHP, etc. I’m just trying to help a friend with this problem.
This is the page we are talking about http://www.acustomwindowtreatment.com/checkout.php
At the top of the page you can see the cart items table and sales tax field, which should be calculated based on the selection of the state from the dropdown list in the form below. All information entered in the form should be kept after the selection of the state and calculation is made (I assume that the page should be reloaded/refreshed), so the user shouldn’t have to re-enter them again. After this, he can click on the “make purchase” button at the end of the page, to complete the checkout process.
I’ve searched all over the web for some solution for similar problem like mine, but nothing. I know that this is a trivial problem for somebody experienced with PHP, like you :).
Please, if you can help me, I can send you a zip file with the source code of this page.
Or, if you don’t have extra time, just send me some example code and I will (try) to work from there.


Anyway, thank you.
Robert

CarolineBogart
02-09-2007, 10:08 PM
hi - that page is a 404 for me. It's pretty hard to move from here, you might think about getting a freelancer?

rostok
02-10-2007, 10:34 AM
Hi Caroline,
Hmmm, strange, the IE is giving me 404 error. I've tried the link with Firefox and the page was displayed without a problem. I don't know why IE is reporting error.
Anyway, thanks for your help. Again, if you have time, please, visit the checkout page and give me some suggestions, even if I need to redesign entire page, like separating the cart items table and submission form on different pages.

Regards,
Robert

P.S. Nice cat! :)

CarolineBogart
02-10-2007, 01:02 PM
Usually the checkout is done in stages for exactly this reason. Tell us where you live, next, ok here's your shipping and tax, next. Now you can do it on this page, but you have to (a) run an ajax query or refresh the browser with the tax and shipping info upon state selection, (b) re-calculate these things on the server after form submit to make sure the form data you receive is not hacked.


I'd help you with code you already have, fix a bug or something, but it's kind of hard to post the whole solution in a forum.

rostok
02-10-2007, 03:32 PM
Yes, you're absolutely right about checkout stages, but the checkout system is as it is coded, so I'll first exhaust all possibilities to fix this tax thing with the present code. If it still can't be fixed, I'll go with your suggestion about stages.
I've send you a private message, in case you find some time or find this a little bit challenging :).

Thanks,
Robert