osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 

Discount Coupon Codes

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 ...


Go Back   osCommerce and osCMax shopping cart software forums > osCommerce 2.2 Forums > New osCommerce Contributions

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Reply

 

LinkBack Thread Tools
  #1  
Old 05-11-2007, 06:11 AM
michael_s's Avatar
osCMax Developer

 
Join Date: Jul 2002
Location: Phoenix, AZ
Posts: 10,330
Thanks: 68
Thanked 322 Times in 305 Posts
Rep Power: 10
michael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond reputemichael_s has a reputation beyond repute
Post Discount Coupon Codes

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


  • osCMax Templates - Hundreds of premium quality templates. New designs every month!

  • xShop for osCMax - Windows Based osCMax administration. Improved workflow, security, speed and convenience.

  • osCMax Hosting - From basic hosting to High Availability, Load Balanced arrays, the most experienced osCMax host.

  • osCMax Template Tutorial - Learn how to make your own custom templates and how to use the powerful features of the osCMax template system.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -8. The time now is 04:50 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax