Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

im still not getting it to work, I still have no option in checkout_payment to enter a coupon code. any help would be greatly appreciated.

 

Hi, I did a file compare of your code listed and mine and they are very close. However, I just went to your site and logged in as a customer to check it out from there and when I check the code on that page, the discount coding isn't there. I think you need to make sure that you upload the modified checkout_payment.php file that has the coding in it. Maybe you uploaded it under the wrong folder. I have done that before. It is still pulling from the old file without the discount coding.

 

Check that out and let me know what happens.

Link to comment
Share on other sites

Well I guess I solved it.

 

The software will not allow you to use a coupon code for a 'Special' item...

Is there anyway around this as I would like to show something on sale and still allow customers to use their coupon codes?

 

Hi, I believe you should be able to allow this if you change the setting in your admin panel under Modules, then Order Total, then Discount Coupons.

 

You should have the option that asks: Exclude product specials? to which you pick either true or false, in your case you want it to be false.

 

Try that and if you need more help post back.

Link to comment
Share on other sites

Hi, I did a file compare of your code listed and mine and they are very close. However, I just went to your site and logged in as a customer to check it out from there and when I check the code on that page, the discount coding isn't there. I think you need to make sure that you upload the modified checkout_payment.php file that has the coding in it. Maybe you uploaded it under the wrong folder. I have done that before. It is still pulling from the old file without the discount coding.

 

Check that out and let me know what happens.

 

 

i tried replacing the checkout_payment.php with the one that was in the zip file, and still does not work.

Link to comment
Share on other sites

Ok want to install this contrib, because I have a few other contribs added I was looking through the files to see what is going to miss. I can see two problems so far. I have the fancier Invoice & packing slip v6.1 installed. Everything looks like it will work(may be wrong) until I get to-- OPEN catalog/includes/classes/order.php. Mine is different thanks to the other contib, not a bad thing but would like to figure out where to put what.

 

the instructions say

and my order.php looks like this starting at line 281

 $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++;
	  }
	}

	$shown_price = $currencies->calculate_price($this->products[$index]['final_price'], $this->products[$index]['tax'], $this->products[$index]['qty']);
	$this->info['subtotal'] += $shown_price;

	$products_tax = $this->products[$index]['tax'];
	$products_tax_description = $this->products[$index]['tax_description'];
	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'];
  }
}
 }
?>

 

My next question, is there anything else I will need to adjust because of the other mod?

 

 

Anyone?

Link to comment
Share on other sites

Hello,

 

i had some problems to add the code on my class/order.php because sppc was added and i don´t know what i have do change. so if anyone can send me or post the class/order.php so that i can compare it with my one!

 

thanx a lot

 

marco

Link to comment
Share on other sites

i tried replacing the checkout_payment.php with the one that was in the zip file, and still does not work.

 

It appears you may be using the STS contrib. I haven't installed that one. From what I have seen this could be why it doesn't just work right out. If you are using the STS contrib, maybe there is something under that forum discussion that will help you.

Link to comment
Share on other sites

ok, I have looked in all of these posts, done all of the suggestions that have been mentioned (that I can find) and I am still getting the following error when I click on the "discount coupons" link on the left hand side of of the admin pages under the catalog catagory. I have uploaded version 3.31 and I have verified all of the files are in place. I really need some help with this if anyone can.

 

the error is

Discount Coupons NOTICE: Click here to read the Discount Coupon Codes manual for help editing coupons.

 

Coupon Code: Discount: Start: End: Max Use: Min Order: Available:

1054 - Unknown column 'cd.coupons_date_end' in 'order clause'

 

select * from discount_coupons cd order by cd.coupons_date_end, coupons_date_start limit 0, 20

 

[TEP STOP]

 

I am pulling my hair out over here and could really use some help.

Thank you in advance for any help you can offer.

 

Jesse

Link to comment
Share on other sites

ok, I have looked in all of these posts, done all of the suggestions that have been mentioned (that I can find) and I am still getting the following error when I click on the "discount coupons" link on the left hand side of of the admin pages under the catalog catagory. I have uploaded version 3.31 and I have verified all of the files are in place. I really need some help with this if anyone can.

 

the error is

Discount Coupons NOTICE: Click here to read the Discount Coupon Codes manual for help editing coupons.

 

Coupon Code: Discount: Start: End: Max Use: Min Order: Available:

1054 - Unknown column 'cd.coupons_date_end' in 'order clause'

 

select * from discount_coupons cd order by cd.coupons_date_end, coupons_date_start limit 0, 20

 

[TEP STOP]

 

I am pulling my hair out over here and could really use some help.

Thank you in advance for any help you can offer.

 

Jesse

 

Hi, did you see the post back on 1/15/08 where they had the same error then found the fix as stated here:

 

Fixed ! I found that when creating the tables in the database, the prefix "coupons_" was left off of a few columns

 

Don't know if yours is the same issue, but does sound like a database problem to me.

Link to comment
Share on other sites

Is there anyone that might be able to help me with this?? I'd like to go back to Paypal IPN, but can not get the discount code amount to show up when going to paypal. ANY help would be greatly appreciated.

 

 

 

 

I switched back to PayPal Website Payments Standard, and now the actual "real" total does come across as correct, although with the standard vs paypal_ipn Paypal does not show "Per Item" line items, it just displays the "final" total after discounts coupon, shipping and low order fee.

 

Does anyone else have DCC working with Paypal IPN v2.3.3?? or am I the only one that it's not working for???

Link to comment
Share on other sites

Is there anyone that might be able to help me with this?? I'd like to go back to Paypal IPN, but can not get the discount code amount to show up when going to paypal. ANY help would be greatly appreciated.

 

Hi, I am not sure if you have been to the contrib page for discount codes, but there was an update on 1/7/08 that might be what you are needing:

 

http://addons.oscommerce.com/info/4269

Link to comment
Share on other sites

Thanks for the info. That update is for PayPal IPN v2.2, I am running PayPal IPN v2.3.3. I made those chages in my paypal_ipn.php (for v2.3.3) and still had no effect. I STILL can not get the coupon discount amount to show up in the PayPal Checkout Process. One other note, when I apply shipping charges in osC, PayPal IPN is NOT showing the actual shipping charges, it does, however, give the correct amount with the shipping charges applied. The only way that I can get shipping charges to show up as a line item in paypal IPN is to turn on the "Shipping Preferences" in my PayPal Account.

 

Very Frustrating .. Just wondering if there is anyone out there that is running PayPal IPN V2.3.3 that does have the IPN stuff working ..

 

Thanks ahead of time :-)

 

David

Hi, I am not sure if you have been to the contrib page for discount codes, but there was an update on 1/7/08 that might be what you are needing:

 

http://addons.oscommerce.com/info/4269

Link to comment
Share on other sites

Working on a re-build of our site to find and resolve some glitches we've got happening. One thing I've come across is in my modified function is_recalc_shipping()

 

I have it set to recalculate using the Free Shipping with Minimum Amount contrib, and set to recalculate with the table rate

 

The Free Shipping with Minimum Amount portion is working correctly - the table rate is not. I'm guessing I did something goofy in the scripting of includes/classes/discount_coupon.php

 

This is what I have for the function:

	function is_recalc_shipping() {
  global $order, $language;

  //calculate the order total:
  $order_total = $order->info['total'] - $order->info['shipping_cost'];
  if( DISPLAY_PRICE_WITH_TAX != 'true' ) $order_total -= $order->info['tax'];

  //check if there is free shipping
		if( MODULE_SHIPPING_FREEAMOUNT_STATUS == 'True' ) {
			include( DIR_WS_LANGUAGES.$language.'/modules/shipping/freeamount.php' );
			//if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
			if( $order->info['shipping_cost'] == MODULE_SHIPPING_FREEAMOUNT_COST) { //if free shipping is the selected shipping method
				if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_SHIPPING_FREEAMOUNT_AMOUNT ) { //if the discount lowers the total below the free shipping limit
					return true;
				}
			}
		}else if( MODULE_SHIPPING_WFREEAMOUNT_STATUS == 'True' ) {
			include( DIR_WS_LANGUAGES.$language.'/modules/shipping/wfreeamount.php' );
			//if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
			if( $order->info['shipping_cost'] == MODULE_SHIPPING_WFREEAMOUNT_COST ) { //if free shipping is the selected shipping method
				if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_SHIPPING_WFREEAMOUNT_AMOUNT ) { //if the discount lowers the total below the free shipping limit
					return true;
				}
			}
		}
		return false;  

  //check if table rate shipping has changed
  if( strtolower(MODULE_SHIPPING_TABLE_STATUS) == 'true' ) {
	include( DIR_WS_LANGUAGES.$language.'/modules/shipping/table.php' );
	if( substr($order->info['shipping_method'], 0, strlen(MODULE_SHIPPING_TABLE_TEXT_TITLE)) == MODULE_SHIPPING_TABLE_TEXT_TITLE && MODULE_SHIPPING_TABLE_MODE == 'price' ) {
	  $table_cost = split( "[:,]", MODULE_SHIPPING_TABLE_COST );
	  for( $i = 0; $i < count( $table_cost ); $i += 2 ) {
		if( $order_total <= $table_cost[$i] ) {
		  $shipping = $table_cost[$i+1];
		  break;
		}
	  }
	  if( $order->info['shipping_cost'] != $shipping ) { //if the discount lowers the total below the table rate
		return true;
	  }
	}
  }

  return false;
}

 

On catalog/checkout_confirmation.php I do have this bit of code:

	  //now check to see if we need to recalculate shipping:
  require_once( DIR_WS_CLASSES.'discount_coupon.php' );
  if( discount_coupon::is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method

 

I am guessing that I've just done something goofy in the includes/classes/discount_coupon.php code - what do you think?

~Tracy
 

Link to comment
Share on other sites

I would like to install "Discount Coupon Codes" but I don't know where to start.

 

There are so many files. Which one do I download to install? :blush:

 

I believe the 3.31 version by dimi on 27 Sep 2007 is the latest full package to download first, then do any upgrades after that if needed.

Link to comment
Share on other sites

My discount code is working fine with one exception... the subtotal is DOUBLE of what it should be... AND, if there is shipping, it is being added as well. It is taking the full discount that it should, so that is good. Any ideas?

 

Thanks,

 

Mister Ed.

Link to comment
Share on other sites

Look in the Discount Coupon Contrib section, there is a fix specifically for this problem http://www.oscommerce.com/community/contributions,4269

 

Hope that helps!

 

D. Razey

 

My discount code is working fine with one exception... the subtotal is DOUBLE of what it should be... AND, if there is shipping, it is being added as well. It is taking the full discount that it should, so that is good. Any ideas?

 

Thanks,

 

Mister Ed.

Link to comment
Share on other sites

Hello,

 

I have installed this contrib and it works great. I am using STS and added the code at the bottom of the readme to display error messages. The only message that displays is the coupon code is not valid. It does not display the other error mesages, ie. Some or all the products in your cart are excluded.

 

The coupon is setup correctly, excludes it in the subtotal correctly. The only thing I am not getting is that error message.

 

Any suggestions?

Link to comment
Share on other sites

My discount code is working fine with one exception... the subtotal is DOUBLE of what it should be... AND, if there is shipping, it is being added as well. It is taking the full discount that it should, so that is good. Any ideas?

 

Thanks,

 

Mister Ed.

 

The only thing I find remotely close to this problem is where the discount is being doubled. That is NOT my issue. My issue is that the subtotal is being DOUBLED, shipping added, then the discount is applied. If I've missed this fix, I apologize, my eyes may be playing tricks on me. If you know which fix it is, please be specific as I am not finding it.

 

Thanks for your help.

Ed.

Link to comment
Share on other sites

Look in the Discount Coupon Contrib section, there is a fix specifically for this problem http://www.oscommerce.com/community/contributions,4269

 

Hope that helps!

 

D. Razey

 

 

Thanks, but I have been all over it and the only thing I find remotely close is the fix where the discount is being doubled. That is not my issue. My issue is the the subtotal is being doubled, then it adds shipping, then offers the discount. If I've overlooked it, please forgive me and pass along the correct fix name.

 

Thanks,

Ed.

Link to comment
Share on other sites

I'm working on a re-build of our site to get rid of some glitches we have, and I'm having an issue with DCC and shipping.

 

I've got the Free Shipping with Minimum Amount working so that if the discount drops below the Free Shipping level it then sends you back to choose another shipping method. However; I can't seem to get it to also work with the Table Rate, so that if the discount drops you to a lower shipping rate it should take you back to choose shipping again - but it isn't recognizing this.

 

My catalog/includes/classes/discount_coupon.php has this for the function is_recalc_shipping:

	function is_recalc_shipping() {
  global $order, $language;

  //calculate the order total:
  $order_total = $order->info['total'] - $order->info['shipping_cost'];
  if( DISPLAY_PRICE_WITH_TAX != 'true' ) $order_total -= $order->info['tax'];

  //check if there is free shipping
		if( MODULE_SHIPPING_FREEAMOUNT_STATUS == 'True' ) {
			include( DIR_WS_LANGUAGES.$language.'/modules/shipping/freeamount.php' );
			//if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
			if( $order->info['shipping_cost'] == MODULE_SHIPPING_FREEAMOUNT_COST) { //if free shipping is the selected shipping method
				if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_SHIPPING_FREEAMOUNT_AMOUNT ) { //if the discount lowers the total below the free shipping limit
					return true;
				}
			}
		}else if( MODULE_SHIPPING_WFREEAMOUNT_STATUS == 'True' ) {
			include( DIR_WS_LANGUAGES.$language.'/modules/shipping/wfreeamount.php' );
			//if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
			if( $order->info['shipping_cost'] == MODULE_SHIPPING_WFREEAMOUNT_COST ) { //if free shipping is the selected shipping method
				if( ( $order->info['total'] - $order->info['shipping_cost'] ) < MODULE_SHIPPING_WFREEAMOUNT_AMOUNT ) { //if the discount lowers the total below the free shipping limit
					return true;
				}
			}
			//check if table rate shipping has changed
		} else if( strtolower(MODULE_SHIPPING_TABLE_STATUS) == 'true' ) {
	include( DIR_WS_LANGUAGES.$language.'/modules/shipping/table.php' );
	if( substr($order->info['shipping_method'], 0, strlen(MODULE_SHIPPING_TABLE_TEXT_TITLE)) == MODULE_SHIPPING_TABLE_TEXT_TITLE && MODULE_SHIPPING_TABLE_MODE == 'price' ) {
	  $table_cost = split( "[:,]", MODULE_SHIPPING_TABLE_COST );
	  for( $i = 0; $i < count( $table_cost ); $i += 2 ) {
		if( $order_total <= $table_cost[$i] ) {
		  $shipping = $table_cost[$i+1];
		  break;
		}
	  }
	  if( $order->info['shipping_cost'] != $shipping ) { //if the discount lowers the total below the table rate
		return true;
	  }
	}
  }

  return false;
}

 

I'm guessing I have something messed up in here in the way I'm trying to get it to check first for the Free Shipping w/ Minimum Amount (which is functioning correctly) and then to check for the Table Rate (which is not functioning).

 

Are there any other files I should be looking at for this?

~Tracy
 

Link to comment
Share on other sites

Hi TracyS,

 

I don't know if this will help as it appears we have some different fixes or contribs installed, but I will post my code of the same area in that file here and you can compare to see if you think something might help:

 

function is_recalc_shipping() {

global $order, $language;

 

//calculate the order total:

// agrafuese - subtotal/shipping fix

$order_total = $this->cart_info['total_products']['total'];

/**********

$order_total = $order->info['total'] - $order->info['shipping_cost'];

**********/

// END agrafuese - subtotal/shipping fix

if( DISPLAY_PRICE_WITH_TAX != 'true' ) $order_total -= $order->info['tax'];

 

//check if there is free shipping

if( strtolower(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 the 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_total < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER ) { //if the discount lowers the total below the free shipping limit

return true;

}

}

}

 

//check if table rate shipping has changed

if( strtolower(MODULE_SHIPPING_TABLE_STATUS) == 'true' ) {

include( DIR_WS_LANGUAGES.$language.'/modules/shipping/table.php' );

if( substr($order->info['shipping_method'], 0, strlen(MODULE_SHIPPING_TABLE_TEXT_TITLE)) == MODULE_SHIPPING_TABLE_TEXT_TITLE && MODULE_SHIPPING_TABLE_MODE == 'price' ) {

$table_cost = split( "[:,]", MODULE_SHIPPING_TABLE_COST );

for( $i = 0; $i < count( $table_cost ); $i += 2 ) {

if( $order_total <= $table_cost[$i] ) {

$shipping = $table_cost[$i+1];

break;

}

}

// agrafuese - subtotal/shipping fix

/**********

if( $order->info['shipping_cost'] != $shipping ) { //if the discount lowers the total below the table rate

return true;

}

**********/

// END agrafuese - subtotal/shipping fix

}

}

 

return false;

}

Link to comment
Share on other sites

Ok, I have looked through a ton of pages and I haven't seen anyone else with this issue.

 

I am having a problem where I keep getting redirected to the login page when I use some of my coupon codes. 1 of the coupons I have set up works fine and takes you to the confirmation page as it should. For all the rest of the coupons this is what happens:

- customer adds something to cart

- customer clicks checkout and is taken to the login page

- customer logs in and is taken to checkout_shipping

- customer clicks continue and is taken to checkout_payment

- customer chooses payment type and enters coupon code

- when they click continue they are logged off and taken back to the login page. no errors are given.

 

the same thing happens if i enter an incorrect coupon code. i have checked to make sure that the coupons are all in the database.

 

any suggestions?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...