[ic] Trying to add products using non-numeric quantities...

Jeff Carnahan interchange-users@lists.akopia.com
Thu Jun 28 01:40:00 2001


I've found a similar problem when trying to add products using non-numeric
quantities with the mv_order_item and mv_order_quantity mechanism.

This concerns 4.6.5, I haven't looked at 4.7.x

sub add_items in Order.pm properly creates @quantities, however later when
it comes time to adding the specified quantity to the cart, it uses:

$quantity = defined $quantities[$j] ? $quantities[$j] : 1;

(Line #1779)

So, if the user entered "1a" (as I did to test this) in mv_order_quantity,
"1a" is assumed to be the price, since it meets the defined criteria.

I think that after @quantities is determined, in order to remain consistent
with 4.7.x's behavior of stripping non-numerics, Order.pm should:

@quantities = map { if (/^=/) { s/\D//g; '=' . $_ } else { s/\D//g; $_ } }
@quantities;

Note my ugly use of an if statement to keep the equals sign necessary for
the $set flag later, if there is a better way to do this, please let me know
(I tried using pos $_ = 1 to no avail).. I've tested this on 4.6.5 and it
fixes the problem. =)

This would explain why the demo catalog on developer.akopia.com allows you
to add "1a" ladders to your basket, as I mentioned in my previous e-mail.

--
Jeff Carnahan - jcarnahan@networq.com