How to store many product prices in a flexible way?

I want to build a store in which products have a little wizard through whom the price is determined. In this case, I am talking about printed products.

So, for a small example, when you come to the store and want to print a business card, you can decide whether you want to print black and white or color, if you want to choose thick paper or thin, if you want to print 100, 200, 500 or 1000 pieces, etc.

In the end there will be a price for let say: black and white, thick paper, 200 pieces => 40, - $

In reality, you have many more choices. Since you may think that there are many prices for which there is no formula .

So my question is: how can I handle the prices?

My first idea: decorator pattern.

But when I thought about it, this is not a good idea. Since I said that there is no real formula, I also need to generate a wizard (which may be different if you want to print greeting cards). I also want to be able to change the price through the admin interface or add a product or add a new “solution”, for example, “do you want glossy paper?”. to the product or remove it (and still keep the prices intact).

So now I’m thinking about using a tree for each product in which I can add a level (new solution), resort levels, etc.

, . , , , .

, , , , , , , , ?

+3
1

, , , , .

, , , , , , , # 2 , , , - , , , , , - , , , , .

-, , , . , .

, . , ( ), " ". , 10 , 2, 8 - , , , , . 8 . , , , , , .

. , , , , , .

, , 3 3 :

    • Light
    • Green
    • Fold
    • Bind

:

        Light   Regular Card    Red     Blue    Green   Print   Fold    Bind
Light                           0.05    0.05            0.001           0.50
Regular                         0.06    0.05    0.07    0.001   0.02    0.80
Card                                    0.06            0.002           0.90
Print                                                   0.002   
Fold                                                            
Bind                            

, .
:

  • - / .
  • ( ), ,
  • (.. , ) - , , , , .

- , , (.. 100 , 10). , , - ( 0,001 0,50 , $5 )

, , , .

, . , , ( ) , .

(), , .

, , . , Dell - . , , , , : " , . , ?"

- . - , , , , , .

, , , , , , 200 50 . (, , ), . , .

, - , - , , . 20 /, .

Lasty, , . - ( ..) , , , 0,00234 , . , .., , , , , ( - ). ( n- , ), , , , . , , .

Update

, , Light Paper, Red , . ? /, /, /. , , .

, , .

, . , . .

, Light paper, red, print. 0,05 ( !), 0,001 ( ), 0,051 . 300 , 15,30 .

, , 50 , 6 , 300 . , 6 ( 0,50 ) 3,00 . , 18,30 . .

, , , :

. , / (, ), , . , / vs regular/red - , .

, ...

, , , (300 , 6 ) , :

Pricing matrix shows cells where options collide to provide pricing information

( /, /), , . . ( / - )

/, ( , ). , (, Print Reverse), . : " " " ".

, , , , :

  • ( )

№ 1 , . , "light/bound" , :

  • ()

, .

! Woo!

, , , ?

, . - .

, , , . /, .

, :

  • - , , 4 , ..
  • (/)

, . , , , , - , , .

. , , , , . , /, , .

, (.. - ).

, - Light, Red, Print, Fold , Light, Red, PrintFold, .

, , , , ( ), :

  • (.. , , )

-Adam

+7

Source: https://habr.com/ru/post/1702773/


All Articles