Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Problem with code to add multiple products


peteravu

Recommended Posts

Posted

I have installed Add Multiple Products with plus/minus buttons

 

 

Very nice add.

The only problem is products with Attributes, the Attributes do not show, and product with Attributes does not add to the Shopping Cart.

The minimum must be that Attributes is showed and add to the shopping cart.

The best would be that each Attributes was listed and could be added to the shopping cart with the plus and minus buttons.

But how to make that?

 

 

 

I also tried to installed "Attribute Qty Product Info"

but the code in 2.3.1 is different from the add on so I try to modify the code, the only thing that shows are "Option Model Price Quantity" headline, why the rest do not show

What did I do wrong?

I made the following changes but it still not work at all

also now cannot add any product to cart any more.

How to do?

 

In product_info.php

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_mult2')); ?>

and

?>

<p><?php echo TEXT_PRODUCT_OPTIONS; ?>
<?php echo TEXT_PRODUCT_MODEL; ?>
<?php echo TEXT_PRODUCT_PRICE; ?>
<?php echo TEXT_PRODUCT_QUANTITY; ?></p>

<p>
<?php

and

$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
if ($products_options[$n]['options_values_price'] != '0') {
$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
if ($products_options['price_prefix'] == '+') {
$price_with_attribute = ($product_info['products_price'] + $products_options['options_values_price']);
} else {
$price_with_attribute = ($product_info['products_price'] - $products_options['options_values_price']);
}
?>
<tr>
<td class="main" align="center">
<?php echo $products_options['products_options_values_name'];
echo tep_draw_hidden_field('a[]', $products_options['products_options_values_id']);
echo tep_draw_hidden_field('b[]',$products_options_name['products_options_id']); ?> </td>
<td class="main" align="center">
<?php /* uncomment if you want to show the model number
echo $product_info['products_model']; */
?>
</td>
<td class="main" align="center"><?php echo $currencies->display_price($price_with_attribute, tep_get_tax_rate($product_info['products_tax_class_id'])); ?></td>
<td class="main" align="center"><?php echo tep_draw_input_field('quantity[]',$value = '0',"size=2");?></td>
</tr>
<?php
$x++;

and

/* ?>
// <strong><?php echo $products_options_name['products_options_name'] . ':'; ?></strong><br /><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?><br />
<?php
*/

In includes/application_top.php

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
// customer adds multiple products from the product_info page
case 'add_mult2' : 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;
// 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'])) {
$attributes = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : '';
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $attributes))+1, $attributes);
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;

in catalog/includes/languages/english/product_info.php

define('TEXT_PRODUCT_NOT_FOUND', 'Product not found!');
define('TEXT_CURRENT_REVIEWS', 'Current Reviews:');
define('TEXT_MORE_INFORMATION', 'For more information, please visit this products <a href="%s" target="_blank"><u>webpage</u></a>.');
define('TEXT_DATE_ADDED', 'This product was added to our catalog on %s.');
define('TEXT_DATE_AVAILABLE', '<font color="#ff0000">This product will be in stock on %s.</font>');
define('TEXT_ALSO_PURCHASED_PRODUCTS', 'Customers who bought this product also purchased');
define('TEXT_PRODUCT_OPTIONS', 'Available Options:');
define('TEXT_CLICK_TO_ENLARGE', 'Click to enlarge');
define('TEXT_PRODUCT_OPTION', 'Option');
define('TEXT_PRODUCT_MODEL', 'Model');
define('TEXT_PRODUCT_QUANTITY', 'Quantity');
define('TEXT_PRODUCT_PRICE', 'Price');
?>

Archived

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

×
×
  • Create New...