volumax Posted June 13, 2004 Share Posted June 13, 2004 Hi Guys Sorry to banging on about this but my provious posts only had one reply saying 'be more specific' which i then did and still no one replied! OK Here goes request totaly reworded in an endevour to clarify even more. in /catalog/includes/classes/shopping_cart.php the code works out all the prices for the products you add to the cart before going to the checkout. in there is a call (function) that can allow you to display the total monitary value of the items in the cart as follows:- function show_total() { $this->calculate(); return $this->total; } Which in turn calls function calculate that does all the working out. What I need is the following calls:- function show_nett() { $this->calculate(); return $this->nett; } function show_tax() { $this->calculate(); return $this->tax; } function show_shipping() { $this->calculate(); return $this->shipping; } and taking into account variable shipping rates and variable tax rates. but as you can see from the calculate function 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']; // 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']; $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']; } $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); } } } } } They are not there, and not being a programmer I havn't a clue where to start now you would expect the 'nett' value to be Total minus Tax and that Tax would be Total minus Nett so looking at the function i tried adding this:- $this->nett += tep_add_tax($products_price, $products_tax) * $qty - ($products_tax * $qty); $this->tax = $this->total - (tep_add_tax($products_price, $products_tax) * $qty); but as you php and coding guy's out there will realise is that it does not work properly. So if anyone can show me how it can be done and get the correct values it would be appreciated. BTW if you are wondering why My boss has insisted upon having the customer see the cart totals at all times and not just at checkout time, it is also what our customers have requested. Take pitty on a cut and paster, Hellpp :) Regards Andy Literally, Laterally Thinking! If you cannot get through it, go round it. Link to comment Share on other sites More sharing options...
volumax Posted June 15, 2004 Author Share Posted June 15, 2004 Hi All, Seeing that no one is able to help a beginner work out how to display net total and tax total for our customers, it seems a shame, after asking for nearly 4 weeks and giving more and more detail for what my boss would like for what i would have thought was a relatively simple request. His last comment was 'I thought that the whole idea of a cart that allowed for the community to enhance, what you said was an excellent cart, was that you ask for help and not get more that a single response, it seems pointless'. One last call for help on this before, it gets scrapped. Dejectidly Andy I'll Apologise now for any flack, but at this point I dont really care :( Literally, Laterally Thinking! If you cannot get through it, go round it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.