Forum Moderators: open

Message Too Old, No Replies

Dropdown calculates and updates static field

Cart script to select shipping method and total

         

salewit

4:56 am on Oct 14, 2008 (gmt 0)

10+ Year Member



I have a shopping cart script written in PHP. We've now decided to offer multiple shipping method choices. I'm having some trouble dealing with this without have to show another page.


Widgets 5 .99

Subtotal 4.95

Dropdown Shipping Choices (1st Class $3, Priority $6, Express $22, etc)

Total ?.?

Ideally a user would select a drop down option, and the total would be updated in place of the ?.?.

Possible? Is this AJAX?

daveVk

6:31 am on Oct 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a stage where the number of widgets can be selected, and the subtotal is updated in place ? If so, then try extending it to do shipping also.

salewit

3:27 pm on Oct 14, 2008 (gmt 0)

10+ Year Member



Well I've got the cart contents stage, but at that point we don't have the customer's location info yet. I don't think I've ever seen it where you select your desired shipping method at the cart stage either. It's usually a "Go Checkout" button at this point. Then the customer enters their address info. I could add another page inbetween the address collection and credit card info, but I'm trying to keep the # of steps down.

rocknbil

7:25 pm on Oct 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are your shipping methods set by your program or are you dynamically connecting to the API of your shipper to get shipping amounts?

If you have a set array of shipping served up by your PHP, you could get the array before outputting the form and store the values in JS variables or arrays. This would allow you to just use client-side Javascript. It would be a bit complex, as you'd have to store a good deal of values, but it would work.

If you are good at Ajax, you can do the same thing by doing an http request at run time to your database.

But if you're connecting to one of the API's (presuming USPS by your examples) this requires an XML string sent to the API, which returns an XML string that needs to be parsed to get a result. I'm sure there is an Ajax solution for this, but it seems to me the time spent in the request from your page to the API might be just as slow as adding another page.

We use the following method and we have FOUR simple steps. At any point - Add to cart, click cart link, or checkout:

- The first is a summary of the current cart, and below is "Enter your shipping destination" - Country for non-us, or zip code for default, US.

- Then next step you'd skip. We check order for in-stock items and ask them what they want to do (keep entire order until all items come in, ship what's in stock and the rest when they come in at no extra charge, remove out of stock items from order.) A lot of stores don't display out of stock items. We get LOTS of sales for out of stock items (maybe because our description of out of stock is accurate, describing how long it will delay the order.)

- Next we connect with the shipping API for the adjusted order, and present a link to ALL possible shipping with detailed values:
First Class: (if it's light enough) $2.00 (5-7 business days)
Priority: $5.00 (3-5 Business days)
Express: $20 (1-3 Business days)

- The final page is CC, shipping, and billing info. At the upper right is an OPTIONAL login box for returning customers if they want to populate the form.