我如何做到這一點卡住思路: 我有購物車,我想創建一個2×,3×2,5X3的折扣優惠券系統等公式優惠2×3×2等PHP
但我無法解決這個問題,得到一個公式,並顯示應用優惠券後的總價。
例如:商品價格:$ 5美金,我有一個優惠券2×1:
If I buy 2 items: TOTAL: $5,00 usd (2x1)
If I buy 3 items: TOTAL: $10,00 usd (2x1 + 1)
If I buy 4 items: TOTAL: $10,00 usd (2x1 + 2x1)
以同樣的方式。項目價格:5美元。現在我有一張優惠券3x1。
If I buy 2 items: TOTAL: $10,00 usd (3x1 NOPE!)
If I buy 3 items: TOTAL: $5,00 usd (3x1)
If I buy 4 items: TOTAL: $10,00 usd (3x1 + 1)
If I buy 5 items: TOTAL: $15,00 usd (3x1 + 2)
If I buy 6 items: TOTAL: $10,00 usd (3x1 + 3x1)
If I buy 7 items: TOTAL: $15,00 usd (3x1 + 3x1 + 1)
如何獲取使用優惠券在PHP總價格是多少?
是該項目的價格很重要?您的示例顯示具有相同價格的所有項目。如果我把兩件物品放在5美元,兩件放在6美元,會怎麼樣? – Gordon
對於需要使用系統的客戶,我感到很遺憾,他們會以2的價格銷售6件產品,但3件的價格爲5件。 – hobbs