Discount calculator base on number of checkout

  arrays, javascript, php

Scenario: We are launching a sales campaign on our digital shop that will run from January 7 th to January 11 th Pacific Standard Time (-16). The promo is Buy 1 frame, Get 10% off | Buy 2 frames, Get 15% off |Buy 3 frames, Get 20% off. Frame(product) id is 8723 and price is $199.99 .

Knowing that the cart data schema if as follows

#schema for the cart:
Cart = [{product}, {product}, ..., {product}]

#schema for the product:
product = { id: number, original_price: money, discounted_price: I }

a. Provide algorithm for the discount that will be used for this sales campaign. The discount only applies up to 6 frames.

b. Explain the logic behind the algorithm composed on a.)

c. From the algorithm on a), provide total amount due when the customer orders 1 up to 6
frames.

Source: Ask PHP

LEAVE A COMMENT