This is a discussion on Discount Coupon Codes within the New osCommerce Contributions forums, part of the osCommerce 2.2 Forums category; After having a sale and realizing we just lost money on a purchase (product came to below wholesale cost) I ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| ||||
| ||||
| After having a sale and realizing we just lost money on a purchase (product came to below wholesale cost) I devised a little snip of code to exclude any items on sale from being processed through the sale. But regular items will still receive discount. You can use the code below or just replace the discount_coupon.php with the one in the zip file. Which ever is easier for you. Good Luck! ------------------------------------------------ ///// In the classes/discount_coupon.php file Replace the calc function (last function of the file) with this: function calculate_discount( $product, $product_count ) { //Start [Central50] sale exclusion //check if this product ($product['id'] on sale $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $product['id'] . "' and status = '1'"); if (tep_db_num_rows($specials_query) > 0) { $specials = tep_db_fetch_array($specials_query); $specialprice = $specials['specials_new_products_price']; } // End [Central50] sale exclusion //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 ) ); //Start [Central50] sale exclusion if ($specialprice > 0) { //This item is on sale, do not apply ANY discount $applied_discount = 0; } else { //This item is of regular value, let the system proceed with applied discount $applied_discount = tep_add_tax( $product['final_price'] * $max_applied_percentage * $this->coupon['coupons_discount_percent'], $product['tax'] ) * $product['qty']; } //End [Central50] sale exclusion //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']; return $applied_discount; } ------------------------------------- What I have done is used the code the check for specials from the shopping_cart class file. What I originally did was checked if any item was on sale and just shut off the coupons, but thats not fair to the customer if they have other items that are of regular price. This will be included in the for loop in the classes/order.php file and if that product is on sale, will not apply the sale to it. If it is not on sale, it will act of regular function. I am still learning in coding, I have done some extensive custom coding to both of my sites but if anyone sees any problems with this or can improve on it, by all means please do. And my staff and I have checked the outcome and it does work for me as far as I can tell. USE AT YOUR OWN RISK, NOT RESPONSIBLE FOR ANYTHING. More...
__________________ Michael Sasek osCMax Developer
|
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Discount Coupon Codes | michael_s | New osCommerce Contributions | 0 | 05-02-2007 12:00 PM |
| Discount Coupon Codes | michael_s | New osCommerce Contributions | 0 | 04-26-2007 07:21 AM |
| Discount Coupon Codes | michael_s | New osCommerce Contributions | 0 | 04-24-2007 07:20 AM |
| Discount Coupon Codes | michael_s | New osCommerce Contributions | 0 | 04-20-2007 06:31 PM |
| Discount Coupon Codes | michael_s | New osCommerce Contributions | 0 | 04-17-2007 10:01 AM |