Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Code query - could someone check?


JemCraft

Recommended Posts

Posted

I asked on the forums about changing the qty box in the shopping cart to a drop down box, where only the number of items we have in stock can be selected e.g if we have 10 heat tools, the drop down box would drop down to 10, however if we had only 3 sheets of stickers, the drop down box for the sitckers would only drop down to 3.

 

I was given the code below and thought that all was fine, but now the drop down boxes are changing there numbers to tally with the qty of the last item added to the shopping cart. E.g I selected stickers of which we had 10 in stock and the drop down showed 10, then I added a heat tool of which we had 4 and the drop down box showed 4, however the drop down box for the stickers had changed to also show only 4 in stock.

 

Could someone tell me what I have done wrong, or suggest a change to the code to fix this?

 

Or maybe just compeltely new code LOL!

 

I would be very grateful, thanks

Jemma

 

well, in shopping_cart.php:

 

after:

 

$n=sizeof($products);

for ($i=0; $i<$n; $i++) {

 

you add:

 

$max_to_order = tep_get_products_stock($products[$i]['id']);

if ($max_to_order > 0) {

$options = '';

for ($s=0 ; $s<$max_to_order; $s++) {

$z = $s+1;

$options[] = array('id' => $z,

'text' => $z);

}

} else {

$options[] = array('id' => 0,

'text' => 0);

}

 

 

 

and replace :

 

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

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

'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

 

 

with:

 

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

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

'text' => tep_draw_pull_down_menu('cart_quantity[]', $options, $products[$i]['quantity'], ' ').tep_draw_hidden_field('products_id[]', $products[$i]['id']));

Posted
I asked on the forums about changing the qty box in the shopping cart to a drop down box, where only the number of items we have in stock can be selected e.g if we have 10 heat tools, the drop down box would drop down to 10, however if we had only 3 sheets of stickers, the drop down box for the sitckers would only drop down to 3.

 

I was given the code below and thought that all was fine, but now the drop down boxes are changing there numbers to tally with the qty of the last item added to the shopping cart. E.g I selected stickers of which we had 10 in stock and the drop down showed 10, then I added a heat tool of which we had 4 and the drop down box showed 4, however the drop down box for the stickers had changed to also show only 4 in stock.

 

Could someone tell me what I have done wrong, or suggest a change to the code to fix this?

 

Or maybe just compeltely new code LOL!

 

I would be very grateful, thanks

Jemma

 

that is the location for the attributes.

 

put the code just after:

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

 

and before :

 

if (($i/2) == floor($i/2)) {

 

like this:

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

 

// product quantity stock based dropdown array

$max_to_order = tep_get_products_stock($products[$i]['id']);

if ($max_to_order > 0) {

$options = '';

for ($s=0 ; $s<$max_to_order; $s++) {

$z = $s+1;

$options[] = array('id' => $z,

'text' => $z);

}

} else {

$options[] = array('id' => 0,

'text' => 0);

}

 

if (($i/2) == floor($i/2)) {

Treasurer MFC

Posted
that is the location for the attributes.

 

put the code just after:

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

 

and before :

 

if (($i/2) == floor($i/2)) {

 

like this:

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

 

// product quantity stock based dropdown array

$max_to_order = tep_get_products_stock($products[$i]['id']);

if ($max_to_order > 0) {

$options = '';

for ($s=0 ; $s<$max_to_order; $s++) {

$z = $s+1;

$options[] = array('id' => $z,

'text' => $z);

}

} else {

$options[] = array('id' => 0,

'text' => 0);

}

 

if (($i/2) == floor($i/2)) {

 

Do I need to delete the previous code that I was told to add then add your code, or add yours as well?

 

Thanks

Jemma

Archived

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

×
×
  • Create New...