My favorites
▼
|
Sign in
substruct
Open-source Ruby on Rails E-Commerce
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
103
attachment: delete_previous_promotion_before_compare_minimum_cart_value.patch
(1.3 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Index: /home/edmundo/workspace_aptana/trunk/vendor/plugins/substruct/app/models/order.rb
===================================================================
--- /home/edmundo/workspace_aptana/trunk/vendor/plugins/substruct/app/models/order.rb (revision 78)
+++ /home/edmundo/workspace_aptana/trunk/vendor/plugins/substruct/app/models/order.rb (working copy)
@@ -48,18 +48,18 @@
# No promo code? Not active? No deal...
return if !promo || !promo.is_active?
+ # Delete the last line item representing a promotion if any.
+ # We allow only one promotion to be applied.
+ self.order_line_items.delete(self.promotion_line_item) if self.promotion_line_item
+
# Make sure it's valid to add
if promo.minimum_cart_value
- return if promo.minimum_cart_value > self.total
+ return if promo.minimum_cart_value > self.line_items_total
end
logger.info "PROMO MIN CART VALUE PASSED"
- # Don't allow more than one promotion?
- # This destroys any line items created previously.
- self.promotion_line_item.destroy if self.promotion_line_item
-
- # Assign proper promotion ID
- self.promotion_id = promo.id
+ # Associate the order with the promotion.
+ self.promotion = promo
# Add any line items necessary from promotion.
oli = OrderLineItem.new
Powered by
Google Project Hosting