0

Pretend you are a seller and have a cart on your web page based on woocommerce. A buyer wants to buy 600g of a product. It is the maximum quantity he may buy. However he also wants 30g of one product and 40g of another. How can one add these products up before they reach the cart in PHP?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Po4
  • 1
  • 2
    Hey Po4, this is a pretty broad question, you may get more traction with this question if you can post what approaches you've tried already, and any specific roadblocks or problems you have with that approach. – Andy Hoffner May 03 '19 at 15:45
  • Welcome to Stack Overflow. Please take a moment to read [How to Ask](https://stackoverflow.com/help/how-to-ask) then [edit] your question accordingly. Creating a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) will maximize the help you get here. – SecretAgentMan May 03 '19 at 17:02
  • Your question is unclear and too broad. As explained by others, you should need to clarify **and provide some related code** in your question, as StackOverflow is not a free coding service. – LoicTheAztec May 04 '19 at 02:52
  • Weight of products is predefined and is equal to 600g all the times. * There is one mandatory primary category and the other categories are optional. * A customer can add 1 product from the primary category only ( and can change for other one but still there should be 1 main category product ) * At the beginning, when the product is added from the primary category, the weight is 600 g and when adding the next products the weight of the product from the primary category is reduced by the weight of the newly added products. * Maximum amount of products is 20 – Po4 May 04 '19 at 12:29
  • Example: * Customer adds product A from the primary category - a weight should be 600g of product A * Customer adds product B ( weight is 30 g) - a weight should be 570g of product A and 30 g of product B * Customer adds product C ( weight is 50 g) - a weight should be - 520g - A, 30g - B and 50g - C – Po4 May 04 '19 at 12:29

0 Answers0