Jump to content

Recommended Posts

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:

-UPS Ground $12

-2nd Day Air: $20

Alaska, Hawaii, Puerto Rico, USVI:

-USPS Mail: $20.00

-Global Express: $28.50

 

International:

-Real-time Quotes from USPS

Section Orders:

 

Continental USA: 

1-2 Sections:

-USPS Priority Mail: $8

-3+ Sections

-USPS Priority Mail: $11

International, Alaska, Hawaii, Puerto Rico, USVI:

-1-2 Sections:

-Not Yet Determined

-3+ Sections

-Not Yet Determined

 

 

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

 

Link to comment
https://forums.phpfreaks.com/topic/52859-complex-shipping-rules/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.