I'm very new to OpenCart. About an hour. I'm a web developer and am thinking about using it for clients. I like the simplicity and I love the "add-to-cart" visual and that I stay on the same page. But, when I go to the cart, I'm able to order fractions of items and OpenCart happily calculates the extended price. That looks stupid and it doesn't give me a confident feeling about this software. And, it isn't just the demo store. I've gone to live OpenCart storefronts and ordered 1.7 computer monitors. I did NOT continue to Checkout and hopefully this issue is caught at that point.
Have confirmed this on 1.3.2.
Added 1.7 of a 2.00 item to my cart, showed cart total of 3.40.
Completed checkout procedure and admin panel shows only 1 item with a value of 3.40.
It won't work for fractions less than 1, ie. 0.7.
To reproduce:
1. Add item to your cart
2. Click 'Basket'
3. Modify quantity of item to fraction, eg 1.7 and click 'Update'
4. Complete checkout as normal
Granted this isn't desirable and appears to have been overlooked, but I think you will find when working on OpenCart that as a rule the code is extremely well written, easy to follow and easy to extend... but you're more than welcome to spend some time working on with osCommerce if you don't believe me
Added 1.7 of a 2.00 item to my cart, showed cart total of 3.40.
Completed checkout procedure and admin panel shows only 1 item with a value of 3.40.
It won't work for fractions less than 1, ie. 0.7.
To reproduce:
1. Add item to your cart
2. Click 'Basket'
3. Modify quantity of item to fraction, eg 1.7 and click 'Update'
4. Complete checkout as normal
Granted this isn't desirable and appears to have been overlooked, but I think you will find when working on OpenCart that as a rule the code is extremely well written, easy to follow and easy to extend... but you're more than welcome to spend some time working on with osCommerce if you don't believe me

I thought I stoped this from happenign.
I used (int) on the qty.
Try this code:
I used (int) on the qty.
Try this code:
Code: Select all
public function add($product_id, $qty = 1, $options = array()) {
if (!$options) {
$key = $product_id;
} else {
$key = $product_id . ':' . implode('.', $options);
}
if (((int)$qty) && ((int)$qty > 0)) {
if (!isset($this->session->data['cart'][$key])) {
$this->session->data['cart'][$key] = (int)$qty;
} else {
$this->session->data['cart'][$key] += (int)$qty;
}
}
}
public function update($key, $qty) {
if (((int)$qty) && ((int)$qty > 0)) {
$this->session->data['cart'][$key] = (int)$qty;
} else {
$this->remove($key);
}
}
OpenCart®
Project Owner & Developer.
The Code worked for me on 1.3.2.Daniel wrote:I thought I stoped this from happenign.
I used (int) on the qty.
I had a thought though, If somebody enters that they require "1.3" items, 1 obviousely is not enough for them so should the code be rounding up to increase sales?

1.3 = 2
instead of
1.3 = 1
Alex
Who is online
Users browsing this forum: No registered users and 12 guests