| Issue 69: | Weight of Variation does't get considered in shipping price | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem? 1. Add one or more variation for a product and provide an weight for the product. 2. Assign some weight vs. price breakdown in "Shipping rates" 3. Add one ore more quantities of that product's variation into shopping cart and go for checkout 4. Fill out for of "Step 1", then move to "Step 2" - Shipping rate. 5. See the total weight of the variation(s) is not being considered to calculate the shipping price. What is the expected output? What do you see instead? If you add product(not variation) into cart, its weight is being considered to find out in which weight-range the total order falls and fetches proper shipping price. But , if you use variation, it is weight is being considered a "0", where as it's weight should same as that of the product. What version of the product are you using? On what operating system? trunk. Windows-2000 Please provide any additional information below. I think the cause is a follows, 1)When item is added in shopping cart, it is being saved a "OrderLineItem" 2)OrderLineItem provide reference to the item , not as Product or Variation 3)When "weight" message of Order model us being called, it uses the OrderLineItem and the item it holds to get its weight. 4)Product and Variation both are item. Weight is saved in Product database record, but in Variation database record "weight" is saved as "0". 5)So, while calculating total weight of order, check the type of item, if it is a product use its weight and if it is a variation use its product's weight. The calculation of order weight is executed in "weight" message in "order.rb" model def weight weight = 0 self.order_line_items.each do |item| weight += item.quantity * item.product.weight rescue 0 end return weight end The function needs to be changed to as follows, def weight weight = 0 self.order_line_items.each do |item| if(item.product.instance_of?(Variation)) weight += item.quantity * item.product.product.weight rescue 0 else weight += item.quantity * item.product.weight rescue 0 end end return weight end
Apr 9, 2008
Project Member
#1
subim...@gmail.com
Status:
Accepted
Apr 10, 2008
Hi, I have attached the patch file. "item.product.product" looks weird, i agree with you. But, Order#order_line_items is an array of OrderLineItem objects. OrderLineItem class has a method "item" which points to an object of "Item" class, hence item.product. Since the problem of not considering the weight of a "variation" is that a "variation" do not have an weight set for it and we need to look into its parent product to get its weight, we should use the method "product" of "item" class, which points to parent "item" of a "variation". Hence, item.product.product is used. Wish, the name would have been different, me also get confused when i used it first time while working on a Substruct based web site (even though its working!). Hope the patch file is properly formatted. Regards Sujoy
Jun 15, 2008
Please fix this too, the weight is really wrong.
Jun 19, 2008
An alternative is to add a field in the admin panel with "weight" for a variation... It's perfect for us because our variations are differents sizes of a carpet, and so, each carpet have a different weight...
Aug 11, 2008
Any movement on this patch, or a correct patch?
Aug 14, 2008
Here goes what was asked, let the calculation as is and be able to set the variation weight. I fixed the test inside too. |