I think that's correct.I believe that would yield:
'+' -> $product['weight'] + ($product['weight'] * $option['weight_factor']).... + ($product['weight'] * $option['weight_factor'])
'-' -> $product['weight'] - ($product['weight'] * $option['weight_factor']).... - ($product['weight'] * $option['weight_factor'])
'*' -> $product['weight'] * $option['weight_factor'].... * $option['weight_factor']
Am I getting warmer?
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
OK! I think I got it. I want to test it a bit more tonight but I think the calculations are correct and working with +,-, and * based on the formulas from the last post.
I also fixed the decrease of option stock when buying multiple of the same product.
ill look into that preventing of buying more than there are options in stock too
I also fixed the decrease of option stock when buying multiple of the same product.
ill look into that preventing of buying more than there are options in stock too
Last edited by Qphoria on Wed Oct 08, 2008 9:06 am, edited 1 time in total.
Update v0.6 Options Weight & Stock
• Completely recoded the functionality to use proper math and calculation options (based on the above discussions with JNeuhoff)
• Fixed the option stock level decrease when buy multiple of the same product.
• Added option stock error check to the cart. Similar to the error received when adding a qty higher than the product stock
level, it will show you a warning about going over each individual option stock level. (It will not prevent checkout tho)
There are also updates to the Category List Options & Min Ord Qty contribs as well to support this new functionality, as these 3 contribs are very closely tied together (they all edit the same files or use the same functionality)
Demo
1. Goto Demo link
2. Notice how many of each option are in stock. (This text can be changed in the language file)
3. Add the product to your cart
4. Change the qty to something greater than the options in stock
5. There should be a single red asterisk next to each option per item and an error message explaining the problem
6. Checkout with the item using account [demo@demo.com / demo] and use COD payment
7. Verify that after you checkout, you see the stock qty reflects the current stock (assuming that the stock decrease option is enabled)
8. Log into the admin section at Admin Demo with account [demo / demo]
9. Goto "Catalog->Products" and view the options for product 1
10. Change the new params, including the weight operator to see the way it displays & calculates.
11. Now goto your cart and verify the weights match up with the options you've used. Product 1 on the demo is 10lbs at the base level
Download
Note: Currently the "Error" banner is a single variable. Technically since you can have multiple errors on this page, it should be made into an array stack. But that will be added in the 0.7.9 version.
• Completely recoded the functionality to use proper math and calculation options (based on the above discussions with JNeuhoff)
• Fixed the option stock level decrease when buy multiple of the same product.
• Added option stock error check to the cart. Similar to the error received when adding a qty higher than the product stock
level, it will show you a warning about going over each individual option stock level. (It will not prevent checkout tho)
There are also updates to the Category List Options & Min Ord Qty contribs as well to support this new functionality, as these 3 contribs are very closely tied together (they all edit the same files or use the same functionality)
Demo
1. Goto Demo link
2. Notice how many of each option are in stock. (This text can be changed in the language file)
3. Add the product to your cart
4. Change the qty to something greater than the options in stock
5. There should be a single red asterisk next to each option per item and an error message explaining the problem
6. Checkout with the item using account [demo@demo.com / demo] and use COD payment
7. Verify that after you checkout, you see the stock qty reflects the current stock (assuming that the stock decrease option is enabled)
8. Log into the admin section at Admin Demo with account [demo / demo]
9. Goto "Catalog->Products" and view the options for product 1
10. Change the new params, including the weight operator to see the way it displays & calculates.
11. Now goto your cart and verify the weights match up with the options you've used. Product 1 on the demo is 10lbs at the base level
Download
Note: Currently the "Error" banner is a single variable. Technically since you can have multiple errors on this page, it should be made into an array stack. But that will be added in the 0.7.9 version.
Last edited by Qphoria on Sat Oct 11, 2008 2:03 am, edited 1 time in total.
Product weight = 1
Option Weight Factor = 46
Shipping is set to
500:6.50, 20000:11.50
When you buy 11 units which = 517g > shipping is $0.00
Now if I change the shipping to 400:6.50, 20000:11.50,
Zero shipping starts at 9units = 423g
So it's looking like it'll pickup the first shipping weight band ie 500g but a cart heavier than the 1st shipping band > zero shipping. So it's not picking up the 20000:11.50 part of my shipping setting
Option Weight Factor = 46
Shipping is set to
500:6.50, 20000:11.50
When you buy 11 units which = 517g > shipping is $0.00
Now if I change the shipping to 400:6.50, 20000:11.50,
Zero shipping starts at 9units = 423g
So it's looking like it'll pickup the first shipping weight band ie 500g but a cart heavier than the 1st shipping band > zero shipping. So it's not picking up the 20000:11.50 part of my shipping setting

I'm confused on how the zone shipping works.jty wrote: Product weight = 1
Option Weight Factor = 46
Shipping is set to
500:6.50, 20000:11.50
When you buy 11 units which = 517g > shipping is $0.00
Now if I change the shipping to 400:6.50, 20000:11.50,
Zero shipping starts at 9units = 423g
So it's looking like it'll pickup the first shipping weight band ie 500g but a cart heavier than the 1st shipping band > zero shipping. So it's not picking up the 20000:11.50 part of my shipping setting![]()
The default has:
Shipping Zone 1 Cost: 1.00:7
You have 500:6.50, 20000:11.50
Is the weight 1.00 and the cost 7 in the default?
or is it reversed?
Nevermind, I see the problem. It's the getweight() thing in the zone shipping module. Can o' worms time as this will be a problem in 0.7.9 too
This goes back to that code fix for the getWeight where if the weight was 1000lbs, the weight->convert() function would return "1,000" and the getWeight function, being a long would truncate everything after the comma, leaving "1lb"
Bruce fixed this one way, and hm2k fixed it another.
In hm2k's way, getWeight fixes the comma, so 1000 = 1000. But as an additional pre-emptive step, he added the weight unit to the returned value. So 1000 = 1000lb (or kg, oz, etc)
I included hm2k's fix with the min ord qty contrib and should actually be with this one too, tho I didn't include it. So its trying to do: if "500" < "500.00lb" ... integer < string makes no sense.
So, we need to remove the weight unit add-on (hate to say I told you so hm2k
)
I will open a bug tracker to fix the 0.7.9 thing. To fix the problem with the contrib
This goes back to that code fix for the getWeight where if the weight was 1000lbs, the weight->convert() function would return "1,000" and the getWeight function, being a long would truncate everything after the comma, leaving "1lb"
Bruce fixed this one way, and hm2k fixed it another.
In hm2k's way, getWeight fixes the comma, so 1000 = 1000. But as an additional pre-emptive step, he added the weight unit to the returned value. So 1000 = 1000lb (or kg, oz, etc)
I included hm2k's fix with the min ord qty contrib and should actually be with this one too, tho I didn't include it. So its trying to do: if "500" < "500.00lb" ... integer < string makes no sense.
So, we need to remove the weight unit add-on (hate to say I told you so hm2k

I will open a bug tracker to fix the 0.7.9 thing. To fix the problem with the contrib
Last edited by Qphoria on Fri Oct 10, 2008 10:10 pm, edited 1 time in total.
I found it. It's the thousand bug !!!!!
I changed my shipping data to 400:6.50,999:11.50
and it now works correctly
9 units = 423g which is more than 400g so goes to next band > shipping = $11.50
Where do I get the code for the 1,000 bug fix ?
I changed my shipping data to 400:6.50,999:11.50
and it now works correctly
9 units = 423g which is more than 400g so goes to next band > shipping = $11.50
Where do I get the code for the 1,000 bug fix ?
Bleh, you're trying to use a formatted string for math, something's not gonna work.
Get me the revisions that relate to this and open an issue tracker (or reopen it) and i'll look into it with you.
Get me the revisions that relate to this and open an issue tracker (or reopen it) and i'll look into it with you.
I'm not using it. The default Zone shipping module is.hm2k wrote: Bleh, you're trying to use a formatted string for math, something's not gonna work.
Get me the revisions that relate to this and open an issue tracker (or reopen it) and i'll look into it with you.
Actually its not something you did hm2k. Well.. its a bug inside a bug.
the weight->format() function was always designed to return "100.00lb"
getWeight, up until the fix, always returned a long, which auto-truncated any string data. So from "1lb" to "999lb" it would always return 1 to 999.
When we noticed that "1,000lb" was being returned as "1" we never even thought about the fact that "lb" was always on it. We just focused on the comma. So by fixing the "1,000" to be "1000" you also fixed its use of including the "lb" part with it.
It appears that the shipping zone module was designed around the bugged version of getWeight, which now that it is fixed to work the way it was designed, the modules using the bugged version don't work.
So by fixing one for the number, you broke one for the string. a double-edged sword!
So the fix really is to make a choice:
should getWeight return the string weight of "1000.00lbs" or should it just return a value "1000.00" ? It seems that other parts of the cart were designed around the notion that getWeight returns a value (long) only. I think some weight-based contribs might be doing the same thing.
Last edited by Qphoria on Sat Oct 11, 2008 2:04 am, edited 1 time in total.
For now to fix the fixed bug to be broke again the way other modules want it, you can edit:
library/cart/weight.php
change:
to:
This is a temporary fix, but assuming other stuff was designed around getWeight returning a long, this might be the final solution as well. Sometimes it's easier to change the design than the code 
The fix for the comma bug still needs to be applied tho for weights over 999, either by using the weight.php file from min_order contrib or using bruces fix.
library/cart/weight.php
change:
Code: Select all
function format($value, $weight_class_id) {
return number_format($value, 2, $this->language->get('decimal_point'), $this->language->get('thousand_point')) . $this->classes[$weight_class_id]['unit'];
}
Code: Select all
function format($value, $weight_class_id) {
return number_format($value, 2, $this->language->get('decimal_point'), $this->language->get('thousand_point'));
}

The fix for the comma bug still needs to be applied tho for weights over 999, either by using the weight.php file from min_order contrib or using bruces fix.
Last edited by Qphoria on Fri Oct 10, 2008 10:49 pm, edited 1 time in total.
ok. so see here for the final proposed fix that will address the number issue and the option stock issue:
http://forum.opencart.com/index.php/top ... ml#msg9482
http://forum.opencart.com/index.php/top ... ml#msg9482
Last edited by Qphoria on Fri Oct 10, 2008 11:24 pm, edited 1 time in total.
Update v0.7 Options Weight & Stock
• Fixed: Added the proper bug fix for getWeight() which fixes the comma problem and allows use of zone based shipping. Also changed the Total Cart Display weight to use a new method that doesn't rely on getting the unit back from getWeight.
There are also updates to the Min Ord Qty contrib as well to support this new functionality, as these 2 contribs are very closely tied together (they all edit the same files or use the same functionality)
Demo
1. Goto Demo link
2. Notice how many of each option are in stock. (This text can be changed in the language file)
3. Add the product to your cart
4. Change the qty to something greater than the options in stock
5. There should be a single red asterisk next to each option per item and an error message explaining the problem
6. Checkout with the item using account [demo@demo.com / demo] and use COD payment
7. Verify that after you checkout, you see the stock qty reflects the current stock (assuming that the stock decrease option is enabled)
8. Log into the admin section at Admin Demo with account [demo / demo]
9. Goto "Catalog->Products" and view the options for product 1
10. Change the new params, including the weight operator to see the way it displays & calculates.
11. Now goto your cart and verify the weights match up with the options you've used. Product 1 on the demo is 10lbs at the base level
Download
Note: Currently the "Error" banner is a single variable. Technically since you can have multiple errors on this page, it should be made into an array stack. But that will be added in the 0.7.9 version.
NOTE:THIS WILL BE THE LAST VERSION FOR OPENCART 0.7.8!
THE NEXT VERSION WILL BE FOR OPENCART 0.7.9.
- Since Min Ord Qty is part of the core code in 0.7.9, I will need to rip all the support for the contrib version out of it to allow the core version to work. This will also make it a lot easier since I won't have to maintain 3 contribs sharing the same code, just 2.. (really more like 1)
• Fixed: Added the proper bug fix for getWeight() which fixes the comma problem and allows use of zone based shipping. Also changed the Total Cart Display weight to use a new method that doesn't rely on getting the unit back from getWeight.
There are also updates to the Min Ord Qty contrib as well to support this new functionality, as these 2 contribs are very closely tied together (they all edit the same files or use the same functionality)
Demo
1. Goto Demo link
2. Notice how many of each option are in stock. (This text can be changed in the language file)
3. Add the product to your cart
4. Change the qty to something greater than the options in stock
5. There should be a single red asterisk next to each option per item and an error message explaining the problem
6. Checkout with the item using account [demo@demo.com / demo] and use COD payment
7. Verify that after you checkout, you see the stock qty reflects the current stock (assuming that the stock decrease option is enabled)
8. Log into the admin section at Admin Demo with account [demo / demo]
9. Goto "Catalog->Products" and view the options for product 1
10. Change the new params, including the weight operator to see the way it displays & calculates.
11. Now goto your cart and verify the weights match up with the options you've used. Product 1 on the demo is 10lbs at the base level
Download
Note: Currently the "Error" banner is a single variable. Technically since you can have multiple errors on this page, it should be made into an array stack. But that will be added in the 0.7.9 version.
NOTE:THIS WILL BE THE LAST VERSION FOR OPENCART 0.7.8!
THE NEXT VERSION WILL BE FOR OPENCART 0.7.9.
- Since Min Ord Qty is part of the core code in 0.7.9, I will need to rip all the support for the contrib version out of it to allow the core version to work. This will also make it a lot easier since I won't have to maintain 3 contribs sharing the same code, just 2.. (really more like 1)
Last edited by Qphoria on Sat Oct 11, 2008 2:04 am, edited 1 time in total.
@ Mr JNeuhoff,
I was wondering if you had a chance to check this out for the PW * OW1 * OW2...etc method. From my testing I tried to mimic the flooring example you gave and I believe the numbers came out correctly, but I just want to be sure it is working the way you expect now.
Also, any chance of getting the new "weight_operator" field added to the import/export contrib?
And perhaps if you would like to be extra nice, you could also add the "quantity" & "stock_decrease" fields

I was wondering if you had a chance to check this out for the PW * OW1 * OW2...etc method. From my testing I tried to mimic the flooring example you gave and I believe the numbers came out correctly, but I just want to be sure it is working the way you expect now.
Also, any chance of getting the new "weight_operator" field added to the import/export contrib?
And perhaps if you would like to be extra nice, you could also add the "quantity" & "stock_decrease" fields


Q, do you have an approx when date as to when you will be ripping out the min qty stuff for this contribution and the Categories Option List contrib.Qphoria wrote: THE NEXT VERSION WILL BE FOR OPENCART 0.7.9.
- Since Min Ord Qty is part of the core code in 0.7.9, I will need to rip all the support for the contrib version out of it to allow the core version to work.
Will it be a week, weeks, months. Can't be years.
I tried doing it myself today and I created a natural disaster

No hurry, if you can't do it soon, that's OK. I'll use 0.7.8 instead. I just have to get something live soon before I get more orders from my "test" site.
Actually I have it done. But I was waiting for 0.7.9Final to release it as the files that get changed for the contrib were also being changed with the past few bugs. So I didn't want to release a broken version based on RC2, if the bug if fixed in Final.
I could PM you the beta link tho. I am pretty sure there will be no more changes to those files now.
I could PM you the beta link tho. I am pretty sure there will be no more changes to those files now.
You kidding meQphoria wrote: Actually I have it done.


I didn't want to ask earlier cos I know you're busy on 0.7.9
Would you PM the link please.
I have been following the bug tracker and will apply the bugs manually
Thanks again
I've been real-time, multi-task maintaining all my contribs that I've ported to 0.7.9. All my contribs are up to date with the latest SVN.
It goes like this:
- Release 0.7.9RCx
- Update my contrib to use the latest code
- Bug is found
- Fix bug in latest SVN
- Then Fix bug in all my contribs
- Rinse & Repeat
So I am just as anxious as everyone to get 0.7.9 Final out the door so I can go back to only maintaining the contribs as contribs.
I will PM you the latest
It goes like this:
- Release 0.7.9RCx
- Update my contrib to use the latest code
- Bug is found
- Fix bug in latest SVN
- Then Fix bug in all my contribs
- Rinse & Repeat
So I am just as anxious as everyone to get 0.7.9 Final out the door so I can go back to only maintaining the contribs as contribs.
I will PM you the latest
Who is online
Users browsing this forum: No registered users and 5 guests