HairyJim Posted July 12, 2005 Share Posted July 12, 2005 Hi all, I installed the QPB contrib and it works nicely. I would like to show the percentage saved when multi buys are made. On the product_info screen it shows a nice table (Quantity Price Breaks Per Product Price Table Formatter - contribution) that displays the quantity and the price for each quantity. I owuld like to add another row and column for this table so that under each qty & price it showed the % saving. Has someone already done this or is someone familiar enough with this contribution to know how to achieve this? Cheers Jim Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 12, 2005 Author Share Posted July 12, 2005 Actually I solved this. In the priceformatter.php class (this is the one that comes with "Quantity Price Breaks Per Product Price Table Formatter" contribution) I added a new function: function getDiscountSaving($original_price, $discount_price) { $difference = $original_price - $discount_price; $saving = round (($difference / $original_price) * 100) . '%'; return $saving; } Modified an existing function: function getPriceString($style='productPriceInBox') { global $currencies; //Change support special prices //don't display special prices..... if (false == true) { $lc_text = ' <s>' . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass)) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass)) . '</span> '; } else { // If you want to change the format of the price/quantity table // displayed on the product information page, here is where you do it. if($this->hasQuantityPrice == true) { $lc_text = '<table border="0" cellspacing="0" cellpadding="0" class="infoBox" align="left"> <tr valign="top"> <td> <table border="0" cellspacing="1" cellpadding="5" class="infobox">'; $lc_text .= '<tr valign="top"><td width="150" class="infoBoxHeading">QTY</td>' // . $currencies->display_price($this->thePrice, // tep_get_tax_rate($this->taxClass)) . '</td>'; for($i=1; $i<=8; $i++) { if($this->quantity[$i] > 0) { $lc_text .= '<td align="center" width="50" class="infoBoxHeading">' . $this->quantity[$i] .'+ </td>'; } } // <tr valign="top"><td width="150" class="infoBoxContents">M1P102</td><td align="center" width="50" class="infoBoxContents">' // . $currencies->display_price($this->price[$i], // tep_get_tax_rate($this->taxClass)) $lc_text .= '<tr valign="top"><td width="150" class="infoBoxContents">Price each.</td>'; for($i=1; $i<=8; $i++) { if($this->quantity[$i] > 0) { $lc_text .= '<td align="center" width="50" class="infoBoxContents">' . $currencies->display_price($this->price[$i], tep_get_tax_rate($this->taxClass)) .'</td>'; } } $lc_text .= '</tr>'; // Begin saving calculation $lc_text .= '<tr valign="top"><td width="150" class="infoBoxContents">Saving %</td>'; for($i=1; $i<=8; $i++) { if($this->quantity[$i] > 0) { $lc_text .= '<td align="center" width="50" class="infoBoxContents">' . $this->getDiscountSaving($this->price[1], $this->price[$i]) .'</td>'; } } $lc_text .= '</tr></table></td></tr></table>'; } else { $lc_text = ' ' . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass)) . ' '; } } return $lc_text; } People if they wish to use this can just copy and paste the new function in and copy over the old getPriceString function. Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 12, 2005 Author Share Posted July 12, 2005 Added modifications to the Contribution. Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 16, 2005 Share Posted July 16, 2005 (edited) Added modifications to the Contribution. <{POST_SNAPBACK}> Hello Hairy, i have installed yr new Priceformatter... is wonderfull. :) But in old and the new one now, my special Prices are don?t show in product_info. On other places is all ok. What can i do, to solve this problem ?? Greets Hobbes Edited July 16, 2005 by Hobbes_TheReal Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 18, 2005 Author Share Posted July 18, 2005 Hello Hairy, i have installed yr new Priceformatter... is wonderfull. :) But in old and the new one now, my special Prices are don?t show in product_info. On other places is all ok. What can i do, to solve this problem ?? Greets Hobbes <{POST_SNAPBACK}> Hi. Did you make the necessary code changes in the catalog/product_info.php file? Jim Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 18, 2005 Share Posted July 18, 2005 Hello Hairy, yes i have done. But nothing will work. in product info i don?t have that : if ($new_price = tep_get_products_special_price($product_info['products_id'])) { $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>'; } else { $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); } and when i add it, the QPB will not work. Or must this above code into other db query, what comming from PriceFormatter ? Don?t know, from what that problem comming, but i must have that special price function on my shop. Any Ideas ??? Greets Hobbes Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 19, 2005 Share Posted July 19, 2005 Hello Hairy, now i have found in product_info why it dosn?t work. if ($new_price = tep_get_products_special_price($product_info['products_id'])) { $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>'; That was missing. But in classes shopping_cart the shop now don?t add right price for special products :( only the normal price. Have you an idea to fix it ? Greets Hobbes Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 19, 2005 Author Share Posted July 19, 2005 don?t add right price for special products Is this a contribution you are using for special prices? If so let me know the contribution name. Incidentally I am not the original author of this contribution so my knowledge is slightly limited although I beleive Ii may know enough to help you. I can try at least. Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 19, 2005 Share Posted July 19, 2005 Hello Hairy, i know you are not the man who make that great contrib ;) sorry for my questions, but i hope you can help me a bit ;) I am only use CCGV contrib?s, who have changed the classes shopping cart. But in readme it says for install : Find the first instance of the following code and delete: $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$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']; } I think i have delete the full block, my english is not the best ;) And i think i only have to delete, that the block looks like : if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } Right ?? Greets Hobbes Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 19, 2005 Share Posted July 19, 2005 Yes, that was it, now in product_info is showing the right special price with that code : if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } The QPB works fine, with the code changes. But in shopping cart now when i add a special price product it?s showing only the normal price in shopping cart, not the special price :( Can you help me, to fix that ?? Greets Hobbes Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 20, 2005 Author Share Posted July 20, 2005 Sorry I missed your post yesterday, yes as you found that would have been your problem. Sorry what was the contribution you were using for special prices? It sounds like the query for the price on the shopping cart is querying for the 'normal' price. Did you modify the /includes/classes/shopping_cart.php file with the changes outlined in the QPB contribution? Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 20, 2005 Share Posted July 20, 2005 Hello Hairy, no problem that you have not see my post yesterday ;) The only things i have into the shop, are any contribs, but the QPB was the last one i have installed, and i have all done so, we in setup readme?s. All works now, but not the shopping cart right price, when a customer purchase a special price product. For special prices im not using a contrib, that is the shop Specials i use. So i don?t know, why it is not working now :( And after install QPB i don?t have touched the classes/shopping_cart. Only yesterday i have try, to add the right price for special price, what not will work, since i install QPB :( Greets Hobbes P.S. If you like i can post my classes/shopping_cart here ?? Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 20, 2005 Author Share Posted July 20, 2005 Yes post your shopping_cart.php class on here Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 20, 2005 Share Posted July 20, 2005 Many thanks, Hairy that you help me out, with this problem. Here the shopping cart class : <?php /* $Id: shopping_cart.php,v 1.35 2003/07/24 21:14:33 Strider Exp $ $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $ $Id: shopping_cart.php,v 1.3.2.6 2003/05/12 23:11:20 wilt Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 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() { // ############Added CCGV Contribution ########## global $customer_id, $gv_id, $REMOTE_ADDR; // global $customer_id; // ############ End Added CCGV Contribution ########## 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']; $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($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) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } } // ############ Added CCGV Contribution ########## if (tep_session_is_registered('gv_id')) { $gv_query = tep_db_query("insert into " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $gv_id . "', '" . (int)$customer_id . "', now(),'" . $REMOTE_ADDR . "')"); $gv_update = tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $gv_id . "'"); tep_gv_account_update($customer_id, $gv_id); tep_session_unregister('gv_id'); } // ############ End Added CCGV Contribution ########## } // 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 = '" . (int)$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 = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'"); while ($attributes = tep_db_fetch_array($attributes_query)) { $this->contents[$products['products_id']]['attributes'][$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 = '" . (int)$customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'"); } unset($this->cartID); if (tep_session_is_registered('cartID')) tep_session_unregister('cartID'); } function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { global $new_products_id_in_cart, $customer_id; global $languages_id; $pf = new PriceFormatter; $pf->loadProduct($products_id, $languages_id); $qty = $pf->adjustQty($qty); $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, (int)$qty, $attributes); // BUG sur quantit? de produit ajout? (int) } else { $this->contents[] = array($products_id); $this->contents[$products_id] = array('qty' => $qty); // 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) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id]['attributes'][$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 ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$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 customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id]['attributes'][$option] = $value; // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); } } } 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 = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($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 = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($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() { global $languages_id; // ############ Added CCGV Contribution ########## $this->total_virtual = 0; // CCGV Contribution // ############ End Added CCGV Contribution ########## $this->total = 0; $this->weight = 0; if (!is_array($this->contents)) return 0; $pf = new PriceFormatter; reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; // products price if ($product = $pf->loadProduct($products_id, $languages_id)){ // ############ Added CCGV Contribution ########## $no_count = 1; $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', $gv_result['products_model'])) { $no_count = 0; } // ############ End Added CCGV Contribution ########## $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $pf->computePrice($qty); $products_weight = $product['products_weight']; // ############ Added CCGV Contribution ########## $this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count;// ICW CREDIT CLASS; $this->weight_virtual += ($qty * $products_weight) * $no_count;// ICW CREDIT CLASS; // ############ End Added CCGV Contribution ########## $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); } // 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); } } } } } function attributes_price($products_id) { $attributes_price = 0; 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)$products_id . "' 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'] == '+') { $attributes_price += $attribute_price['options_values_price']; } else { $attributes_price -= $attribute_price['options_values_price']; } } } return $attributes_price; } function get_products() { global $languages_id; if (!is_array($this->contents)) return false; $pf = new PriceFormatter; $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { if ($products = $pf->loadProduct($products_id, $languages_id)) { $products_price = $pf->computePrice($this->contents[$products_id]['qty']); $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)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_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; } // ############ Added CCGV Contribution ########## function show_total_virtual() { $this->calculate(); return $this->total_virtual; } function show_weight_virtual() { $this->calculate(); return $this->weight_virtual; } // ############ End Added CCGV Contribution ########## 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 = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$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; } } } // ############ Added CCGV Contribution ########## } elseif ($this->show_weight() == 0) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $virtual_check_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['products_weight'] == 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; } } } // ############ End Added CCGV Contribution ########## } 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']; } } // ############ Added CCGV Contribution ########## // amend count_contents to show nil contents for shipping // as we don't want to quote for 'virtual' item // GLOBAL CONSTANTS if NO_COUNT_ZERO_WEIGHT is true then we don't count any product with a weight // which is less than or equal to MINIMUM_WEIGHT // otherwise we just don't count gift certificates function count_contents_virtual() { // get total number of items in cart disregard gift vouchers $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $no_count = false; $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', $gv_result['products_model'])) { $no_count=true; } if (NO_COUNT_ZERO_WEIGHT == 1) { $gv_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($products_id) . "'"); $gv_result=tep_db_fetch_array($gv_query); if ($gv_result['products_weight']<=MINIMUM_WEIGHT) { $no_count=true; } } if (!$no_count) $total_items += $this->get_quantity($products_id); } } return $total_items; } // ############ End Added CCGV Contribution ########## } ?> Greets Hobbes Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 20, 2005 Author Share Posted July 20, 2005 Hmm - seems to be fine. Would you post your /catalog/shopping_cart.php (not the class file, the other one in the main directory) Im wondering if the call to 'get_price' has been modified by this CCGV contribution. James Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 20, 2005 Share Posted July 20, 2005 (edited) Hello Hairy, ;) that was the orig. from ccgv, so i have use this one. No errors before, but now :( I think it?s for free shipping for a voucher and for welcome gift in shopping cart, for new users ;) here my shopping_cart.php :) : <?php /* ?$Id: shopping_cart.php,v 1.73 2003/06/09 23:03:56 hpdl Exp $ ?osCommerce, Open Source E-Commerce Solutions ?http://www.oscommerce.com ?Copyright (c) 2003 osCommerce ?Released under the GNU General Public License */ ?require("includes/application_top.php"); ?require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART); ?$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOPPING_CART)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> ?<tr> ? ?<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> ? ?</table></td> <!-- body_text //--> ? ?<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> ? ? ?<tr> ? ? ? ?<td><table border="0" width="100%" cellspacing="0" cellpadding="0"> ? ? ? ? ?<tr> ? ? ? ? ? ?<td class="pageHeading"><?php echo HEADING_TITLE; ?></td> ? ? ? ? ? ?<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_cart.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> ? ? ? ? ?</tr> ? ? ? ?</table></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> ? ? ?</tr> <?php ?if ($cart->count_contents() > 0) { ?> ? ? ?<tr> ? ? ? ?<td> <?php ? ?$info_box_contents = array(); ? ?$info_box_contents[0][] = array('align' => 'center', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'params' => 'class="productListing-heading"', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'text' => TABLE_HEADING_REMOVE); ? ?$info_box_contents[0][] = array('params' => 'class="productListing-heading"', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'text' => TABLE_HEADING_PRODUCTS); ? ?$info_box_contents[0][] = array('align' => 'center', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'params' => 'class="productListing-heading"', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'text' => TABLE_HEADING_QUANTITY); ? ?$info_box_contents[0][] = array('align' => 'right', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'params' => 'class="productListing-heading"', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'text' => TABLE_HEADING_TOTAL); ? ?$any_out_of_stock = 0; ? ?$products = $cart->get_products(); ? ?for ($i=0, $n=sizeof($products); $i<$n; $i++) { // Push all attributes information in an array ? ? ?if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) { ? ? ? ?while (list($option, $value) = each($products[$i]['attributes'])) { ? ? ? ? ?echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value); ? ? ? ? ?$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?where pa.products_id = '" . $products[$i]['id'] . "' ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? and pa.options_id = '" . $option . "' ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? and pa.options_id = popt.products_options_id ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? and pa.options_values_id = '" . $value . "' ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? and pa.options_values_id = poval.products_options_values_id ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? and popt.language_id = '" . $languages_id . "' ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? and poval.language_id = '" . $languages_id . "'"); ? ? ? ? ?$attributes_values = tep_db_fetch_array($attributes); ? ? ? ? ?$products[$i][$option]['products_options_name'] = $attributes_values['products_options_name']; ? ? ? ? ?$products[$i][$option]['options_values_id'] = $value; ? ? ? ? ?$products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name']; ? ? ? ? ?$products[$i][$option]['options_values_price'] = $attributes_values['options_values_price']; ? ? ? ? ?$products[$i][$option]['price_prefix'] = $attributes_values['price_prefix']; ? ? ? ?} ? ? ?} ? ?} ? ?for ($i=0, $n=sizeof($products); $i<$n; $i++) { ? ? ?if (($i/2) == floor($i/2)) { ? ? ? ?$info_box_contents[] = array('params' => 'class="productListing-even"'); ? ? ?} else { ? ? ? ?$info_box_contents[] = array('params' => 'class="productListing-odd"'); ? ? ?} ? ? ?$cur_row = sizeof($info_box_contents) - 1; ? ? ?$info_box_contents[$cur_row][] = array('align' => 'center', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-data" valign="top"', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'])); ? ? ?$products_name = '<table border="0" cellspacing="2" cellpadding="2">' . ? ? ? ? ? ? ? ? ? ? ? ' ?<tr>' . ? ? ? ? ? ? ? ? ? ? ? ' ? ?<td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' . ? ? ? ? ? ? ? ? ? ? ? ' ? ?<td class="productListing-data" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>'; ? ? ?if (STOCK_CHECK == 'true') { ? ? ? ?$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']); ? ? ? ?if (tep_not_null($stock_check)) { ? ? ? ? ?$any_out_of_stock = 1; ? ? ? ? ?$products_name .= $stock_check; ? ? ? ?} ? ? ?} ? ? ?if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) { ? ? ? ?reset($products[$i]['attributes']); ? ? ? ?while (list($option, $value) = each($products[$i]['attributes'])) { ? ? ? ? ?$products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>'; ? ? ? ?} ? ? ?} ? ? ?$products_name .= ' ? ?</td>' . ? ? ? ? ? ? ? ? ? ? ? ?' ?</tr>' . ? ? ? ? ? ? ? ? ? ? ? ?'</table>'; ? ? ?$info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => $products_name); ? ? ?$info_box_contents[$cur_row][] = array('align' => 'center', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-data" valign="top"', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id'])); ? ? ?$info_box_contents[$cur_row][] = array('align' => 'right', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-data" valign="top"', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>'); ? ?} ? ?new productListingBox($info_box_contents); ?> ? ? ? ?</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></b></td> ? ? ?</tr> <?php ? ?if ($any_out_of_stock == 1) { ? ? ?if (STOCK_ALLOW_CHECKOUT == 'true') { ?> ? ? ?<tr> ? ? ? ?<td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></td> ? ? ?</tr> <?php ? ? ?} else { ?> ? ? ?<tr> ? ? ? ?<td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></td> ? ? ?</tr> <?php ? ? ?} ? ?} ?> ? ? ?<tr> ? ? ? ?<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> ? ? ? ? ?<tr class="infoBoxContents"> ? ? ? ? ? ?<td><table border="0" width="100%" cellspacing="0" cellpadding="2"> ? ? ? ? ? ? ?<tr> ? ? ? ? ? ? ? ?<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> ? ? ? ? ? ? ? ?<td class="main"><?php echo tep_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART); ?></td> <?php ? ?$back = sizeof($navigation->path)-2; ? ?if (isset($navigation->path[$back])) { ?> ? ? ? ? ? ? ? ?<td class="main"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '">' . tep_image_button('button_continue_shopping.gif', IMAGE_BUTTON_CONTINUE_SHOPPING) . '</a>'; ?></td> <?php ? ?} ?> ? ? ? ? ? ? ? ?<td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>'; ?></td> ? ? ? ? ? ? ? ?<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> ? ? ? ? ? ? ?</tr> ? ? ? ? ? ?</table></td> ? ? ? ? ?</tr> ? ? ? ?</table></td> ? ? ?</tr> <?php ?} else { ?> ? ? ?<tr> ? ? ? ?<td align="center" class="main"><?php new infoBox(array(array('text' => TEXT_CART_EMPTY))); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> ? ? ? ? ?<tr class="infoBoxContents"> ? ? ? ? ? ?<td><table border="0" width="100%" cellspacing="0" cellpadding="2"> ? ? ? ? ? ? ?<tr> ? ? ? ? ? ? ? ?<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> ? ? ? ? ? ? ? ?<td align="right" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> ? ? ? ? ? ? ? ?<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> ? ? ? ? ? ? ?</tr> ? ? ? ? ? ?</table></td> ? ? ? ? ?</tr> ? ? ? ?</table></td> ? ? ?</tr> <?php ?} ?> ? ?</table></form></td> <!-- body_text_eof //--> ? ?<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> ? ?</table></td> ?</tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Greets Hobbes Edited July 20, 2005 by Hobbes_TheReal Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 20, 2005 Share Posted July 20, 2005 (edited) If you have msn messanger than we can talk there, if you like ?? Cheers Hobbes Edited July 20, 2005 by Hobbes_TheReal Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 20, 2005 Author Share Posted July 20, 2005 Would you also post your currencies.php class file found in /includes/classes/ Sorry I do not have msn messenger at work. :( Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 20, 2005 Share Posted July 20, 2005 Ok :) if you like to add me at your home pc, let me know ;) Here the class currencies ;) : <?php /* $Id: currencies.php,v 1.16 2003/06/05 23:16:46 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ //// // Class to handle currencies // TABLES: currencies class currencies { var $currencies; // class constructor function currencies() { $this->currencies = array(); $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES); while ($currencies = tep_db_fetch_array($currencies_query)) { $this->currencies[$currencies['code']] = array('title' => $currencies['title'], 'symbol_left' => $currencies['symbol_left'], 'symbol_right' => $currencies['symbol_right'], 'decimal_point' => $currencies['decimal_point'], 'thousands_point' => $currencies['thousands_point'], 'decimal_places' => $currencies['decimal_places'], 'value' => $currencies['value']); } } // class methods function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { global $currency; if (empty($currency_type)) $currency_type = $currency; if ($calculate_currency_value == true) { $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value']; $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; // if the selected currency is in the european euro-conversion and the default currency is euro, // the currency will displayed in the national currency and euro currency if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) { $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>'; } } else { $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; } // BOF: WebMakers.com Added: Down for Maintenance if (DOWN_FOR_MAINTENANCE=='true' and DOWN_FOR_MAINTENANCE_PRICES_OFF=='true') { $format_string= ''; } // BOF: WebMakers.com Added: Down for Maintenance return $format_string; } function is_set($code) { if (isset($this->currencies[$code]) && tep_not_null($this->currencies[$code])) { return true; } else { return false; } } function get_value($code) { return $this->currencies[$code]['value']; } function get_decimal_places($code) { return $this->currencies[$code]['decimal_places']; } function display_price($products_price, $products_tax, $quantity = 1) { if (TAX_INFO_ONOFF == 'Enabled') { $return = $this->format(tep_add_tax($products_price, $products_tax) * $quantity); global $tag; $return .= "<br><div class=\"tax_info\">" . sprintf(TEXT_INFO_TAX, $products_tax , tep_href_link(FILENAME_SHIPPING)) . "</div>"; return $return; } else { return $this->format(tep_add_tax($products_price, $products_tax) * $quantity); } } } ?> Greets Hobbes Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 20, 2005 Author Share Posted July 20, 2005 Ok I need to confirm a few things. When you say the price is incorrect are you saying that it is not displaying the quantity price break 'discount' price? Look at how one of my QPB items is setup. The first QPB is for 1 item purchase, it costs 925.00 each. If quantity of 2 were to be purchased then each item costs 740.00 (totalling 1480.00 in cart) and so on for 3 & 4 item quantities. Are your items setup like this? Price break level 1: 925.00 Qty: 1 Price break level 2: 740.00 Qty: 2 Price break level 3: 680.00 Qty: 3 Price break level 4: 650.00 Qty: 4 Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 20, 2005 Share Posted July 20, 2005 No no, the QPB works, but when i have a product in special than the shopping cart don?t add now the special price. He only add the normal price now :( Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 20, 2005 Author Share Posted July 20, 2005 No no, the QPB works, but when i have a product in specialthan the shopping cart don?t add now the special price. He only add the normal price now :( <{POST_SNAPBACK}> Is the special price less than the QPB price? If it is then the QPB price will overide what you have set in special. Quote Link to comment Share on other sites More sharing options...
HairyJim Posted July 20, 2005 Author Share Posted July 20, 2005 OK. I think I have tracked the problem down. In the PriceFormatter file there are there are three lines that need to be uncommented: lines 196, 197 & 198 They look like this in the file: //if ($this->hasSpecialPrice == true) // $price = $this->specialPrice; //else Remove the slashes and then retry. Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 20, 2005 Share Posted July 20, 2005 kk, i will do :) im back in any minutes :) Quote Link to comment Share on other sites More sharing options...
Hobbes_TheReal Posted July 20, 2005 Share Posted July 20, 2005 Yeaaaaaaaaaaaaah :) that was the problem. Many, many thx, Hairy :) Greets Hobbes 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.
Note: Your post will require moderator approval before it will be visible.