I just try to fit this contributen for my needs an need some help.
Actual I´m displaying the Product Attributes in the shop as a list with a Quantity Boxes - some kind of add multiple products to cart at once.
I want the same for the QTpro contrib but now i´m stuck. I´m using the QT stock table display to get this to work. Inserting a model Number for each attribute combination wasnßt that difficult but trying to get quantity Boxes to bulk buy the attributes is a bit different :blush:
This is the code to add multiple attributes with quantity to cart in application_top:
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 in the product_info:
<?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']); ?>
... but to get it work with QTpro i have to merge it with this:
case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
//++++ QT Pro: Begin Changed code
$attributes=array();
if (isset($HTTP_POST_VARS['attrcomb']) && (preg_match("/^\d{1,10}-\d{1,10}(,\d{1,10}-\d{1,10})*$/",$HTTP_POST_VARS['attrcomb']))) {
$attrlist=explode(',',$HTTP_POST_VARS['attrcomb']);
foreach ($attrlist as $attr) {
list($oid, $oval)=explode('-',$attr);
if (is_numeric($oid) && $oid==(int)$oid && is_numeric($oval) && $oval==(int)$oval)
$attributes[$oid]=$oval;
}
}
if (isset($HTTP_POST_VARS['id']) && is_array($HTTP_POST_VARS['id'])) {
foreach ($HTTP_POST_VARS['id'] as $key=>$val) {
if (is_numeric($key) && $key==(int)$key && is_numeric($val) && $val==(int)$val)
$attributes=$attributes + $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);
//++++ QT Pro: End Changed Code
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
Has onyone an idea how to merge these codes?