I am looking to develop a function for my client’s ecommerce solution. The set of ‘shipping rules’ is kind of complex, and I am perplexed at how exactly I should approach a solution. My client sells a study guide as a complete set, or she sells each 6 sections individually. In total there are 7 products which can be ordered. Let me first give an example of how shipping is determined:
Complete Set:
Continental USA:
[INDENT]-UPS Ground $12
-2nd Day Air: $20[/INDENT]
Alaska, Hawaii, Puerto Rico, USVI:
[INDENT]-USPS Mail: $20.00
-Global Express: $28.50
[/INDENT]
International:
[INDENT]-Real-time Quotes from USPS [/INDENT]
Section Orders:
Continental USA:
[INDENT]1-2 Sections:
[INDENT]-USPS Priority Mail: $8[/INDENT]
-3+ Sections
[INDENT]-USPS Priority Mail: $11[/INDENT][/INDENT]
International, Alaska, Hawaii, Puerto Rico, USVI:
[INDENT]-1-2 Sections:
[INDENT]-Not Yet Determined[/INDENT]
-3+ Sections
[INDENT]-Not Yet Determined[/INDENT][/INDENT]
In the end I want a function where I could pass needed arguments, and then return a $ShippingPrice.
To do this in if/else and case statements seems completely illogical and I’m sure most we’ll agree. I was thinking to set a database up and query to get rates the schema might look something like this:
Table: Shipping Rates
Country | State | Method | CompleteSetCost | SectionCost1-2 | SectionCost 3+
USA | NY | Ground | 12.00 | 8.00 | 11.00
USA | NY | 2nd Day| 20.00 | Don't Do | NULL?
Also, the client is unable/unwilling to change the method of determining shipping, so that's out of the question. I’m really not sure how to approach this, but any help would be much appreciated.
Thank You,
Evan