@@ -7,28 +7,34 @@ class ProductOptionsModifier(BaseCartModifier):
7
7
This modifier adds an extra field to the cart to let the lineitem "know"
8
8
about product options and their respective price.
9
9
'''
10
- def add_extra_cart_item_price_field (self , cart_item ):
10
+ def process_cart_item (self , cart_item ):
11
11
'''
12
- This adds a list of price modifiers dependeing on the product options
12
+ This adds a list of price modifiers depending on the product options
13
13
the client selected for the current cart_item (if any)
14
14
'''
15
15
selected_options = CartItemOption .objects .filter (cartitem = cart_item )
16
-
17
16
for selected_opt in selected_options :
18
17
option_obj = selected_opt .option
19
- data = (option_obj .name , option_obj .price * cart_item .quantity )
18
+ price = option_obj .price * cart_item .quantity
19
+ data = (option_obj .name , price )
20
+ # Don't forget to update the running total!
21
+ cart_item .current_total = cart_item .current_total + price
20
22
cart_item .extra_price_fields .append (data )
21
-
22
23
return cart_item
23
24
24
25
25
26
class TextOptionsModifier (BaseCartModifier ):
26
27
"""
27
- THis price modifier appends all the text options it finds in the database for
28
+ This price modifier appends all the text options it finds in the database for
28
29
a given cart item to the item's extra_price_fields.
29
30
"""
30
- def add_extra_cart_item_price_field (self , cart_item ):
31
+ def process_cart_item (self , cart_item ):
31
32
text_options = CartItemTextOption .objects .filter (cartitem = cart_item )
32
33
for text_opt in text_options :
33
- data = ('Text: "%s"' , text_opt .text_option .price )
34
+ price = text_opt .text_option .price
35
+ data = ('Text: "%s"' , price )
36
+ # Don't forget to update the running total!
37
+ cart_item .current_total = cart_item .current_total + price
38
+ #Append to the cart_item's list now.
34
39
cart_item .extra_price_fields .append (data )
40
+ return cart_item
0 commit comments