Amadeuss Posted February 3, 2009 Share Posted February 3, 2009 First of all the contribution can be found here http://addons.oscommerce.com/info/3159 Now... I've searched everywhere for support and couldn't find it. I love the add-on, it works very good with oscommerce and very easy to install. But there is a small inconvenience. It does not provide discount for different attributes at the same product. For example a blue hat and a black hat. If I buy two the same color there is a 10% discount But if I buy one blue and one black there is no discount. Can anyone suggest an idea? Thank you! Quote Link to comment Share on other sites More sharing options...
Amadeuss Posted February 3, 2009 Author Share Posted February 3, 2009 I will post the Instructions here. In case someone doesn't want to download the contribution. So.... the code is not a lot but I can't seem to be able to realize what needs to be modified so it will work for all attributes. ************* admin/includes/functions/general.php add after: tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . (int)$product_id . "'"); this: //BEGIN www.ocean-internet.de - Discount Plus tep_db_query("delete from " . TABLE_DISCOUNTPLUS . " where products_id = '" . (int) $product_id . "'"); //END www.ocean-internet.de - Discount Plus ********* admin/categories.php add after: if ($action == 'insert_product') { $insert_sql_data = array('products_id' => $products_id, 'language_id' => $language_id); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array); } elseif ($action == 'update_product') { tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'"); } } this: //BEGIN www.ocean-internet.de - Discount Plus tep_db_query("delete from " . TABLE_DISCOUNTPLUS . " where products_id = '" . $products_id . "'"); $s=1; for ($i=0; $i<DISCOUNTPLUS_number; $i++) { if ($HTTP_POST_VARS['quantity'.$s] > '0') { $insert_sql_data = array('products_id' => $products_id, 'quantity' => tep_db_prepare_input($HTTP_POST_VARS['quantity'.$s]), 'value' => tep_db_prepare_input($HTTP_POST_VARS['value'.$s]), 'valuetyp' => tep_db_prepare_input($HTTP_POST_VARS['valuetyp'.$s])); tep_db_perform(TABLE_DISCOUNTPLUS, $insert_sql_data); } $s++; } //END www.ocean-internet.de - Discount Plus add after: <tr bgcolor="#ebebff"> <td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td> </tr> .... <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> this: <?php //BEGIN www.ocean-internet.de - Discount Plus ?> <?php if (DISCOUNTPLUS_number > 0){ ?> <tr> <td class="main" valign="top"><?php echo TEXT_DISCOUNTPLUS_DISCOUNTS; ?></td> <td class="main"> <table border="0" width=""> <tr> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15'); ?></td> <td class="main"><?php echo TEXT_DISCOUNTPLUS_NUMBER;?></td> <td class="main"><?php echo TEXT_DISCOUNTPLUS_DISCOUNT;?></td> <td></td> </tr> <?php $discountplus_query = tep_db_query("select quantity, value, valuetyp from " . TABLE_DISCOUNTPLUS . " where products_id = '" . $pInfo->products_id . "' order by quantity "); $s=1; for ($i=0; $i<DISCOUNTPLUS_number; $i++) { $discountplus_data = tep_db_fetch_array($discountplus_query); ?> <tr> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15'); ?></td> <td class="main"><?php echo TEXT_DISCOUNTPLUS_FROM . " " . tep_draw_input_field('quantity'.$s,$discountplus_data['quantity'],"size='6'");?></td> <td class="main" class="main"> <?php echo tep_draw_input_field('value'.$s, $discountplus_data['value'],"size='6'"); ?> </td> <?php switch ($discountplus_data['valuetyp']) { case "endprice": $checked_percent = false; $checked_price = false; $checked_endprice = true; break; case "price": $checked_percent = false; $checked_price = true; $checked_endprice = false; break; default: $checked_percent = true; $checked_price = false; $checked_endprice = false; break; } ?> <td class="main"><?php echo tep_draw_radio_field('valuetyp'.$s, 'percent', $checked_percent); echo TEXT_DISCOUNTPLUS_PERCENTDISCOUNT; ?> <?php echo tep_draw_radio_field('valuetyp'.$s, 'price', $checked_price); echo TEXT_DISCOUNTPLUS_PRICEDISCOUNT; ?> <?php echo tep_draw_radio_field('valuetyp'.$s, 'endprice', $checked_endprice); echo TEXT_DISCOUNTPLUS_UNITPRICE; ?></td> </tr> <?php $s++; } ?> </table> </td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php } ?> <?php //END www.ocean-internet.de - Discount Plus ?> ******************************************************* ********* ****************catalog/includes/classes/shopping_cart.php add after: // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; this: // BEGIN www.ocean-internet.de - Discount Plus $discountplus_query = tep_db_query("select quantity, value, valuetyp from " . TABLE_DISCOUNTPLUS . " where products_id = $prid " . " and quantity <= $qty order by quantity desc"); if(tep_db_num_rows($discountplus_query)) { $discountplus_data = tep_db_fetch_array($discountplus_query); if ($discountplus_data['valuetyp'] == "price") $products_price = $products_price-$discountplus_data['value']; elseif ($discountplus_data['valuetyp'] == "endprice") $products_price = $discountplus_data['value']; else $products_price = $products_price-(($products_price/100)*$discountplus_data['value']); } // END www.ocean-internet.de - Discount Plus add after: function get_products() { global $languages_id; if (!is_array($this->contents)) return false; $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); if ($products = tep_db_fetch_array($products_query)) { $prid = $products['products_id']; $products_price = $products['products_price']; this: // BEGIN www.ocean-internet.de - Discount Plus $attributes_price = $this->attributes_price($products_id); $qty = $this->contents[$products_id]['qty']; $discountplus_query = tep_db_query("select quantity, value, valuetyp from " . TABLE_DISCOUNTPLUS . " where products_id = $prid " . " and quantity <= $qty order by quantity desc"); if(tep_db_num_rows($discountplus_query)) { $discountplus_data = tep_db_fetch_array($discountplus_query); if ($discountplus_data['valuetyp'] == "price") $products_price = $products_price-$discountplus_data['value']; elseif ($discountplus_data['valuetyp'] == "endprice") $products_price = $discountplus_data['value']; else { $products_price = $products_price-(($products_price/100)*$discountplus_data['value']); $attributes_price = $attributes_price-(($attributes_price/100)*$discountplus_data['value']); } } // END www.ocean-internet.de - Discount Plus change this: $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), to: $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], ///'final_price' => ($products_price + $this->attributes_price($products_id)),///www.ocean-internet.de - Discount Plus 'final_price' => ($products_price + $attributes_price),///www.ocean-internet.de - Discount Plus change this: // attributes price if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } else { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } } } to: // attributes price if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { ///$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);///www.ocean-internet.de - Discount Plus // BEGIN www.ocean-internet.de - Discount Plus if ($discountplus_data['valuetyp'] != "price" && $discountplus_data['valuetyp'] != "endprice") $this->total += $qty * tep_add_tax($attribute_price['options_values_price']-(($attribute_price['options_values_price']/100)*$discountplus_data['value']), $products_tax); else $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); // END www.ocean-internet.de - Discount Plus } else { ///$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);///www.ocean-internet.de - Discount Plus // BEGIN www.ocean-internet.de - Discount Plus if ($discountplus_data['valuetyp'] != "price" && $discountplus_data['valuetyp'] != "endprice") $this->total -= $qty * tep_add_tax($attribute_price['options_values_price']-(($attribute_price['options_values_price']/100)*$discountplus_data['value']), $products_tax); else $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); // END www.ocean-internet.de - Discount Plus } } } ********* catalog/includes/classes/order.php change this: $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']); to: $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { // BEGIN www.ocean-internet.de - Discount Plus $attributes_price = $cart->attributes_price($products[$i]['id']); $tmpprid = explode("{",$products[$i]['id']); $prid = $tmpprid[0]; $qty = $products[$i]['quantity']; $discountplus_query = tep_db_query("select quantity, value, valuetyp from " . TABLE_DISCOUNTPLUS . " where products_id = $prid " . " and quantity <= $qty order by quantity desc"); if(tep_db_num_rows($discountplus_query)) { $discountplus_data = tep_db_fetch_array($discountplus_query); if ($discountplus_data['valuetyp'] != "price" && $discountplus_data['valuetyp'] != "endprice") $attributes_price = $attributes_price-(($attributes_price/100)*$discountplus_data['value']); } $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $attributes_price, 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']); // END www.ocean-internet.de - Discount Plus ****catalog/product_info.php add after: $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); if ($new_price = tep_get_products_special_price($product_info['products_id'])) { this: // BEGIN www.ocean-internet.de - Discount Plus $specialprice = true; // END www.ocean-internet.de - Discount Plus add after: <p><?php echo stripslashes($product_info['products_description']); ?></p> this: <?php // BEGIN www.ocean-internet.de - Discount Plus if (DISCOUNTPLUS_number > 0 && !$specialprice){ $discountplus_query = tep_db_query("select quantity, value, valuetyp from " . TABLE_DISCOUNTPLUS . " where products_id = '" . $product_info['products_id'] . "' order by quantity "); if (tep_db_num_rows($discountplus_query) > 0) { ?> <?php echo TEXT_DISCOUNTPLUS_DISCOUNTS; ?><br> <table border="0"> <tr> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15'); ?></td> <td class="main" valign="top"><?php echo TEXT_DISCOUNTPLUS_NUMBER;?> </td> <td class="main" align="right" valign="top"> <?php echo TEXT_DISCOUNTPLUS_DISCOUNT;?></td> <td class="main" align="right" valign="top"> <?php echo TEXT_DISCOUNTPLUS_UNITPRICE;?></td> </tr> <?php $s=1; for ($i=0; $i<DISCOUNTPLUS_number; $i++) { $discountplus_data = tep_db_fetch_array($discountplus_query); if ($discountplus_data['quantity'] > 0) { ?> <tr> <td class="main" valign="top"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15'); ?></td> <td class="main" valign="top"><?php echo TEXT_DISCOUNTPLUS_FROM." ". $discountplus_data['quantity']?> </td> <td class="main" align="right" valign="top"> <?php if ($discountplus_data['valuetyp'] == "price") $discountplus_rabatt = $currencies->display_price($discountplus_data['value'], tep_get_tax_rate($product_info['products_tax_class_id'])); elseif ($discountplus_data['valuetyp'] == "endprice") $discountplus_rabatt = "->"; else $discountplus_rabatt = ($discountplus_data['value']+0)."%"; echo $discountplus_rabatt; ?> </td> <td class="main" align="right" valign="top"> <b><?php if ($discountplus_data['valuetyp'] == "price") $discountplus_price = $product_info['products_price']-$discountplus_data['value']; elseif ($discountplus_data['valuetyp'] == "endprice") $discountplus_price = $discountplus_data['value']; else $discountplus_price = $product_info['products_price']-(($product_info['products_price']/100)*$discountplus_data['value']); $discountplus_price_output = $currencies->display_price($discountplus_price, tep_get_tax_rate($product_info['products_tax_class_id'])); echo $discountplus_price_output; ?></b></td> </tr> <?php } $s++; } ?> </table> <?php } } // END www.ocean-internet.de - Discount Plus ?> Quote Link to comment Share on other sites More sharing options...
Amadeuss Posted February 9, 2009 Author Share Posted February 9, 2009 I also added product numbers but still no results.Anyone? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.