Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

All sites have this bug, so heres the fix


Arpit

Recommended Posts

I am not sure if you have noticed this, but every release of osCom has this, the text box where you specify the quantity of products, the shopping_cart.php, there you can specify products with decimal places, so a customer could mistakeably orders 2.5 shirts, now I dont know how to give a customer 2.5 of any item, and the weird thing is, the price total includes the price for that 0.5 shirt, so this is what you do,

 

In includes/classes/shopping_cart.php around line 99

make sure that the variable 'qty' has (int) in front of it so it looks like,

 

if ($this->in_cart($products_id)) {  

$this->update_quantity($products_id,

(int)
$qty, $attributes);

 

if you are using CVS2.2 then add (int) in catalog/shopping_cart.php around line 149

 

$info_box_contents[$cur_row][] = array('align' => 'right',

                                            'params' => 'class="productListing-data" valign="top"',

                                            'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), (int)$products[$i]['quantity']) . '</b>');

   }

 

Now if someone tries to enter 2.6 or any quantity with decimal, it would round the quantity and the price would not change :idea:

The late twentieth century has witnessed a remarkable growth in scientific interest in the subject of extinction

----------------------------------------------------

Arpit

Link to comment
Share on other sites

  • Replies 54
  • Created
  • Last Reply

Arpit,

 

That's not a bug, it is a feature. :D

 

Actually some of us use it too....If you sell fabric by the yard, or rope by the foot or nails by the pound being able to sell .5 is a good thing. :D

 

Thank you for providing a fix for those that don't need it though. :D

Link to comment
Share on other sites

Better yet - it should be by item that way if SOME of your items are sold by the fraction - you can - But if a large qty has to be sold by a whole unit DON'T have this "Fractional" flag on will only allow whole numbers.

Link to comment
Share on other sites

  • 2 weeks later...

how about you turn up an error if the value is not int ?

 

maybe instead of 1.5 the client wanted 15 products...

 

so i think it would be better to show them the error they made right away.

 

just a thought

Designrfix.com | Graphic Design Inspiration & Web Design Resources - @designrfix
Link to comment
Share on other sites

That's not a bug, it is a feature. :D

 

Kim, how long have you been waiting to use that one? :wink: :lol:

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

Any ideas on why when placing an order, anything ordered in an amount higher than 1 in shopping_cart.php, defaults back to 1 in checkout_shipping.php and checkout_confirmation.php?

I'm using MS1, the only mods are CanadaPost and an Update Currency cron, and only have one product. I have tried "falsing" the stock options in Admin, but have 995 in stock anyway there.

 

Violet

Link to comment
Share on other sites

That's not a bug, it is a feature. :D

you must be joking! :?

I think most of us sell 1 whole of an item, not a fraction of it. :lol:

 

thanx god for some1 pointing me here, I just got an order today for 1.5 of a product, and I'm quite puzzled how to ship that :sarcasm:

 

cheers,

Cheers,

Susan

 

* * * * *

Find a way, or make one!

Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...

I'm missing somthing here. I change the value to (int) as you showed and when I test the script it seems to work, the value entered is rounded down but the value increases unless update is pushed a second time.

 

$Id: shopping_cart.php,v 1.73 2003/06/09 23:03:56 hpdl Exp $

Link to comment
Share on other sites

Great website..........Can you tell me how you got rid of the numbers from the category list?

If you have not found it yet.

 

Admin, Configuration, My Store, Show Category Counts False

while (!succeed) {try()};

 

GMT -6:00

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 weeks later...

What is needed are units of measures for material pricing and delivery quantities.

 

Common products such as shirts are sold in C62 (iso eaches) while others such as rope are sold in MTR (iso metres)

 

Eaches materials are only sold in whole form while rope products may have decimal quantities eg. 2.5 metres at $40.40 per metre.

 

This feature is common in supply chain solutions.

Link to comment
Share on other sites

Arpit,

 

That code modification works * but * although

the item price shows the rounded price the sub-total

does not show the right price i.e.

 

1 x widget @ ?29.99 Line Price = ?29.99 Sub-Total = ?29.99

 

1.5 x widget @ ?29.99 Line price=?29.99 Sub-Total = ?44.99

 

Any ideas would be greatly appreciated.

 

Cheers

 

Steve

Link to comment
Share on other sites

Doesn't seem to work for me either :|

 

I'm getting the same problems as above, in the line price it says a rounded up figure yet in totoal it accounts for the .x ??

 

Any help would be superb! Last thing I want is someone ordering 2.6 guitars :blink:

 

Cheers

Link to comment
Share on other sites

Hey, it ain't working for me either!

 

Weird since all of you said it worked.

 

This is what I wrote at line 149 following your instructions:

 

$info_box_contents[$cur_row][] = array('align' => 'right',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), (int)$products[$i]['quantity']) . '</b>');

 

Now when someone tries to buy 2.5 items of 10 euros each, the Total shows 20 euros ... but the Subtotal at the bottom of the shopping cart says 30 euros (that corresponds to the price of 2 and a half units), and if you browse around my webstore and then go the shopping cart it still will show you've ordered 2.5 units.

:huh:

So it is not working fine.

I guess I've forgot to do something, right?

But can think of what it is.

 

Thanks in advance,

Jose Delgado

- - - - - - - - - - - -

"I wish I were smart enough so I could end all my posts with one of those famous and brillant phrases!"

J. Delgado, amateur philosopher (2003)

Link to comment
Share on other sites

On line 148 of catalog/shopping_cart.php, find:

'text' => tep_draw_input_field('cart_quantity[]', (int)$products[$i]['quantity'])

 

and replace it with:

'text' => tep_draw_input_field('cart_quantity[]', (int)$products[$i]['quantity'], 'onBlur="this.value = parseInt(this.value);"')

 

This causes the field to truncate its value to an integer when the user clicks outside of the field (i.e. when s/he clicks 'Update').

Link to comment
Share on other sites

What about just displaying a message informing the customer that they are ordering a fractional quantity and disable the respective buttons until they fix it, unless, of course, fractional quantities are ok.

 

Some say round up, others say round down, yet others say maybe they meant to have the decimal point moved to the right. This forces the customer to make the fix.

 

Just a thought.

Link to comment
Share on other sites

  • 2 weeks later...

Logiczero,

Thanks for the code bit, it works.

However, the sizing doesn't work anymore.

'size="4"'

 

I tried to put it before like

tep_draw_input_field('cart_quantity[]', (int)$products[$i]['quantity'], 'size="4"','onBlur="this.value = parseInt(this.value);"'

 

or after like

tep_draw_input_field('cart_quantity[]', (int)$products[$i]['quantity'], 'onBlur="this.value = parseInt(this.value);"', 'size="4"')

 

but it doesn't work. Sorry, I'm a Delhi guy & have no clue of php. Any idea how can I use your code fix, plus still be able to fix the input box size to 4?

Cheers mate... :rolleyes:

Link to comment
Share on other sites

tep_draw_input_field('cart_quantity[]', (int)$products[$i]['quantity'], 'size="4"','onBlur="this.value = parseInt(this.value);"'

should be

tep_draw_input_field('cart_quantity[]', (int)$products[$i]['quantity'], 'size="4" onBlur="this.value = parseInt(this.value);"'

Hth,

Matt

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...