Guest Posted December 2, 2006 Share Posted December 2, 2006 I just installed Discount Coupon Codes and this is the error I get when trying to goto the module: Parse error: parse error, unexpected ')' in /home/sales/public_html/shop/admin/includes/boxes/catalog.php on line 32 Post your code for your admin/includes/boxes/catalog.php and I will see if I can help you. Quote Link to comment Share on other sites More sharing options...
robodude Posted December 3, 2006 Share Posted December 3, 2006 if ($selected_box == 'catalog') { $contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS . '</a><br>' . //kgt - discount coupons '<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a><br>'. '<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a>' ); //end kgt - discount coupons '<a href="' . tep_href_link(FILENAME_MANUFACTURERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_MANUFACTURERS . '</a><br>' . Quote Link to comment Share on other sites More sharing options...
Guest Posted December 3, 2006 Share Posted December 3, 2006 find this code: '<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a>' ); replace with: '<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a><br>'. That should do the trick. By the way, I still need help with my question a couple of posts above this one. Anyone? /Per Quote Link to comment Share on other sites More sharing options...
Guest Posted December 3, 2006 Share Posted December 3, 2006 (edited) @robodude Or if you don´t have any more links underneath your last line. Do like this: Find: if ($selected_box == 'catalog') { $contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS . '</a><br>' . //kgt - discount coupons '<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a><br>'. '<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a>' ); //end kgt - discount coupons '<a href="' . tep_href_link(FILENAME_MANUFACTURERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_MANUFACTURERS . '</a><br>' . Replace with: if ($selected_box == 'catalog') { $contents[] = array('text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS . '</a><br>' . //kgt - discount coupons '<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a><br>'. '<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a><br>'. //end kgt - discount coupons '<a href="' . tep_href_link(FILENAME_MANUFACTURERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_MANUFACTURERS . '</a>' ); Edited December 3, 2006 by figurez Quote Link to comment Share on other sites More sharing options...
robodude Posted December 3, 2006 Share Posted December 3, 2006 Ok, that got rid of the error, but the coupon code isn't showing up in my module? Quote Link to comment Share on other sites More sharing options...
robodude Posted December 3, 2006 Share Posted December 3, 2006 Ok, actually I got it to show up in the module...forgot to upload a file. But now I'm getting this error: Warning: main(/home/sales/public_html/shop/includes/languages/english/modules/order_total/ot_discount_coupon.php): failed to open stream: No such file or directory in /home/sales/public_html/shop/admin/modules.php on line 128 Warning: main(/home/sales/public_html/shop/includes/languages/english/modules/order_total/ot_discount_coupon.php): failed to open stream: No such file or directory in /home/sales/public_html/shop/admin/modules.php on line 128 Warning: main(): Failed opening '/home/sales/public_html/shop/includes/languages/english/modules/order_total/ot_discount_coupon.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/sales/public_html/shop/admin/modules.php on line 128 Quote Link to comment Share on other sites More sharing options...
nudylady Posted December 4, 2006 Share Posted December 4, 2006 hello I also installed Quantity Discounts http://www.oscommerce.com/community/contributions,1159 Is there anyway to stop customers use Coupon Codes and quantity discount together? Quantity Discounts has a option of Disable If Coupon Used. I set it to ture. but not work. now my customers can use both together. Quote Link to comment Share on other sites More sharing options...
kgt Posted December 4, 2006 Author Share Posted December 4, 2006 And the part from the VAT contribution I´m trying to implement looks like this. It´s supposed to go at the end of the order.php The code from the VAT contribution is marked with "// BOF for TVA_intracom_v3.4" I would really appreciate any help with this to bring me closer to a solution. Could this even be done? I would really like to use both contributions. Thanks in advance Per includes/classes/order.php: $subindex++; } } // BOF for TVA_intracom_v3.4 //For those who want taxes automatically if the conditions below are OK, uncomment the lines below if ($this->billing['company'] != '' && $this->billing['tva_intracom'] != '' && $this->billing['country']['id'] != STORE_COUNTRY && $this->delivery['country']['id'] != STORE_COUNTRY) { //kgt - discount coupon if( !empty( $this->info['coupon'] ) ) { if( !isset( $this_coupon ) ) { require_once( DIR_WS_CLASSES . 'discount_coupon.php' ); $this_coupon = new discount_coupon( $this->info['coupon'] ); } $applied_discount = $this_coupon->calculate_discount( $this->products[$index], $n ); if( isset( $this->info['applied_discount'][$this->products[$index]['tax_description']] ) ) { $this->info['applied_discount'][$this->products[$index]['tax_description']] += $applied_discount; } else { $this->info['applied_discount'][$this->products[$index]['tax_description']] = $applied_discount; } $this_actual_shown_price = null; if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) { //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax $this_actual_shown_price = ( $this->products[$index]['final_price'] ) * $this->products[$index]['qty'] ) - $applied_discount; $applied_discount = 0; } } $shown_price = ( $this->products[$index]['final_price'] * $this->products[$index]['qty'] ) - $applied_discount; $this->info['subtotal'] += $shown_price; //if we need to display the subtotal without the discount applied, then add the shown price to the subtotal, then change shown price to the price with the applied discount in order to properly calculate taxes if( isset( $this_actual_shown_price ) ) $shown_price = $this_actual_shown_price; //end kgt - discount coupon } else { // EOF for TVA_intracom_v3.4 //kgt - discount coupon if( !empty( $this->info['coupon'] ) ) { if( !isset( $this_coupon ) ) { require_once( DIR_WS_CLASSES . 'discount_coupon.php' ); $this_coupon = new discount_coupon( $this->info['coupon'] ); } $applied_discount = $this_coupon->calculate_discount( $this->products[$index], $n, true ); if( isset( $this->info['applied_discount'][$this->products[$index]['tax_description']] ) ) { $this->info['applied_discount'][$this->products[$index]['tax_description']] += $applied_discount; } else { $this->info['applied_discount'][$this->products[$index]['tax_description']] = $applied_discount; } $this_actual_shown_price = null; if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) { //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax $this_actual_shown_price = ( tep_add_tax( $this->products[$index]['final_price'], $this->products[$index]['tax'] ) * $this->products[$index]['qty'] ) - $applied_discount; $applied_discount = 0; } } $shown_price = ( tep_add_tax( $this->products[$index]['final_price'], $this->products[$index]['tax'] ) * $this->products[$index]['qty'] ) - $applied_discount; $this->info['subtotal'] += $shown_price; //if we need to display the subtotal without the discount applied, then add the shown price to the subtotal, then change shown price to the price with the applied discount in order to properly calculate taxes if( isset( $this_actual_shown_price ) ) $shown_price = $this_actual_shown_price; //end kgt - discount coupon // BOF for TVA_intracom_v3.4 //For those who want taxes automatically if the conditions below are OK, uncomment the line below } // EOF for TVA_intracom_v3.4 // BOF for TVA_intracom_v3.4 //For those who want taxes automatically if the conditions below are OK, uncomment the lines below if ($this->billing['company'] != '' && $this->billing['tva_intracom'] != '' && $this->billing['country']['id'] != STORE_COUNTRY && $this->delivery['country']['id'] != STORE_COUNTRY) { $products_tax = 0; $products_tax_description = NO_TAX; } else { // EOF for TVA_intracom_v3.4 $products_tax = $this->products[$index]['tax']; $products_tax_description = $this->products[$index]['tax_description']; // BOF for TVA_intracom_v3.4 //For those who want taxes automatically if the conditions below are OK, uncomment the line below } // EOF for TVA_intracom_v3.4 if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } else { $this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } } else { $this->info['tax'] += ($products_tax / 100) * $shown_price; if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price; } else { $this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price; } } $index++; } if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; } else { $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; } } } ?> includes/classes/discount_coupon.php: function calculate_discount( $product, $product_count, $use_tax = false ) { if( $use_tax ) { //if there's a maximum order amount to apply the discount to, determine the percentage of this product's final price we should apply the discount to $max_applied_percentage = ( $this->coupon['coupons_max_order'] == 0 ? '1.00' : $this->coupon['coupons_max_order'] / ( tep_add_tax( $product['final_price'] * $product['qty'], $product['tax'] ) * $product_count ) ); $applied_discount = tep_add_tax( $product['final_price'] * $max_applied_percentage * $this->coupon['coupons_discount_percent'], $product['tax'] ) * $product['qty']; //don't allow the discount amount to be more than the product price if( $applied_discount > ( tep_add_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) ) $applied_discount = tep_add_tax( $product['final_price'], $product['tax'] ) * $product['qty']; } else { //if there's a maximum order amount to apply the discount to, determine the percentage of this product's final price we should apply the discount to $max_applied_percentage = ( $this->coupon['coupons_max_order'] == 0 ? '1.00' : $this->coupon['coupons_max_order'] / ( $product['final_price'] * $product['qty'] * $product_count ) ); $applied_discount = $product['final_price'] * $max_applied_percentage * $this->coupon['coupons_discount_percent'] * $product['qty']; //don't allow the discount amount to be more than the product price if( $applied_discount > ( $product['final_price'] * $product['qty'] ) ) $applied_discount = $product['final_price'] * $product['qty']; } return $applied_discount; } Since you're not applying tax in certain circumstances, the discount coupon class needs to be altered too. The only function you should need to worry about is the last one in that file, which I have modified above. I haven't tested any of this, so be prepared for errors. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted December 4, 2006 Author Share Posted December 4, 2006 helloI also installed Quantity Discounts http://www.oscommerce.com/community/contributions,1159 Is there anyway to stop customers use Coupon Codes and quantity discount together? Quantity Discounts has a option of Disable If Coupon Used. I set it to ture. but not work. now my customers can use both together. I'm sure they could be used together, but they are not intended/written to. The best way to approach this is to find out where and how Quantity Discounts determines whether or not a coupon has been used, then alter that code to make it work with this contribution. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted December 4, 2006 Author Share Posted December 4, 2006 Ok, actually I got it to show up in the module...forgot to upload a file. But now I'm getting this error: Warning: main(/home/sales/public_html/shop/includes/languages/english/modules/order_total/ot_discount_coupon.php): failed to open stream: No such file or directory in /home/sales/public_html/shop/admin/modules.php on line 128 Warning: main(/home/sales/public_html/shop/includes/languages/english/modules/order_total/ot_discount_coupon.php): failed to open stream: No such file or directory in /home/sales/public_html/shop/admin/modules.php on line 128 Warning: main(): Failed opening '/home/sales/public_html/shop/includes/languages/english/modules/order_total/ot_discount_coupon.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/sales/public_html/shop/admin/modules.php on line 128 You need to upload the language file in includes/languages/english/modules/order_total/ot_discount_coupon.php. This error message is saying it cannot find that file. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
Bassie Posted December 4, 2006 Share Posted December 4, 2006 Hi, I've just installed this contrib and I have to say it's a great one ! Thanks! :thumbsup: I'm using the discount percentage option rather then the fixed amount and I would like to round the discount amount to 5 cents. example: product 1: 24.50 product 2: 52.00 discount coupon (5%): -3.87 ???? (should this not be 3.83 ?) subtotal: 72.63 shipping: 6.20 Total: 78.83 My question where should I add (and what code) the rounding so that 3.87 becomes 3.85 ? It should round up to either ##.#0 or to ##.#5 preferable. It would be nice if someone could explain why the rounding is a little bit off as well even using percentage discount (I have read about the fix amount discount rounding issue), but I'm more interested in the rounding area. If I'll round to five cents, this small difference is not a real problem after all. thanks. Quote Link to comment Share on other sites More sharing options...
Guest Posted December 4, 2006 Share Posted December 4, 2006 Hi KGT and thank you for your help. I have done the modifications you suggested. When I´m trying to checkout I´m getting the following error: Parse error: syntax error, unexpected ')' in /home/xxxxx/public_html/includes/classes/order.php on line 273 The code for line 273 is: $this_actual_shown_price = ( $this->products[$index]['final_price'] ) * $this->products[$index]['qty'] ) - $applied_discount; Can I just add and "(" before the "$this" ? Sorry my php knowledge is very limited :blush: Quote Link to comment Share on other sites More sharing options...
Guest Posted December 4, 2006 Share Posted December 4, 2006 Well, I added the "(" and got rid of that error. Then I got another error when I try to continue from the payment method page. The following error: Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/xxxxx/public_html/includes/classes/discount_coupon.php on line 127 Line 127 has the following code: ?> Quote Link to comment Share on other sites More sharing options...
kgt Posted December 4, 2006 Author Share Posted December 4, 2006 Hi KGT and thank you for your help. I have done the modifications you suggested. When I´m trying to checkout I´m getting the following error: Parse error: syntax error, unexpected ')' in /home/xxxxx/public_html/includes/classes/order.php on line 273 The code for line 273 is: $this_actual_shown_price = ( $this->products[$index]['final_price'] ) * $this->products[$index]['qty'] ) - $applied_discount; Can I just add and "(" before the "$this" ? Sorry my php knowledge is very limited :blush: It should look like: $this_actual_shown_price = ( $this->products[$index]['final_price'] * $this->products[$index]['qty'] ) - $applied_discount; Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted December 4, 2006 Author Share Posted December 4, 2006 Well, I added the "(" and got rid of that error. Then I got another error when I try to continue from the payment method page. The following error: Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/xxxxx/public_html/includes/classes/discount_coupon.php on line 127 Line 127 has the following code: ?> When you get errors that occur on the last line, for example, that's a pretty good indication that the real error is occurring before that. Post the lines preceding this one. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
Guest Posted December 4, 2006 Share Posted December 4, 2006 This is my whole discount_coupon.php from catalog/includes/classes <?php /* * ot_discount_coupon.php * August 4, 2006 * author: Kristen G. Thorson * * ot_discount_coupon_codes version 2.0 * * Released under the GNU General Public License * */ class discount_coupon { var $code, $error_message, $coupon; function discount_coupon( $code ) { $this->code = $code; $this->error_message = array(); $this->coupon = array(); $this->get_coupon(); } function verify_code() { //check the global number of discounts that may be used if( $this->coupon['coupons_number_available'] != 0 ) { $this->check_num_available(); } //if coupons_max_use==0, then use is unlimited, otherwise, we need to verify the customer hasn't used this coupon more than coupons_max_use times if( $this->coupon['coupons_max_use'] != 0 ) { $this->check_coupons_max_use(); } //now we need to check if the order total matches the coupons_min_order if( $this->coupon['coupons_min_order'] != 0 ) { $this->check_coupons_min_order(); } } function get_coupon() { $check_code_query = tep_db_query( $sql = "SELECT coupons_discount_percent, coupons_description, coupons_max_use, coupons_min_order, coupons_max_order, coupons_number_available FROM " . TABLE_DISCOUNT_COUPONS . " WHERE coupons_id = '" . tep_db_input( $this->code ) . "' AND ( coupons_date_start <= CURDATE() OR coupons_date_start IS NULL ) AND ( coupons_date_end >= CURDATE() OR coupons_date_end IS NULL )" ); if( tep_db_num_rows( $check_code_query ) != 1 ) { //if no rows are returned, then they haven't entered a valid code $this->error_message[] = ENTRY_DISCOUNT_COUPON_ERROR; //display the error message } else { $row = tep_db_fetch_array( $check_code_query ); //since there is one record, we have a valid code $this->coupon = $row; } } function check_coupons_min_order() { global $order, $currencies; //if we display the subtotal without the discount applied, then just compare the subtotal to the minimum order if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' && $this->coupon['coupons_min_order'] > $order->info['subtotal'] ) { $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $this->coupon['coupons_min_order'], true, $order->info['currency'], $order->info['currency_value'] ) ); //if we display the subtotal with the discount applied, then we need to compare the subtotal with the discount added back in to the minimum order } else if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'true' ) { $subtotal = $order->info['subtotal']; foreach( $order->info['applied_discount'] as $discount ) { $subtotal += $discount; } if( $this->coupon['coupons_min_order'] > $subtotal ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_MIN_ERROR, $currencies->format( $this->coupon['coupons_min_order'], true, $order->info['currency'], $order->info['currency_value'] ) ); } } function check_coupons_max_use() { global $customer_id; $check_use_query = tep_db_query($sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_ORDERS." AS o INNER JOIN ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o ON dc2o.orders_id=o.orders_id AND o.customers_id = '".(int)$customer_id."' AND dc2o.coupons_id='".tep_db_input( $this->code )."'"); $use = tep_db_fetch_array( $check_use_query ); //show error message if coupons_max_use is equal to the number of times this customer has used the code if( $this->coupon['coupons_max_use'] <= $use['cnt'] ) $this->error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_USE_ERROR, $use['cnt'], $this->coupon['coupons_max_use'] ); //display the error message for number of times used } function check_num_available() { //count the number of times this coupon has been used $check_use_query = tep_db_query( $sql = 'SELECT COUNT(*) AS cnt FROM '.TABLE_DISCOUNT_COUPONS_TO_ORDERS.' WHERE coupons_id="'.tep_db_input( $this->code ).'"' ); $use = tep_db_fetch_array( $check_use_query ); if( $this->coupon['coupons_number_available'] <= $use['cnt'] ) $this->error_message[] = ENTRY_DISCOUNT_COUPON_AVAILABLE_ERROR; //display error that this coupon is no longer valid } function is_recalc_shipping() { global $order, $language; //check if there is free shipping if( MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true' ) { include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php'); //if free shipping is enabled, make sure te discount does not bring the order total below free shipping limit if( $order->info['shipping_method'] == FREE_SHIPPING_TITLE ) { //if free shipping is the selected shipping method if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER ) { //if the discount lowers the total below the free shipping limit return true; } } } return false; } function is_errors() { if( count( $this->error_message ) > 0 ) return true; return false; } function calculate_discount( $product, $product_count, $use_tax = false ) { if( $use_tax ) { //if there's a maximum order amount to apply the discount to, determine the percentage of this product's final price we should apply the discount to $max_applied_percentage = ( $this->coupon['coupons_max_order'] == 0 ? '1.00' : $this->coupon['coupons_max_order'] / ( tep_add_tax( $product['final_price'] * $product['qty'], $product['tax'] ) * $product_count ) ); $applied_discount = tep_add_tax( $product['final_price'] * $max_applied_percentage * $this->coupon['coupons_discount_percent'], $product['tax'] ) * $product['qty']; //don't allow the discount amount to be more than the product price if( $applied_discount > ( tep_add_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) ) $applied_discount = tep_add_tax( $product['final_price'], $product['tax'] ) * $product['qty']; } else { //if there's a maximum order amount to apply the discount to, determine the percentage of this product's final price we should apply the discount to $max_applied_percentage = ( $this->coupon['coupons_max_order'] == 0 ? '1.00' : $this->coupon['coupons_max_order'] / ( $product['final_price'] * $product['qty'] * $product_count ) ); $applied_discount = $product['final_price'] * $max_applied_percentage * $this->coupon['coupons_discount_percent'] * $product['qty']; //don't allow the discount amount to be more than the product price if( $applied_discount > ( $product['final_price'] * $product['qty'] ) ) $applied_discount = $product['final_price'] * $product['qty']; } return $applied_discount; } ?> Quote Link to comment Share on other sites More sharing options...
kgt Posted December 4, 2006 Author Share Posted December 4, 2006 This is my whole discount_coupon.php from catalog/includes/classes You overwrote the closing brace for the class: $applied_discount = $product['final_price'] * $max_applied_percentage * $this->coupon['coupons_discount_percent'] * $product['qty']; //don't allow the discount amount to be more than the product price if( $applied_discount > ( $product['final_price'] * $product['qty'] ) ) $applied_discount = $product['final_price'] * $product['qty']; } return $applied_discount; } } ?> The end of that file should look like the above, with two closing braces after the return statement. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
Guest Posted December 4, 2006 Share Posted December 4, 2006 wow it at first glance it looks like it´s working. I will do some testing. I will get back to you soon. I can´t tell you how happy I am if I can get this to work. Talk to you later I have to make supper for my kid :D :D Quote Link to comment Share on other sites More sharing options...
Guest Posted December 4, 2006 Share Posted December 4, 2006 (edited) ok, I tested the changes and it looks like it doesn´t remove the discount from the total. It count´s the tax correct but the total ammount to pay is without the discount. Any ideas? I really appreciate your time and help. Should I modify the order_total.php somehow? This is my order_total.php if you can see anything: <?php /* $Id: ot_total.php,v 1.7 2003/02/13 00:12:04 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class ot_total { var $title, $output; function ot_total() { $this->code = 'ot_total'; $this->title = MODULE_ORDER_TOTAL_TOTAL_TITLE; $this->description = MODULE_ORDER_TOTAL_TOTAL_DESCRIPTION; $this->enabled = ((MODULE_ORDER_TOTAL_TOTAL_STATUS == 'true') ? true : false); $this->sort_order = MODULE_ORDER_TOTAL_TOTAL_SORT_ORDER; $this->output = array(); } function process() { global $order, $currencies; $this->output[] = array('title' => $this->title . ':', 'text' => '<b>' . $currencies->format($order->info['total'], true, $order->info['currency'], $order->info['currency_value']) . '</b>', 'value' => $order->info['total']); } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_TOTAL_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function keys() { return array('MODULE_ORDER_TOTAL_TOTAL_STATUS', 'MODULE_ORDER_TOTAL_TOTAL_SORT_ORDER'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Total', 'MODULE_ORDER_TOTAL_TOTAL_STATUS', 'true', 'Do you want to display the total order value?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_TOTAL_SORT_ORDER', '4', 'Sort order of display.', '6', '2', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } } ?> Edited December 4, 2006 by figurez Quote Link to comment Share on other sites More sharing options...
kgt Posted December 5, 2006 Author Share Posted December 5, 2006 ok, I tested the changes and it looks like it doesn´t remove the discount from the total.It count´s the tax correct but the total ammount to pay is without the discount. Any ideas? I really appreciate your time and help. Should I modify the order_total.php somehow? This is my order_total.php if you can see anything: order_total.php has nothing to do with this. The error is occurring in order.php. Show me the code you now have for that file. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
Guest Posted December 5, 2006 Share Posted December 5, 2006 ok, this is my includes/classes/order.php <?php /* $Id: order.php,v 1.33 2003/06/09 22:25:35 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class order { var $info, $totals, $products, $customer, $delivery, $content_type; function order($order_id = '') { $this->info = array(); $this->totals = array(); $this->products = array(); $this->customer = array(); $this->delivery = array(); if (tep_not_null($order_id)) { $this->query($order_id); } else { $this->cart(); } } function query($order_id) { global $languages_id; $order_id = tep_db_prepare_input($order_id); $order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_tva_intracom, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); $order = tep_db_fetch_array($order_query); $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); while ($totals = tep_db_fetch_array($totals_query)) { $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text']); } $order_total_query = tep_db_query("select text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_total'"); $order_total = tep_db_fetch_array($order_total_query); $shipping_method_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'"); $shipping_method = tep_db_fetch_array($shipping_method_query); $order_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . (int)$languages_id . "'"); $order_status = tep_db_fetch_array($order_status_query); $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order_status['orders_status_name'], 'last_modified' => $order['last_modified'], 'total' => strip_tags($order_total['text']), 'shipping_method' => ((substr($shipping_method['title'], -1) == ':') ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title']))); $this->customer = array('id' => $order['customers_id'], 'name' => $order['customers_name'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']); $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']); if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) { $this->delivery = false; } $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], //BOF for VAT INTRACOM 'tva_intracom' => $order['billing_tva_intracom'], // EOF for TVA_INTRACOM 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']); $index = 0; $orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); while ($orders_products = tep_db_fetch_array($orders_products_query)) { $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'id' => $orders_products['products_id'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price']); $subindex = 0; $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); if (tep_db_num_rows($attributes_query)) { while ($attributes = tep_db_fetch_array($attributes_query)) { $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']); $subindex++; } } $this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1'; $index++; } } function cart() { global $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment; $this->content_type = $cart->get_content_type(); $customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_tva_intracom, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id"); $customer_address = tep_db_fetch_array($customer_address_query); $shipping_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$sendto . "'"); $shipping_address = tep_db_fetch_array($shipping_address_query); $billing_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_tva_intracom, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$billto . "'"); $billing_address = tep_db_fetch_array($billing_address_query); $tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $billto : $sendto) . "'"); $tax_address = tep_db_fetch_array($tax_address_query); $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $currency, 'currency_value' => $currencies->currencies[$currency]['value'], 'payment_method' => $payment, 'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''), 'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''), 'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''), 'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''), 'shipping_method' => $shipping['title'], 'shipping_cost' => $shipping['cost'], 'subtotal' => 0, 'tax' => 0, 'tax_groups' => array(), //kgt - discount coupons 'coupon' => (isset($GLOBALS['coupon']) ? $GLOBALS['coupon'] : ''), 'applied_discount' => array(), //end kgt - discount coupons 'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : '')); if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) { $this->info['payment_method'] = $GLOBALS[$payment]->title; if ( isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && ($GLOBALS[$payment]->order_status > 0) ) { $this->info['order_status'] = $GLOBALS[$payment]->order_status; } } $this->customer = array('firstname' => $customer_address['customers_firstname'], 'lastname' => $customer_address['customers_lastname'], 'company' => $customer_address['entry_company'], 'street_address' => $customer_address['entry_street_address'], 'suburb' => $customer_address['entry_suburb'], 'city' => $customer_address['entry_city'], 'postcode' => $customer_address['entry_postcode'], 'state' => ((tep_not_null($customer_address['entry_state'])) ? $customer_address['entry_state'] : $customer_address['zone_name']), 'zone_id' => $customer_address['entry_zone_id'], 'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']), 'format_id' => $customer_address['address_format_id'], 'telephone' => $customer_address['customers_telephone'], 'email_address' => $customer_address['customers_email_address']); $this->delivery = array('firstname' => $shipping_address['entry_firstname'], 'lastname' => $shipping_address['entry_lastname'], 'company' => $shipping_address['entry_company'], 'street_address' => $shipping_address['entry_street_address'], 'suburb' => $shipping_address['entry_suburb'], 'city' => $shipping_address['entry_city'], 'postcode' => $shipping_address['entry_postcode'], 'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']), 'zone_id' => $shipping_address['entry_zone_id'], 'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']), 'country_id' => $shipping_address['entry_country_id'], 'format_id' => $shipping_address['address_format_id']); $this->billing = array('firstname' => $billing_address['entry_firstname'], 'lastname' => $billing_address['entry_lastname'], 'company' => $billing_address['entry_company'], //BOF for VAT INTRACOM 'tva_intracom' => $billing_address['entry_tva_intracom'], // EOF for TVA_INTRACOM 'street_address' => $billing_address['entry_street_address'], 'suburb' => $billing_address['entry_suburb'], 'city' => $billing_address['entry_city'], 'postcode' => $billing_address['entry_postcode'], 'state' => ((tep_not_null($billing_address['entry_state'])) ? $billing_address['entry_state'] : $billing_address['zone_name']), 'zone_id' => $billing_address['entry_zone_id'], 'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']), 'country_id' => $billing_address['entry_country_id'], 'format_id' => $billing_address['address_format_id']); $index = 0; $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']); if ($products[$i]['attributes']) { $subindex = 0; reset($products[$i]['attributes']); while (list($option, $value) = each($products[$i]['attributes'])) { $attributes_query = 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 = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'"); $attributes = tep_db_fetch_array($attributes_query); $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'], 'value' => $attributes['products_options_values_name'], 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']); $subindex++; } } // BOF for TVA_intracom_v3.4 //For those who want taxes automatically if the conditions below are OK, uncomment the lines below if ($this->billing['company'] != '' && $this->billing['tva_intracom'] != '' && $this->billing['country']['id'] != STORE_COUNTRY && $this->delivery['country']['id'] != STORE_COUNTRY) { //kgt - discount coupon if( !empty( $this->info['coupon'] ) ) { if( !isset( $this_coupon ) ) { require_once( DIR_WS_CLASSES . 'discount_coupon.php' ); $this_coupon = new discount_coupon( $this->info['coupon'] ); } $applied_discount = $this_coupon->calculate_discount( $this->products[$index], $n ); if( isset( $this->info['applied_discount'][$this->products[$index]['tax_description']] ) ) { $this->info['applied_discount'][$this->products[$index]['tax_description']] += $applied_discount; } else { $this->info['applied_discount'][$this->products[$index]['tax_description']] = $applied_discount; } $this_actual_shown_price = null; if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) { //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax $this_actual_shown_price = ( $this->products[$index]['final_price'] * $this->products[$index]['qty'] ) - $applied_discount; $applied_discount = 0; } } $shown_price = ( $this->products[$index]['final_price'] * $this->products[$index]['qty'] ) - $applied_discount; $this->info['subtotal'] += $shown_price; //if we need to display the subtotal without the discount applied, then add the shown price to the subtotal, then change shown price to the price with the applied discount in order to properly calculate taxes if( isset( $this_actual_shown_price ) ) $shown_price = $this_actual_shown_price; //end kgt - discount coupon } else { // EOF for TVA_intracom_v3.4 //kgt - discount coupon if( !empty( $this->info['coupon'] ) ) { if( !isset( $this_coupon ) ) { require_once( DIR_WS_CLASSES . 'discount_coupon.php' ); $this_coupon = new discount_coupon( $this->info['coupon'] ); } $applied_discount = $this_coupon->calculate_discount( $this->products[$index], $n, true ); if( isset( $this->info['applied_discount'][$this->products[$index]['tax_description']] ) ) { $this->info['applied_discount'][$this->products[$index]['tax_description']] += $applied_discount; } else { $this->info['applied_discount'][$this->products[$index]['tax_description']] = $applied_discount; } $this_actual_shown_price = null; if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) { //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax $this_actual_shown_price = ( tep_add_tax( $this->products[$index]['final_price'], $this->products[$index]['tax'] ) * $this->products[$index]['qty'] ) - $applied_discount; $applied_discount = 0; } } $shown_price = ( tep_add_tax( $this->products[$index]['final_price'], $this->products[$index]['tax'] ) * $this->products[$index]['qty'] ) - $applied_discount; $this->info['subtotal'] += $shown_price; //if we need to display the subtotal without the discount applied, then add the shown price to the subtotal, then change shown price to the price with the applied discount in order to properly calculate taxes if( isset( $this_actual_shown_price ) ) $shown_price = $this_actual_shown_price; //end kgt - discount coupon // BOF for TVA_intracom_v3.4 //For those who want taxes automatically if the conditions below are OK, uncomment the line below } // EOF for TVA_intracom_v3.4 // BOF for TVA_intracom_v3.4 //For those who want taxes automatically if the conditions below are OK, uncomment the lines below if ($this->billing['company'] != '' && $this->billing['tva_intracom'] != '' && $this->billing['country']['id'] != STORE_COUNTRY && $this->delivery['country']['id'] != STORE_COUNTRY) { $products_tax = 0; $products_tax_description = NO_TAX; } else { // EOF for TVA_intracom_v3.4 $products_tax = $this->products[$index]['tax']; $products_tax_description = $this->products[$index]['tax_description']; // BOF for TVA_intracom_v3.4 //For those who want taxes automatically if the conditions below are OK, uncomment the line below } // EOF for TVA_intracom_v3.4 if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } else { $this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } } else { $this->info['tax'] += ($products_tax / 100) * $shown_price; if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price; } else { $this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price; } } $index++; } if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; } else { $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; } } } ?> Quote Link to comment Share on other sites More sharing options...
Bassie Posted December 6, 2006 Share Posted December 6, 2006 Hi,I've just installed this contrib and I have to say it's a great one ! Thanks! :thumbsup: I'm using the discount percentage option rather then the fixed amount and I would like to round the discount amount to 5 cents. example: product 1: 24.50 product 2: 52.00 discount coupon (5%): -3.87 ???? (should this not be 3.83 ?) subtotal: 72.63 shipping: 6.20 Total: 78.83 My question where should I add (and what code) the rounding so that 3.87 becomes 3.85 ? It should round up to either ##.#0 or to ##.#5 preferable. It would be nice if someone could explain why the rounding is a little bit off as well even using percentage discount (I have read about the fix amount discount rounding issue), but I'm more interested in the rounding area. If I'll round to five cents, this small difference is not a real problem after all. thanks. Could someone assist me with the above ? Much appreciated! Quote Link to comment Share on other sites More sharing options...
kgt Posted December 6, 2006 Author Share Posted December 6, 2006 ok, this is my includes/classes/order.php You're missing the part that applies the discount: if (DISPLAY_PRICE_WITH_TAX == 'true') { $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; } else { $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; } //kgt - discount coupon if( !empty( $this->info['coupon'] ) && MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL == 'false' ) { foreach( $this->info['applied_discount'] as $discount ){ $this->info['total'] -= $discount; } } //end kgt - discount coupon } } ?> Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
kgt Posted December 6, 2006 Author Share Posted December 6, 2006 Could someone assist me with the above ? Much appreciated! The type of rounding you want to do is not exactly something that's built into a PHP round() function or anything. It's not difficult to do, but it takes finding a function to do it or working out the logic to do it yourself. If you do some searching and find some code someone has written to round like this, I will tell you how to add it in. Or ask in the general questions for someone to help you. Quote Contributions Discount Coupon Codes Donations Link to comment Share on other sites More sharing options...
Guest Posted December 6, 2006 Share Posted December 6, 2006 Thanks KGT, yes I figured that out, sorry I didn´t tell you earlier. Thanks a million for your time and support. It´s greatly apprecieated. Looks like everything is working now. :) 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.