Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

name="add_id['.$number_of_products.']" HOW TO ADD


TheFinnisher

Recommended Posts

Anyone have an idea on how to make the input name id +1?

 

This is what I am trying to do. I have modified the families group to be able to do a multi-add to cart using some of the information of the "Add multiple products" contribution.

 

I changed product_info.php to use the multi-add form rather than the normal add to cart form...I have added a quantity box next to the normal button and want to name this id 1

 

For all the families products I want them to start with a number from 2 and up.

 

I managed to get the right numbers in the hidden fields but not in the visible fields.

 

In the hidden fields it was easy. I did it like:

 

<input type="hidden" name="products_id[<?php echo $number_of_products + 1; ?>]" value="<?php echo $listing['products_id']; ?>">

 

but how do I change this so that it starts with number 2:

 

case 'FAMILY_LIST_AMOUNT':

$lc_align = 'center';

    $lc_text = '<input type="text" name="add_id['.$number_of_products.']" value="0" size="3" maxlength="3">';

 break;

 

I have tried numerous possibilities:

 

name="add_id['.$number_of_products+1.']"

 

name="add_id['.$number_of_products + 1.']"

 

name="add_id['.$number_of_products . + 1 .']"

 

etc. etc.

 

but I just can't figure it out...

 

Can anyone help me?

 

The other option I thought of was to include the value for the showing product as parameter "p" and change the multi-add function in application_top.php so that it would include id's 1 and above AND p. But I'm afraid I don't know what's code right.

 

This is the multi add code in apllication_top.php

 

 

// Shopping cart actions

 if (isset($HTTP_GET_VARS['action'])) {

   if (DISPLAY_CART == 'true') {

     $goto =  FILENAME_SHOPPING_CART;

     $parameters = array('action', 'cPath', 'products_id', 'pid');

   } else {

     $goto = basename($PHP_SELF);

     if ($HTTP_GET_VARS['action'] == 'buy_now') {

       $parameters = array('action', 'pid', 'products_id');

     } else {

       $parameters = array('action', 'pid');

     }

   }

///////////////////////////////////////// Products Multi //////////////////////

     if ($HTTP_GET_VARS['action'] == 'add_multi') {

       $parameters = array('action', 'pid', 'products_id');

     }#

///////////////////////////////////////// Products Multi //////////////////////

   switch ($HTTP_GET_VARS['action']) {

///////////////////////////////////////// Products Multi //////////////////////

     // multi_product_add

     case 'add_multi':

       for ($i=1;);$i++) {

         $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['id'][$i]))+($HTTP_POST_VARS['add_id'][$i]), $HTTP_POST_VARS['id'][$i]);

       }

       tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'));

     break;

///////////////////////////////////////// Products Multi //////////////////////      

   

  // customer wants to update the product quantity in their shopping cart

 

Could I do something like for ($i=1; and change it to for ($i=1, $i=p;

 

Thanks in advance!

 

Thomas

Link to comment
Share on other sites

I have added a quantity box next to the normal button and want to name this id 1
I know it's not what you asked, but why not just name this quantity rather than id 1?

 

Hth,

Matt

Link to comment
Share on other sites

Thanks Matt,

 

Well that just wouldn't work if I tried to share the multi-add to cart form. but I think I have managed to figure out my problem...

 

What I did is I added a row in the main body text area. I made the left column have a rowspan of 2 (therfore not messing up the rendering of the page)

 

Then I used the multi-add for family groups...and if I had no family groups i used the normal form...I am still working on it...

 

basically I am making one product with sizes in a separate folder. These are all family related to the main product. There will be no links in the family table and so people will add products with only visiting the main product...

 

A little though to describe...

 

I have a testing category here. Customer's don't have access to it right now. if you visit any of the products you an find in the drop-down menu...you will see the normal add-to-cart button again...

 

what do you think?

 

I'm doing this because i want to get rid of the attributes. It just gets messy. So far I have close to 200 different attributes...and the owners don't know how to update the prices etc.

 

Plus this way I can have separate prices for customers that are part of a sponsorship program...and it will be easy to post JUST one size as a special etc.

 

I removed the links from family product listing because I want to funnel viewers to the main product. This way. and hopefully I won't have product reviews for basically the same tire (but in 20 different sizes)

 

This is the testing product:

 

http://www.crstires.com/product_info.php?c...products_id=199

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...