Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

a LITTLE php help needed


Guest

Recommended Posts

Hi

 

I have tried asking the relative contribution threads to try and solve my problem, here it is

 

I've added the Attribute Qty Product Info contribution which allows you to have a table of attributes with a quantity box along with the Option Type Feature contribution which allows you to add a text box to the product_info page.

 

The layout looks great but when products are added to the cart the text box entry is not added if I have the following in the product_info.php page (this posts the form)

 

 

<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_mult')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

 

 

If I change the above to

 

<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

 

the text box contents are added as an attribute to the cart but the quantity shows as 1 even if it's not, (the price shows correctly for the number of products ordered.

 

As far as I can work out it's down to these bits of code in application_top.php, can anyone help me sort this out as I'm mystified.

 

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'] => (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;

 

 

and

 

// 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']))+1, $HTTP_POST_VARS['id']);
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;

 

 

You can have a look at http://www.deanforestfayre.co.uk/shop you will need to login to the store using test as the username and test as the password

 

I have been going around in circles for days with this and it's the last thing I need to get sorted, I would really appreciate any help in this, thanks

Link to comment
Share on other sites

Did you add a message in the 'Write a note:- box as well, I know that multiple quantities can be added, it's the note bit that is causing a problem

Link to comment
Share on other sites

Its been a while since I did anything with this bit of the cart, but as I recall you must use the 'add_mult' for multiple quantities, & your change to 'add_product' which is for single addition, so it only adds one.

 

You need to look carefully at the code in app top to see what its doing.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

which is what I have been doing for the past few days and I'm a little confused , I think I've found the bits that add the product_info contents into the cart but don't know how to change them to add all the fields into the cart correctly.

Link to comment
Share on other sites

I`ll give you a knock when I'm working on that area again, as its not simple.

 

There's also the issue of how far you want to take the note through checkout, its not easy there iether.

 

;)

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Hi Sam

 

Thanks for the comments, what I don't understand is why the comments are passed throught the system if I use the 'add_product' call from the product_info page, these arrive in the orders in admin but will not do so if I use the 'add_mult' call from the product_info page.

 

The message is an attribute for the product and surely can been sent through the system as such. All I need is for the add_mult option to parse the text box attribute.

 

Unfortunately my php programming skills are extremely limited (I am trying!)

 

Thanks

 

Mark

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...