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
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
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.JN, is this something that you'd can easily rip out of your special version? If not I might just whip one up
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?
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
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.
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.Qphoria wrote: Though, unless you are selling helium, I'm not sure what kind of option would decrease 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

Makes sense to me.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?
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
Ok, First thing, we have some optionsJNeuhoff 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.

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:
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.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']));
}
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

Other than that, its pretty much done. Gonna do some testing with multiple products and multiple options now.
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.
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.One thing I noticed tho was the import/export module doesn't have support for the weight_prefix
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.
No need for any conversion of measurement units. The 'weight_factor' is just something what it says it is: Something to be multiplied by.Also, I'm not quite sure if I should do a weight conversion based on customer locale.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig

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!
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.Weight can go either way, so we need a + or - prefix to define the factor
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
But how about options that bring down the product base weight?JNeuhoff wrote: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.Weight can go either way, so we need a + or - prefix to define the factor
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...

Its more like this: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
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.
Same thing here (assuming Helium is half the weight of normal air):What if you are selling Helium.
Empty Tank = 5lbs
Option A (Full tank) = -0.5
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
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.
Users browsing this forum: No registered users and 1 guest