Post by JNeuhoff » Thu Feb 14, 2008 1:42 am

The zone-based shipping includes the support of weights which is fine unless the selected product option (e.g. option name is 'Size' with possible option values of  '1 Litre', '5 Litre', '25 Litre' etc) affects the actual product weight. Surely if the user selects a '25 Litre' option, its weight is 25 times higher than the originally specified product weight ('1 Litre' is the default option with zero price difference in this example).

This problem illustrates that for certain kinds of product option names, e.g. 'Size', 'Volume', 'Weight', etc. the zone-based shipping module cannot always use the original default product weight.

My proposal is to extend the 'product_to_option' table to include not just the price increments/decrements, but also weight increments/decrements in future versions of OpenCart.

Daniel, do you agree with this proposal?

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Fri Aug 29, 2008 9:11 pm

Not sure if there was any headway into this but I want to second this notion. I just recently ran into this and was going to contrib it, unless it was planned to be in the next version.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Fri Aug 29, 2008 11:58 pm

I have done that for a special Australian flavor of OpenCart 0.7.7, by introducing a new DB field column 'weight_factor' for the DB table 'product_to_option'. The Import/Export module has support for this feature.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by jty » Sun Aug 31, 2008 4:47 am

I third this notion.
I have another site that requires weight with options for shipping by weight

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Qphoria » Sun Aug 31, 2008 6:36 am

JN, is this something that you'd can easily rip out of your special version? If not I might just whip one up

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Sun Aug 31, 2008 9:54 pm

JN, is this something that you'd can easily rip out of your special version? If not I might just whip one up
I have never updated the admin side of it. You'd have to add the code for the additonal 'weight_factor' field yourself in the file /admin/controller/product_option.php, and the database would need the additional product_to_option.weight_factor field column of type float.

My Export/Import module automatically detects the existance of this additional field, and if there, uses it, too.

It would be useful to have a proper OpenCart extension module implementing this feature, including the changes in the /admin/controller/product_option.php file. Also, any weight-based shipping module would have to be modified, too, for proper support of this feature. Care to give it a go?
Last edited by JNeuhoff on Sun Aug 31, 2008 10:02 pm, edited 1 time in total.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Sun Aug 31, 2008 11:10 pm

sure why not. I'm going to need it for my store anyway, plus I can add support for it to my USPS Shipping Rate API contrib before I release it. ;D
Last edited by Qphoria on Mon Sep 01, 2008 9:32 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Mon Sep 01, 2008 9:57 am

Would it make more sense to make the attribute weight affect the cart weight, this way it would be transparent to the shipping modules as the getWeight function would already include the option weight?

Also, to do it right, I should probably also add a prefix for the weight. Though, unless you are selling helium, I'm not sure what kind of option would decrease weight. But perhaps there is something out there. Safer to have it and not need it, than to need and not have it.
Last edited by Qphoria on Mon Sep 01, 2008 10:10 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jty » Mon Sep 01, 2008 12:13 pm

Qphoria wrote: Though, unless you are selling helium, I'm not sure what kind of option would decrease weight.
Sample sizes might use this eg the product listed would be a bottle of say perfume but they can have an option to buy a sample size which would decrease the weight.

If Open Cart has the decrease price option, then there will be a need for a decrease weight option. I can't think of an example of decrease price either but it must obviously be used as other carts have the minus feature. Does helium reduce in weight as the price goes up. Maybe :)

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by JNeuhoff » Mon Sep 01, 2008 9:16 pm

Would it make more sense to make the attribute weight affect the cart weight, this way it would be transparent to the shipping modules as the getWeight function would already include the option weight?
Makes sense to me.

Hence we'd need the weight_factor field in the following DB tables:

product_to_option
order_option

And the getWeight() function would take the weight_factor into account, too, so that any shipping module using this function could remain unmodified.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Mon Sep 01, 2008 10:39 pm

JNeuhoff wrote: Hence we'd need the weight_factor field in the following DB tables:

product_to_option
order_option

And the getWeight() function would take the weight_factor into account, too, so that any shipping module using this function could remain unmodified.
Ok, First thing, we have some options :P

I could add the option weight at the "getWeight" function level. Or I could add it at the cart index level. Currently I have it at the latter, but either way seems to work. The option price is added at the cart index level, so I just cloned that section for adding the weight there as well. Either way, the getWeight function returns the correct weight.

Second thing, in looking at the order_option table, I noticed that the price column seems incorrect in that table. It takes the full product price as the price listed under each option, instead of just including the  option price.

In the library/cart/order.php file it shows:
foreach ($product['option'] as $option) {
    $sql = "insert into order_option set order_id = '?', order_product_id = '?', name = '?', `value` = '?', price = '?', prefix = '?'";
    $this->database->query($this->database->parse($sql, $order_id, $order_product_id, $option['name'], $option['value'], $product['price'], $option['prefix']));
}
I would think that 'price' should be option price, not product price. But it seems like such a intentional code choice. While I wait to hear some feedback on that one, I am going to set the weight to the option weight, not the product weight for the time being.

And third thing.... There needs to be a change made to the catalog/controller/product.php file to include the +weight in the option drop down. I already have changes to product.php for my admin_ip contrib, and I'm sure there are other contribs. Unfortunately, even my template override idea wouldn't help in this case. We need to get back to override system talk  :P

Other than that, its pretty much done. Gonna do some testing with multiple products and multiple options now.
Last edited by Qphoria on Mon Sep 01, 2008 10:56 pm, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Tue Sep 02, 2008 1:00 am

One thing I noticed tho was the import/export module doesn't have support for the weight_prefix

Also, I'm not quite sure if I should do a weight conversion based on customer locale. Should it always match the store's locale (I'm in USA so I'd use lbs. Euro would use kg. etc) but should I be doing some equation based on
$ = lbs
€ = kg
??

Or should weight stay static to the store measurement units? I'm not sure what countries use which units tbh.
Last edited by Qphoria on Tue Sep 02, 2008 1:24 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Tue Sep 02, 2008 1:45 am

One thing I noticed tho was the import/export module doesn't have support for the weight_prefix
It does support it! You need to name it weight_factor, see the documentation at http://www.mhccorp.com/opencart-0-7-7-export-import.pdf.

Example: Suppose the store sells cans with liquids, e.g. paint, and it has a product option called 'Size', described in Litres, then the weight factors are:


option nameoption valueweight_factor...
size4 Litres1...    (the default option)
size6 Litres1.5...
size20 Litres5...


The weight-based shipping module needs to make sure that it multiplies the product by the weight_factor for the chosen product option.
Also, I'm not quite sure if I should do a weight conversion based on customer locale.
No need for any conversion of measurement units. The 'weight_factor' is just something what it says it is: Something to be multiplied by.
Last edited by JNeuhoff on Tue Sep 02, 2008 1:50 am, edited 1 time in total.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Tue Sep 02, 2008 1:49 am

I know that!  :D

I didn't say weight_factor, I said weight_prefix. see the conversation a few posts above. Weight can go either way, so we need a + or - prefix to define the factor

There are 2 new fields

weight_prefix and weight_factor

And it is no longer calculated at the weight-based shipping level. It is calculated in the cart weight to be transparent to all shipping modules.

-EDIT-
Hmm... I think I understand what you are saying. You are using weight as a multiplier of the base product weight.. My design is actually adding an actual separate weight to each option.
Product 1 - weight: 5lbs
- size 5Gallons: +1lb
= 6lbs total

I suppose a multiplier could be done with:
Product 1 - weight: 5lbs
- size 5Gallons: (weight x 0.2)
= 6lbs total

But still without a prefix, it will always assume a positive number.

Even with a prefix, which would the populace prefer? A multiplier of the product weight? or a separate option weight? Maybe we need a vote!
Last edited by Qphoria on Tue Sep 02, 2008 1:57 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Tue Sep 02, 2008 1:57 am

Weight can go either way, so we need a + or - prefix to define the factor
No problem: If the weight for a product option goes down in half, than the weight_factor simply is 0.5! No need for a weight prefix.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Tue Sep 02, 2008 1:59 am

JNeuhoff wrote:
Weight can go either way, so we need a + or - prefix to define the factor
No problem: If the weight for a product option goes down in half, than the weight_factor simply is 0.5! No need for a weight prefix.
But how about options that bring down the product base weight?

Base item = 5lbs
Option A = weight_factor of 0.5
Option B = weight_factor of 1.5

Base + Option A = 5lbs + 2.5lbs = 7.5lbs
Base + Option B = 5lbs + 7.5lbs = 12.5lbs


What if you are selling Helium.
Empty Tank = 5lbs
Option A (Full tank) = -0.5

Tank = 5lbs
Tank + (-2.5) = 2.5lbs


I know the likelihood of helium sales is pretty low...  ;)
Last edited by Qphoria on Tue Sep 02, 2008 4:25 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Tue Sep 02, 2008 5:55 pm

But how about options that bring down the product base weight?

Base item = 5lbs
Option A = weight_factor of 0.5
Option B = weight_factor of 1.5

Base + Option A = 5lbs + 2.5lbs = 7.5lbs
Base + Option B = 5lbs + 7.5lbs = 12.5lbs
Its more like this:

Base item = 5lbs
Option A = weight_factor of 0.5
Option B = weight_factor of 1.5

Base + Option A = 5lbs * 0.5 = 2.5lbs
Base + Option B = 5lbs * 1.5 = 7.5lbs


For a real world example see http://www.vcsproducts.com.au/index.php ... t_id=39002

Base item = TIMBERMATE FLOOR FILLER ( CEDAR ) 2 KG
Option 1: Size = 2 KG  , weight_factor=1
Option 2: Size = 8 KG, weight_factor=4
Option 3: Size = 20 KG, weight_factor=10

The weight factors are used for the correct calculation of the product weight in the shipping module.
What if you are selling Helium.
Empty Tank = 5lbs
Option A (Full tank) = -0.5
Same thing here (assuming Helium is half the weight of normal air):

Base item: Helium tank
Option 1: Volume = empty tank, weight factor 1
Option 2: Volume = 1/2 tank, weight factor 0.75
Option 3: Volume = full tank, weight factor 0.5

The weight factors might be a little higher in the last example to factor in the weight of the tank itself, that is, fully filling the tank with helium may only reduce the weight by e.g. 40%, in which case the weight factor for the 'full tank' option would be 0.6, but you get the main idea of it now, don't you?

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Tue Sep 02, 2008 6:42 pm

Ah ok. So its not:

option_weight = base * weight_factor
product_weight = (base + option_weight) * qty

it's just

product_weight = (base * weight_factor) * qty

so the options themselves don't have a weight. They only affect the weight of the base product by their factor. I was  giving them their own weight. But now I see what you are saying.

OK then, I'll do it your way to keep it simpler.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Wed Sep 03, 2008 4:32 am

Ok Done.

RELEASED
Last edited by Qphoria on Wed Sep 03, 2008 4:59 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 1 guest