LazyCat Posted June 11, 2003 Share Posted June 11, 2003 Hi! i've posted my first contribution, called Discount Groups. As reported in the contribution description, it allows admins to create user groups and assign them category specific discount percentages and default discounts. basically, all discounts are integer positive number, and the default discount is used on all products aside the categories specified by the coategory discounts. As said in the description, the customers are completely unaware of which group they're in or how much the discount is i opened this thread for feedback, suggestions, question or whatever yu may want to ask! i hope you'll findit interesting btw, the contribution is here http://www.oscommerce.com/community/contributions,1288 bye bye! Enrico Quote Link to comment Share on other sites More sharing options...
djansen Posted June 11, 2003 Share Posted June 11, 2003 Sounds Great, i'm on my n'th discount install, hope this one works as i need. Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 12, 2003 Author Share Posted June 12, 2003 i've posted a bugfixed version. It removes a problem in calculating the discount for a products not picked ub by category like, for example. the manufacturer combobox. now the code checks in wich categories the products is in and then applies the best discount Quote Link to comment Share on other sites More sharing options...
Guest Posted June 12, 2003 Share Posted June 12, 2003 Sounds interesting Enrico... I'll give it a whirl ASAP... shall post my thoughts back on this thread... I assume it is coded for MS1? Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 12, 2003 Author Share Posted June 12, 2003 actually, i got a snapshot a week before the milestone, but looking to the changelogs i couln't find any major difference between the MS1 and the snapshot on the parts i've modified... Quote Link to comment Share on other sites More sharing options...
THX Posted June 12, 2003 Share Posted June 12, 2003 The Install file refers to one file that does not exist and in the changes that need to be made to 'shopping_cart.php' it refers to code that does not exist. Am going to ignore it and continue on, hopefully it works. Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 12, 2003 Author Share Posted June 12, 2003 i've checked for the shopping.cart.php it refers to catalog/includes/classes/shopping_cart.php, which is in the MS1 and in the previous too. the changes there are quite important however, so i suggest you not to install the contribution, because that code is used to put the discounted price inside the cart. without it your customers will only see de discount but they will be billed for the full price Quote Link to comment Share on other sites More sharing options...
THX Posted June 12, 2003 Share Posted June 12, 2003 i've checked for the shopping.cart.phpit refers to catalog/includes/classes/shopping_cart.php, which is in the MS1 and in the previous too. the changes there are quite important however, so i suggest you not to install the contribution, because that code is used to put the discounted price inside the cart. without it your customers will only see de discount but they will be billed for the full price Your install file refers to a file called default_specials.php which does not exist as far as I can see. Also the code in the shopping_cart.php refers to code not in the file under catalog/includes but half of it can be found in the other shopping_cart file under admin/includes so...? Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 12, 2003 Author Share Posted June 12, 2003 ii'll check for the code in default_specialis.php and shopping_cart.php a.s.a.p. thanks for the hint. Quote Link to comment Share on other sites More sharing options...
THX Posted June 12, 2003 Share Posted June 12, 2003 No problem. I think I have it 80% working at the moment. Am having some problems with the product listing code now with a 'Fatal error: Call to undefined function: display_price_listing() ' Anyway still working, for the record this Mod is exactly what I need for my website so I hope I can get it working 100%. Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 12, 2003 Author Share Posted June 12, 2003 for a quick fix i've checked the part about defautl_specials.php just ignore that file for the moment, and for display_price_listing() replace the call with display_price(), same variables. i'm still working about it, but that should fix the problem. More info as soon as i have them :) Quote Link to comment Share on other sites More sharing options...
THX Posted June 12, 2003 Share Posted June 12, 2003 That fixed that problem - thanks. Problem I have now is all prices are being displayed as $0.00, I did note something interesting when I placed a product on 'special' with say 5% discount, the "group" discount was then applied and the price displayed correctly e.g. 5% discount on RRP then another 5% for the "group" discount. Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 12, 2003 Author Share Posted June 12, 2003 huummm... weird, i never had that kind of problem, even if i use diplay_price() could you please tell me in with page does that problem arise? thanks Quote Link to comment Share on other sites More sharing options...
THX Posted June 12, 2003 Share Posted June 12, 2003 Happens in the product listing page. I may have missed a piece of code somewhere(is 1am here) or maybe not. I will check it again tomorrow but for the moment there is a problem somewhere.. Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 12, 2003 Author Share Posted June 12, 2003 Happens in the product listing page. I may have missed a piece of code somewhere(is 1am here) or maybe not. I will check it again tomorrow but for the moment there is a problem somewhere.. it's just there or also in the products_info.php (the product's details) ? Quote Link to comment Share on other sites More sharing options...
THX Posted June 12, 2003 Share Posted June 12, 2003 It also does not display in the products_info screen. Quote Link to comment Share on other sites More sharing options...
osik Posted June 13, 2003 Share Posted June 13, 2003 Thank you for contribution. Pls help with zero price in default.php when showing list of category products & the same - zero price, in product_info.php... Quote Link to comment Share on other sites More sharing options...
osik Posted June 13, 2003 Share Posted June 13, 2003 !!! when changed $product_info_values in this block of code $price = $product_info_values['products_price']; if ($discount > 0) $price = $price - ($price/100)*$discount; $products_price = $currencies->display_price($price, tep_get_tax_rate($product_info_values['products_tax_class_id'])); for $product_info - price is showing all above conserning price in product_info.php hope that same solution in general.php Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 13, 2003 Author Share Posted June 13, 2003 i'm checking on it. btw the right file for the problem shown in default.php is instead the includes/modules/products_listing.php try replacing if ($listing_values['specials_new_products_price']) { $price = $listing_values['specials_new_products_price']; if ($discount > 0) $price = $price - ($price/100)*$discount; $lc_text = ' <s>' . $currencies->display_price_listing($listing_values['products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</s> <br/><span class="productSpecialPrice">' . $currencies->display_price_listing($price, tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</span> '; } else { $price = $listing_values['products_price']; if ($discount > 0) $price = $price - ($price/100)*$discount; $lc_text = ' ' . $currencies->display_price_listing($price, tep_get_tax_rate($listing_values['products_tax_class_id'])) . ' '; } with if ($listing['specials_new_products_price']) { $price = $listing['specials_new_products_price']; if ($discount > 0) $price = $price - ($price/100)*$discount; $lc_text = ' <s>' . $currencies->display_price_listing($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s> <br/><span class="productSpecialPrice">' . $currencies->display_price_listing($price, tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> '; } else { $price = $listing['products_price']; if ($discount > 0) $price = $price - ($price/100)*$discount; $lc_text = ' ' . $currencies->display_price_listing($price, tep_get_tax_rate($listing['products_tax_class_id'])) . ' '; } this solution is untested, i'm currently installing MS1 with my own contribution so to check the actual differences, instead on relying on changelogs Quote Link to comment Share on other sites More sharing options...
osik Posted June 13, 2003 Share Posted June 13, 2003 ok, i'll try it tell pls about price in last added product section - are there prices must be shown with group dicsount or not, because now are shown without discount? Quote Link to comment Share on other sites More sharing options...
osik Posted June 13, 2003 Share Posted June 13, 2003 the same question about price in new/last added products box... and ((( products in shoping cart showing with prices without discount, only in line total - price with discount Quote Link to comment Share on other sites More sharing options...
LazyCat Posted June 13, 2003 Author Share Posted June 13, 2003 Being this contribution born as specific modification asked by a customer of mine, the new/last box was left behind because unused. i'm planning to modify it too as soon as possible could you please be more specific in the problem regarding the shopping cart? only the total shouws the right amount of discount? Quote Link to comment Share on other sites More sharing options...
osik Posted June 13, 2003 Share Posted June 13, 2003 yes, only the total Quote Link to comment Share on other sites More sharing options...
osik Posted June 13, 2003 Share Posted June 13, 2003 Being this contribution born as specific modification asked by a customer of mine, the new/last box was left behind because unused. i'm planning to modify it too as soon as possible could you please be more specific in the problem regarding the shopping cart? only the total shouws the right amount of discount? ))) and dont forget about new_products.php Quote Link to comment Share on other sites More sharing options...
osik Posted June 13, 2003 Share Posted June 13, 2003 little addon wrom me - boxes/whats_new.php */ if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { ?> <!-- whats_new //--> <tr> <td> <?php $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_WHATS_NEW); new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_PRODUCTS_NEW)); $category = tep_get_best_category_discount($random_product["products_id"]); $price = $random_product['products_price']; if ($category >= 0 ) { $discount = tep_get_discount($category); if ($discount > 0) $price = $price - ($price/100)*$discount; } if (tep_not_null($random_product['specials_new_products_price'])) { $whats_new_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $whats_new_price .= '<span class="productSpecialPrice">' . $currencies->display_price($price, tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $whats_new_price = $currencies->display_price($price, tep_get_tax_rate($random_product['products_tax_class_id'])); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $category . 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $whats_new_price); new infoBox($info_box_contents); ?> </td> </tr> <!-- whats_new_eof //--> <?php } ?> when special price presents - shown like for default group without discount i'll try to change new_products.php too !!! help pls with shopping cart above mentioned problem my shopping_card.php, pls look at this: <?php /* $Id: shopping_cart.php,v 1.32 2003/02/11 00:04:53 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ class shoppingCart { var $contents, $total, $weight, $cartID, $content_type; function shoppingCart() { $this->reset(); } function restore_contents() { global $customer_id; if (!tep_session_is_registered('customer_id')) return false; // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $cat = $this->contents[$products_id]['cat']; $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . $customer_id . "' and products_id = '" . $products_id . "'"); if (!tep_db_num_rows($product_query)) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added, category_id) values ('" . $customer_id . "', '" . $products_id . "', '" . $qty . "', '" . date('Ymd'). "','" . $cat . "')"); if (isset($this->contents[$products_id]['attributes'])) { for ($cont = 0; $cont < sizeof($this->contents[$products_id]['attributes']) ; $cont++) { reset($this->contents[$products_id]['attributes'][$cont]); while (list($option, $value) = each($this->contents[$products_id]['attributes'][$cont])) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . $customer_id . "', '" . $products_id . "', '" . $option . "', '" . $value . "')"); } } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set category_id = '". $cat ."', customers_basket_quantity = '" . $qty . "' where customers_id = '" . $customer_id . "' and products_id = '" . $products_id . "'"); } } } // reset per-session cart contents, but not the database contents $this->reset(false); $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . $customer_id . "'"); while ($products = tep_db_fetch_array($products_query)) { $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); // attributes $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . $customer_id . "' and products_id = '" . $products['products_id'] . "'"); $contatore = 0; while ($attributes = tep_db_fetch_array($attributes_query)) { $this->contents[$products['products_id']]['attributes'][$contatore++][$attributes['products_options_id']] = $attributes['products_options_value_id']; } } $this->cleanup(); } function reset($reset_database = false) { global $customer_id; $this->contents = array(); $this->total = 0; $this->weight = 0; $this->content_type = false; if (tep_session_is_registered('customer_id') && ($reset_database == true)) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . $customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . $customer_id . "'"); } unset($this->cartID); if (tep_session_is_registered('cartID')) tep_session_unregister('cartID'); } function add_cart($products_id, $qty = '1', $attributes = '', $category_id, $notify = true) { global $new_products_id_in_cart, $customer_id; $products_id = tep_get_uprid($products_id, $attributes); if ($notify == true) { $new_products_id_in_cart = $products_id; tep_session_register('new_products_id_in_cart'); } if ($this->in_cart($products_id)) { $this->update_quantity($products_id, $qty, $attributes); } else { $this->contents[] = array($products_id); $this->contents[$products_id] = array('qty' => $qty, 'cat' => $category_id); // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added, category_id) values ('" . $customer_id . "', '" . $products_id . "', '" . $qty . "', '" . date('Ymd') . "','" . $category_id . "')"); if (is_array($attributes)) { reset($attributes); $contatore = 0; while (list( , $option_value) = each($attributes)) { $option_value2 = split('[{}]',$option_value); for ($i = 1; $i < sizeof($option_value2) ; $i+=2) { $option = $option_value2[$i]; $value = $option_value2[$i+1]; $attribute_price_query = tep_db_query("select options_values_qty, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if (strchr($attribute_price['price_prefix'],'m')) { if ($this->contents[$products_id]['qty'] < $attribute_price['options_values_qty']) $this->contents[$products_id]['qty'] = $attribute_price['options_values_qty']; } if (strchr($attribute_price['price_prefix'],'M')) { if ($this->contents[$products_id]['qty'] > $attribute_price['options_values_qty']) $this->contents[$products_id]['qty'] = $attribute_price['options_values_qty']; } $this->contents[$products_id]['attributes'][$contatore++][$option] = $value; // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . $customer_id . "', '" . $products_id . "', '" . $option . "', '" . $value . "')"); } } } } $this->cleanup(); // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function update_quantity($products_id, $quantity = '', $attributes = '') { global $customer_id; if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true.. $this->contents[$products_id] = array('qty' => $quantity); // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set category_id = '". $cat ."', customers_basket_quantity = '" . $quantity . "' where customers_id = '" . $customer_id . "' and products_id = '" . $products_id . "'"); if (is_array($attributes)) { reset($attributes); $contatore = 0; while (list( , $option_value) = each($attributes)) { $option_value2 = split('[{}]',$option_value); for ($i = 1; $i < sizeof($option_value2) ; $i+=2) { $option = $option_value2[$i]; $value = $option_value2[$i+1]; $attribute_price_query = tep_db_query("select options_values_qty, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if (strchr($attribute_price['price_prefix'],'m')) { if ($this->contents[$products_id]['qty'] < $attribute_price['options_values_qty']) $this->contents[$products_id]['qty'] = $attribute_price['options_values_qty']; } if (strchr($attribute_price['price_prefix'],'M')) { if ($this->contents[$products_id]['qty'] > $attribute_price['options_values_qty']) $this->contents[$products_id]['qty'] = $attribute_price['options_values_qty']; } $this->contents[$products_id]['attributes'][$contatore++][$option] = $value; } } } } function cleanup() { global $customer_id; reset($this->contents); while (list($key,) = each($this->contents)) { if ($this->contents[$key]['qty'] < 1) { unset($this->contents[$key]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . $customer_id . "' and products_id = '" . $key . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . $customer_id . "' and products_id = '" . $key . "'"); } } } } function count_contents() { // get total number of items in cart $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $total_items += $this->get_quantity($products_id); } } return $total_items; } function get_quantity($products_id) { if (isset($this->contents[$products_id])) { return $this->contents[$products_id]['qty']; } else { return 0; } } function in_cart($products_id) { if (isset($this->contents[$products_id])) { return true; } else { return false; } } function remove($products_id) { global $customer_id; unset($this->contents[$products_id]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . $customer_id . "' and products_id = '" . $products_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . $customer_id . "' and products_id = '" . $products_id . "'"); } // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function remove_all() { $this->reset(); } function get_product_id_list() { $product_id_list = ''; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $product_id_list .= ', ' . $products_id; } } return substr($product_id_list, 2); } function calculate() { $this->total = 0; $this->weight = 0; if (!is_array($this->contents)) return 0; reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $cat = $this->contents[$products_id]['cat']; // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . tep_get_prid($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']); // AWB+ PRICE-BREAK $products_price = awb_pb_get_price(tep_get_prid($products_id), $qty); // AWB- PRICE-BREAK $products_weight = $product['products_weight']; $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'"); if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } global $customer_id; $and = ""; if ($customer_id != null) { $and = " and customers_id=" . $customer_id; } $products_discount_query = tep_db_query("select category_id from " . TABLE_CUSTOMERS_BASKET . " where products_id=" . $prid . $and); $category_id = tep_db_fetch_array($products_discount_query); $discount = tep_get_discount($category_id['category_id']); $products_price = $products_price - ($products_price/100)*$discount; $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); } // attributes price if (isset($this->contents[$products_id]['attributes'])) { for ($cont = 0; $cont < sizeof($this->contents[$products_id]['attributes']) ; $cont++) { reset($this->contents[$products_id]['attributes'][$cont]); while (list($option, $value) = each($this->contents[$products_id]['attributes'][$cont])) { $attribute_price_query = tep_db_query("select options_values_qty, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $prid . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if (strchr($attribute_price['price_prefix'],'+')) { $this->total += $qty * tep_add_tax(tep_prefix_options($attribute_price['price_prefix'],$attribute_price['options_values_price'],$attribute_price['options_values_qty'],$qty), $products_tax); } else if (strchr($attribute_price['price_prefix'],'-')) { $this->total -= $qty * tep_add_tax(tep_prefix_options($attribute_price['price_prefix'],$attribute_price['options_values_price'],$attribute_price['options_values_qty'],$qty), $products_tax); } } } } } } function attributes_price($products_id) { if (isset($this->contents[$products_id]['attributes'])) { for ($cont = 0; $cont < sizeof($this->contents[$products_id]['attributes']) ; $cont++) { reset($this->contents[$products_id]['attributes'][$cont]); while (list($option, $value) = each($this->contents[$products_id]['attributes'][$cont])) { $attribute_price_query = tep_db_query("select options_values_qty, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $option . "' and options_values_id = '" . $value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if (strchr($attribute_price['price_prefix'],'+')) { $attributes_price += tep_prefix_options($attribute_price['price_prefix'],$attribute_price['options_values_price'],$attribute_price['options_values_qty'],$this->contents[$products_id]['qty']); } else if (strchr($attribute_price['price_prefix'],'-')) { $attributes_price -= tep_prefix_options($attribute_price['price_prefix'],$attribute_price['options_values_price'],$attribute_price['options_values_qty'],$this->contents[$products_id]['qty']); } } } } return $attributes_price; } 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_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . tep_get_prid($products_id) . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'"); if ($products = tep_db_fetch_array($products_query)) { $prid = $products['products_id']; $products_price = $products['products_price']; $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'"); if (tep_db_num_rows($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } global $customer_id; $and = ""; if ($customer_id != null) { $and = " and customers_id=" . $customer_id; } $products_discount_query = tep_db_query("select category_id from " . TABLE_CUSTOMERS_BASKET . " where products_id=" . $prid. $and); $category_id = tep_db_fetch_array($products_discount_query); $discount = tep_get_discount($category_id['category_id']); $products_price = $products_price - ($products_price/100)*$discount; $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => $this->contents[$products_id]['attributes']); } } return $products_array; } function show_total() { $this->calculate(); return $this->total; } function show_weight() { $this->calculate(); return $this->weight; } function generate_cart_id($length = 5) { return tep_create_random_value($length, 'digits'); } function get_content_type() { $this->content_type = false; if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list(, $value) = each($this->contents[$products_id]['attributes'])) { $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . $products_id . "' and pa.options_values_id = '" . $value . "' and pa.products_attributes_id = pad.products_attributes_id"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { $this->content_type = 'physical'; } return $this->content_type; } function unserialize($broken) { for(reset($broken);$kv=each($broken);) { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } } ?> 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.