Please organize, design, test, document, and deploy your code as if it were going into production.
Write a program that can price a cart of products from different countries, accept multiple products, combine offers, and display a total detailed invoice in USD as well.
Available catalog products and their respective price in USD (regardless of the shipping country): Hint: see below, how to calculate each item shipping fees
Item type | Item price | Shipped from | Weight |
---|---|---|---|
T-shirt | $30.99 | US | 0.2kg |
Blouse | $10.99 | UK | 0.3kg |
Pants | $64.99 | UK | 0.9kg |
Sweatpants | $84.99 | CN | 1.1kg |
Jacket | $199.99 | US | 2.2kg |
Shoes | $79.99 | CN | 1.3kg |
Each country has a shipping rate per 100 grams
Shipping rates: Hint: see below, how to calculate each item shipping fees
Country | Rate |
---|---|
US | $2 |
UK | $3 |
CN | $2 |
The program can handle some special offers, which affect the pricing.
Available offers:
- Shoes are on 10% off.
- Buy any two tops (t-shirt or blouse) and get any jacket half its price.
- Buy any two items or more and get a maximum of $10 off shipping fees.
There is a 14% VAT (before discounts) applied to all products, whatever the shipping country is.
The program accepts a list of products, outputs the detailed invoice of the subtotal (sum of items prices), shipping fees, VAT, and discounts if applicable.
e.g.
Adding the following products:
T-shirt
Blouse
Pants
Shoes
Jacket
Outputs the following invoice:
Subtotal: $386.95
Shipping: $110
VAT: $54.173
Discounts:
10% off shoes: -$7.999
50% off jacket: -$99.995
$10 of shipping: -$10
Total: $433.129
Another, e.g., If none of the offers are eligible by adding one product:
Jacket
Outputs the following invoice:
Subtotal: $199.99
Shipping: $44
VAT: $27.9986
Total: $271.9886
- PHP
- Stick to OO fundamentals in all aspects of your code.
- Stick to SOLID principles.
- Use pre-defined Design Patterns whenever needed in your code.
- Input should be via either (whatever suits you)
- The command line in the form
createCart --product='T-shirt' --product='Blouse' --product='Pants' --product='Shoes' --product='Jacket'
. - Or a simple REST API.
- The command line in the form
- Write unit tests to cover your core code fully.
- No pseudo-code allowed.
- Hosted repository for the program, link to it (e.g. Github, Bitbucket, etc.). Reply with the repo link to the email we sent.
- Code should be well structured, suitably commented, have error handling, and be tested.
- README file, where you describe your solution (design and architecture), how to run the program. You can use pseudo-code here.
Item type | Country | Item price | Weight | Rate | Shipping | VAT |
---|---|---|---|---|---|---|
T-shirt | US | $30.99 | 0.2 | $2 | $4 | $4.3386 |
Blouse | UK | $10.99 | 0.3 | $3 | $9 | $1.5386 |
Pants | UK | $64.99 | 0.9 | $3 | $27 | $9.0986 |
Sweatpants | CN | $84.99 | 1.1 | $2 | $22 | $11.8986 |
Jacket | US | $199.99 | 2.2 | $2 | $44 | $27.9986 |
Shoes | CN | $79.99 | 1.3 | $2 | $26 | $11.1986 |