Jump to content

Oscommerce


RAH

Recommended Posts

Hi,

 

I have 2 contributions installed for Oscommerce that affect the Product Info page, one creates a list of product attributes so that customers can add the quantities of each attribute required (different weights), this uses a add_mult function in the application_top.php file that comes with the contribution.

 

The other contribution is used to create another product attribute that is a text box so the customer can 'write a note' about the product, this one is designed to use the default add_product function in application_top.php.

 

My problem is that they use different means of parsing the product info contents  and I don't know how to make both work together.

 

Here is the function that came with the contribution that adds quantities of each attribute, this is found in the application_top.php file:-

 

// BOF QUANTITY PRODUCT INFO

// customer adds multiple products from the product_info page

      case 'add_mult' : if (is_array($HTTP_POST_VARS['a'])){

        reset($HTTP_POST_VARS['quantity']);

  reset($HTTP_POST_VARS['a']);

 

  $x=0;

  if (is_array($HTTP_POST_VARS['a'])){

    foreach(($HTTP_POST_VARS['a']) as $key => $value){

      $c = array((int)$HTTP_POST_VARS['b'][$x] => (int)$value); 

   

      if (is_array($HTTP_POST_VARS['quantity'])){

        $qty = (int)$HTTP_POST_VARS['quantity'][$x];

       

         

      $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], ($c)))+($qty),($c));

      //$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], ($c)))+($qty),($c), $HTTP_POST_VARS['id']);

      $x++;

   

      }

    }

  }

    } else {

    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

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

                              }

  }

  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

 

                        break;

 

//EOF QUANTITY PRODUCT INFO

 

 

 

           

This is the default add_product function found in application_top.php:-

 

      // customer adds a product from the products page

      case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

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

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

                              }

                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

                              break;

 

 

You can see this in action by going to www.deanforestfayre.co.uk/shop you will need to login with the username test and password test, if you go to a product, choose a quantity and add a message and add to the basket the message does not arrive, this is using the add_mult function at present, if I change it to use the add_product function the message arrives in the basket, and the price total is correct but the quantity is always set to 1. I need to combine the two functions.

 

Any ideas?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/113751-oscommerce/
Share on other sites

Hi,

 

Does this help?

 

Around Line 330 (adding the new case of action='add_mult'):



Find:



// customer adds a product from the products page

case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {



Above this ADD:

// customer adds multiple products from the product_info page

      case 'add_mult' : if (is_array($HTTP_POST_VARS['a'])){

      			  reset($HTTP_POST_VARS['quantity']);

		        reset($HTTP_POST_VARS['a']);

	     	        $x=0;

		        

                          if (is_array($HTTP_POST_VARS['a'])){

		          foreach(($HTTP_POST_VARS['a']) as $key => $value){

		            $c = array((int)$HTTP_POST_VARS['b'][$x] => (int)$value);		



		            if (is_array($HTTP_POST_VARS['quantity'])){

		              $qty = (int)$HTTP_POST_VARS['quantity'][$x];			       

			        $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], ($c)))+($qty),($c));

			        $x++;

  			            }

		          } 

		        }

		      } else {

		        if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

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

                          }

		      }

		      tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

                        break; 

Link to comment
https://forums.phpfreaks.com/topic/113751-oscommerce/#findComment-585251
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.