Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

Nice contribution!

 

I've got the latest version installed with all the fixes and it seems to be working well through the checkout process. The checkout confirmation page shows the coupon line and totals are correct. However, in the confirmation email(s) and when displaying orders from account history, there is no reference to the coupon. You get things like:

Item 1 $1.00

Item 2 $1.00

Subtotal $1.80

with no reference to the coupon amount, in this case -0.20. The amounts are correct for the order as placed but the coupon information is not shown so it doesn't appear to add up correctly.

 

Is this situation true for all installations of this module and I need to figure out modifications to the appropriate files or is there something out of whack with my installation?

I'm runnng RC2.

 

Go over your install again carefully. I have made several different checks on my installation and it displays properly in account history and in the confirmation emails. It didn't the first time I installed it and when I went back over I found where I had missed some things.

Currently running 76 contibutions.

Link to comment
Share on other sites

I had discount coupon codes on my previous install of OSC MS2... I have just upgraded to RC2 Great contrib I love it. But Any word on when a complete download with all of the bug fixes and stuff will be available for the most recent version? I just dont want to have to go through to the contrib then go back through for the bug fix. Dont get me wrong I am not insulting or trying to offend I am just still teaching myself this stuff and the more steps I have the more likely I am to mess up. Any info will be appreciated. Thanks

Link to comment
Share on other sites

For some reason after installing 3.31 I have two bugs. Two features no effect what so ever:

 

Display subtotal with applied discount?

false

Still DOES deduct discount to subtotal line.

 

Allow negative order total?

false

And again no effect so accepting negative order total.

 

Otherwise the contribution works just nicely. Could anyone help with this issue?

Link to comment
Share on other sites

For some reason after installing 3.31 I have two bugs. Two features no effect what so ever:

 

Display subtotal with applied discount?

false

Still DOES deduct discount to subtotal line.

 

Allow negative order total?

false

And again no effect so accepting negative order total.

 

Otherwise the contribution works just nicely. Could anyone help with this issue?

I would advise you to install the last version uploaded by KGT which is 3.3. Install that version and try it. If you find you have problems then check the other "fixes" that were uploaded after that. Some of those problems that the fixes were uploaded for do not occur on all systems and can mess up the contribution that may otherwise work.

Edited by candleman

Currently running 76 contibutions.

Link to comment
Share on other sites

I would advise you to install the last version uploaded by KGT which is 3.3. Install that version and try it. If you find you have problems then check the other "fixes" that were uploaded after that. Some of those problems that the fixes were uploaded for do not occur on all systems and can mess up the contribution that may otherwise work.

 

Went through the installation with narrow comb and found reasons. First was plainly own stupidity (as in most parts these problems are :), added part of code to wrong place. :D A classic mistake.

 

Had to install the subtotal fix by agrafuese and modificate it a bit since I have always taxes applied. With this contribution subtotal will not show taxes included necessary. If you want taxes included on your subtotal line change:

 

 $actual_shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
	$applied_discount = 0;
//agrafuese - subtotal fix	
	$shown_price = $product['final_price'] * $product['qty'];
	} else {
		$shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
	}
/**********		
  }
  $shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
**********/

 

to:

 

 $actual_shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
	$applied_discount = 0;
//agrafuese - subtotal fix	
	$shown_price = $this->apply_tax($product['final_price'] * $product['qty'], $product['tax']);
	} else {
		$shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
	}
/**********		
  }
  $shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
**********/

 

This did the trick for me. :)

Link to comment
Share on other sites

I am VERY new to osCommerce so please bear with me. I have installed the module and it looks great! My questions is this:

 

Can I use this module to apply a discount code to a specific item only? In other words, the discount code is only applicable to a single item. If it is used against any other item, I do not want the code to be valid. Is this possible with the current version?

 

Thanks in advance!

Link to comment
Share on other sites

I am VERY new to osCommerce so please bear with me. I have installed the module and it looks great! My questions is this:

 

Can I use this module to apply a discount code to a specific item only? In other words, the discount code is only applicable to a single item. If it is used against any other item, I do not want the code to be valid. Is this possible with the current version?

 

Thanks in advance!

 

Why you don´t include this product in the Special?

Link to comment
Share on other sites

Why you don´t include this product in the Special?

 

Hi there,

 

The way our marketing department wants to do it, they want the price to be A unless you get a coupon code from a specific affiliate site, which would then make the price A - $50. It's a bit of an odd situation to say the least, but I am wondering if this can be done?

Link to comment
Share on other sites

I need some help..

 

After install and include a new coupon with all arguments open (no data limits, no usage limits and for all products), i run a test and i make a orderer typing the coupon code, however in checkout_payment.php the order total don´t show the discount..

 

well, i check and re-check the instalation and the only thing i found is this:

OPEN catalog/includes/classes/order.php

FIND on line 244:

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

REPLACE with this code:

//kgt - discount coupons

if( is_object( $this->coupon ) ) {

$applied_discount = 0;

$discount = $this->coupon->calculate_discount( $this->products[$index], $valid_products_count );

if( $discount['applied_discount'] > 0 ) $valid_products_count++;

$shown_price = $this->coupon->calculate_shown_price( $discount, $this->products[$index] );

$this->info['subtotal'] += $shown_price['shown_price'];

$shown_price = $shown_price['actual_shown_price'];

} else {

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

}

/**************

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

**************/

//end kgt - discount coupons

 

I use RC2 and the order.php dosn´t have this code

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

 

only this:

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

$this->info['subtotal'] += $shown_price

 

so, i made this:

//kgt - discount coupons

if( is_object( $this->coupon ) ) {

$applied_discount = 0;

$discount = $this->coupon->calculate_discount( $this->products[$index], $valid_products_count );

if( $discount['applied_discount'] > 0 ) $valid_products_count++;

$shown_price = $this->coupon->calculate_shown_price( $discount, $this->products[$index] );

$this->info['subtotal'] += $shown_price['shown_price'];

$shown_price = $shown_price['actual_shown_price'];

} else {

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

$this->info['subtotal'] += $shown_price;

}

/**************

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

$this->info['subtotal'] += $shown_price;

**************/

//end kgt - discount coupons

 

The module is active and the sort order is unique. I saw some post where other users have RC2 too but no one with this problem, the discount it's not aplicated for me..

 

Obs.: Sorry about my (poor) english...

Link to comment
Share on other sites

Hi there,

 

The way our marketing department wants to do it, they want the price to be A unless you get a coupon code from a specific affiliate site, which would then make the price A - $50. It's a bit of an odd situation to say the least, but I am wondering if this can be done?

 

ok.. Try to do this:

- Include a new coupom;

- Click in Products Exclusion button;

- Click in Choose All button;

- Now, in the right collun, select the product you want and click in the << button to put this product in the left collun, and Save.

Edited by rcdesign
Link to comment
Share on other sites

Hi, I am still no closer to getting my problem fixed. My problem is in the admin side of things, when I get an order with a discount coupon, I cannot update the order from pending to processing to delivered. The options don't even show. Someone said it might be the payment mod I have installed which is a bank transfer mod for NZ.

 

Is anyone able to help me out at all? I'm getting really frustrated as I cannot find any support for this issue.

Link to comment
Share on other sites

This is a great concept!

 

It worked for about two minutes after installing.

 

I am running osc2.2 rc2.

 

I did the install, and was able to get into the admin section. I made a coupon, and then went to my site and tested the coupon. It worked like a charm. Then I went to log back into the admin section. I got the login.php not found error. I patched that, and now I am gettin this error:

 

1146 - Table 'db233751650.TABLE_ADMINISTRATORS' doesn't exist

 

select id from TABLE_ADMINISTRATORS limit 1

 

[TEP STOP]

 

Does anyone know what this is, and how to fix it? Help would be great, because I would really like to use this contribution!

 

Thanks,

Josh

Link to comment
Share on other sites

your lucky i still cant work out which one to download... i started from the top and non of them are full contributions... i gave up after a couple...

 

do you download the last full package noted then all the rest?

 

also using 2.2

 

:huh:

Link to comment
Share on other sites

your lucky i still cant work out which one to download... i started from the top and non of them are full contributions... i gave up after a couple...

 

do you download the last full package noted then all the rest?

 

also using 2.2

 

:huh:

 

I finally got it to work! I only downloaded the last full package.

 

After I did the "login.php" fix, I had to do this next step to resolve the "table_admin" error.

 

In catalog/admin/includes/database_tables.php :

 

after:

 

define('TABLE_ADDRESS_FORMAT', 'address_format');

 

add:

 

define('TABLE_ADMINISTRATORS', 'administrators');

 

After completing this step I was allowed back into the admin section. In the admin section, I had to go to modules/order total, and click on "Discount Coupons", and then click install. It worked like a charm after that.

Link to comment
Share on other sites

did you download the :Discount Coupon Codes 3.31 (was that the last full version... i think it was... i'll try this for now)

 

cheers mate i'll give it a go :D

Edited by Misery_Kitty
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

OPEN catalog/includes/classes/order.php

 

FIND on line 217:

 

$index = 0;

$products = $cart->get_products();

 

ADD this code after:

 

//kgt - discount coupons

global $coupon;

if( tep_session_is_registered( 'coupon' ) && tep_not_null( $coupon ) ) {

require_once( DIR_WS_CLASSES.'discount_coupon.php' );

$this->coupon = new discount_coupon( $coupon, $this->delivery );

$this->coupon->total_valid_products( $products );

$valid_products_count = 0;

}

//end kgt - discount coupons

 

FIND on line 244:

 

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

 

REPLACE with this code:

 

//kgt - discount coupons

if( is_object( $this->coupon ) ) {

$applied_discount = 0;

$discount = $this->coupon->calculate_discount( $this->products[$index], $valid_products_count );

if( $discount['applied_discount'] > 0 ) $valid_products_count++;

$shown_price = $this->coupon->calculate_shown_price( $discount, $this->products[$index] );

$this->info['subtotal'] += $shown_price['shown_price'];

$shown_price = $shown_price['actual_shown_price'];

} else {

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

}

/**************

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

**************/

//end kgt - discount coupons

 

FIND on line 268:

 

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'];

}

 

ADD this code after:

 

//kgt - discount coupon

if( is_object( $this->coupon ) ) {

$this->info['total'] = $this->coupon->finalize_discount( $this->info );

}

//end kgt - discount coupon

 

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?

Link to comment
Share on other sites

Everything installed just fine, now I have a slight problem - the coupons we have on one of our sites are essentially to allow you to order something free. The problem I run into is that once the customer tries to check out, authorize.net responds with an error code that a valid amount is required. I don't mind having the customer put in their CC even for a free order, but I need to figure out how to only process if the amount is more than $0.00.

That's about the short of it ...

Even at a Mensa convention someone is the dumbest person in the room.

Link to comment
Share on other sites

A quick follow up - I tried to simply not call the payment module if the order->info{'total'} = 0 - but interesting enough, it now does not evaluate the reply from authorize for any purchase, which means I can purchase with a bad card and it will look like the order went through, not a good idea either. >_<

Even at a Mensa convention someone is the dumbest person in the room.

Link to comment
Share on other sites

I have installed the Discount Coupon Code and ALL seems to be working with the exception of when the customer is transferred to PayPal (IPN) for final payment. PayPal is NOT showing the total WITH the Discount being applied. PayPal is ONLY showing the Order Total (no discount coupon listed anywhere). I am running PayPal IPN v2.3.3 with OSC 2rc2. I have downloaded the latest DCC available from the contributions area of DCC.

 

Anyone have any ideas? this is causing a real problem for my site, as there are a great many customers that I give Discount's to based on Customer Name, Number, etc ..

 

Thanks in Advance :-)

 

D. Razey

Link to comment
Share on other sites

I have installed the Discount Coupon Code and ALL seems to be working with the exception of when the customer is transferred to PayPal (IPN) for final payment. PayPal is NOT showing the total WITH the Discount being applied. PayPal is ONLY showing the Order Total (no discount coupon listed anywhere). I am running PayPal IPN v2.3.3 with OSC 2rc2. I have downloaded the latest DCC available from the contributions area of DCC.

 

Anyone have any ideas? this is causing a real problem for my site, as there are a great many customers that I give Discount's to based on Customer Name, Number, etc ..

 

Thanks in Advance :-)

 

D. Razey

 

Hi,

 

Did you add this coding to your includes/modules/paypal_ipn.php file?

 

//kgt - discount coupons

if( tep_session_is_registered( 'coupon' ) && $order->info['coupon'] != '' ) {

$sql_data_array = array( 'coupons_id' => $order->info['coupon'],

'orders_id' => $order_id );

tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );

}

//end kgt - discount coupons

Link to comment
Share on other sites

That's what I checked this afternoon, but now looking at what you have put here (MANY, MANY Thanks by the way), It looks a bit different. I will go back and compare this to what I have.

 

Thanks Again !!

 

D. Razey

 

 

Hi,

 

Did you add this coding to your includes/modules/paypal_ipn.php file?

 

//kgt - discount coupons

if( tep_session_is_registered( 'coupon' ) && $order->info['coupon'] != '' ) {

$sql_data_array = array( 'coupons_id' => $order->info['coupon'],

'orders_id' => $order_id );

tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );

}

//end kgt - discount coupons

Link to comment
Share on other sites

I looked at my /catalog/languages/modules/payments/paypal_ipn.php and it did contain the code you put here. I'm adding a portion of my paypal_ipn.php file, perhaps I'm misisng something very minute.

 

D. Razey

 

//+1.4

$sql_data_array = array('orders_id' => $insert_id,

'orders_status_id' => $order->info['order_status'],

'date_added' => 'now()',

'customer_notified' => '0',

'comments' => $order->info['comments']);

tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

//-1.4

//kgt - discount coupons

if( tep_session_is_registered( 'coupon' ) && $order->info['coupon'] != '' ) {

$sql_data_array = array( 'coupons_id' => $order->info['coupon'],

'orders_id' => $order_id );

tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );

}

//end kgt - discount coupons

 

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

$sql_data_array = array('orders_id' => $insert_id,

'products_id' => tep_get_prid($order->products[$i]['id']),

'products_model' => $order->products[$i]['model'],

'products_name' => $order->products[$i]['name'],

'products_price' => $order->products[$i]['price'],

'final_price' => $order->products[$i]['final_price'],

'products_tax' => $order->products[$i]['tax'],

'products_quantity' => $order->products[$i]['qty']);

 

tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

 

 

 

 

 

 

That's what I checked this afternoon, but now looking at what you have put here (MANY, MANY Thanks by the way), It looks a bit different. I will go back and compare this to what I have.

 

Thanks Again !!

 

D. Razey

Link to comment
Share on other sites

I thought I would add in that if I have orders that total $30.00 or less I charge an additional fee. This fee IS showing up at paypal. Just the Discount Coupon stuff is not.

 

That's what I checked this afternoon, but now looking at what you have put here (MANY, MANY Thanks by the way), It looks a bit different. I will go back and compare this to what I have.

 

Thanks Again !!

 

D. Razey

Link to comment
Share on other sites

I checked my paypal_ipn.php and my discount coding is much further down then where you show yours. Mine looks like this around it:

 

$sql_data_array = array('orders_id' => $order_id,

'orders_status_id' => $order->info['order_status'],

'date_added' => 'now()',

'customer_notified' => (SEND_EMAILS == 'true') ? '1' : '0',

'comments' => $order->info['comments']);

 

tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

 

//kgt - discount coupons

if( tep_session_is_registered( 'coupon' ) && $order->info['coupon'] != '' ) {

$sql_data_array = array( 'coupons_id' => $order->info['coupon'],

'orders_id' => $order_id );

tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );

}

//end kgt - discount coupons

 

// initialized for the email confirmation

$products_ordered = '';

$subtotal = 0;

$total_tax = 0;

 

I haven't had an order with a discount coupon go thru paypal for a while, I now also have Google checkout and credit cards, but I am sure I did a little while back and it worked.

Link to comment
Share on other sites

ok.. Try to do this:

- Include a new coupom;

- Click in Products Exclusion button;

- Click in Choose All button;

- Now, in the right collun, select the product you want and click in the << button to put this product in the left collun, and Save.

 

This is odd. I am using 3.3.1 and I don't see these options for product exclusions in the coupon definition area. Am I missing something?

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