johnkock / substruct

Automatically exported from code.google.com/p/substruct
0 stars 0 forks source link

Promotion Bug #186

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a promotion. I added $10 off
2. Apply promo during checkout, and submit. It takes us to shipping page.
3. At this stage, if you click on Continue Shopping and try looking at the
cart, it throws an exception saying item_id is null.

What is the expected output? What do you see instead?
Clicking on cart is expected to show the items in it. Instead it throws
an exception saying accessing "nil".images in /store/show_cart.rhtml.

What version of the product are you using? On what operating system?
OS : Linux 2.6.27-grsec2
App : substruct_rel_1-0-a6

Please provide any additional information below.
Earlier I was not able to use the promotion at all. After some searching, I
found that the issue was fixed at
http://code.google.com/p/substruct/issues/detail?id=140. After applying the
patch, the show cart test failed.

Original issue reported on code.google.com by pramod.b...@gmail.com on 1 Oct 2009 at 4:06

GoogleCodeExporter commented 8 years ago
The problem is that the promo code appears to be saved as a cart item and a 
promotion
doesnt have an "item_id". This only happens if your using the inventory mode 
switch on.

Here is what you need to modify in the code...

#model/orders.rb 

def check_inventory
      removed_items = []
    # Promotion codes are stored as order_line_items with a item_id of NULL
    # Need to pick out the items that have an item code first.
    order_items = self.order_line_items.find(:all, :conditions => ['item_id > ?', '0'])
      order_items.each do |oli|
        # Find the item in the db, because oli.item is cached.
        db_item = Item.find(oli.item_id)
        if oli.quantity > db_item.quantity
          removed_items << oli.name.clone
          self.order_items.delete(oli)
      end
    end
    return removed_items

Original comment by RyanSid...@googlemail.com on 9 Oct 2009 at 4:35

GoogleCodeExporter commented 8 years ago

Original comment by subim...@gmail.com on 4 May 2010 at 7:18

GoogleCodeExporter commented 8 years ago
Is this happening with the current 1.1 release? I can't reproduce it on trunk.

Original comment by subim...@gmail.com on 5 May 2010 at 6:32

GoogleCodeExporter commented 8 years ago

Original comment by subim...@gmail.com on 5 May 2010 at 6:33