Jump to content
kgt

[Contribution] Discount Coupon Codes

Recommended Posts

The SQL you posted is not from version 3.3. Try downloading the package again and uploading admin/coupons.php again. I'm not sure what's happened, but it seems you have an old version of that file up there.
You were right :-"

 

 

Thanks a lot. It seems to be working alright now.

Share this post


Link to post
Share on other sites

Hello all,

Got this up and running and did a test order just fine. Since providing the coupon code to a customer though, Ive seen some problems, don't know if they're related.

 

1) Customer's order had the correct discount applied, but the order invoice itemizes the order as follows:

Sub-Total: $384.12

Discount Coupon "xyz" applied: -$576.18

Shipping: $0.00

Total: $384.12

 

Looks like the final total is fine, but what happened to the Original Subtotal?

 

2) I then set to "false" in the order total module: "Display subtotal with applied discount?" thinking that may be what was wrong with above.

 

3) I then tried to place a test order myself. I added items to my cart, entered the coupon code at checkout, received a message that shipping costs were being recalculated (fine) and was taken back to the payment type selection page. I was then in an neverending loop of the payment type selection page and the shipping recalculation notice page. I could not complete checkout.

 

4) I turned to "true" the "debug mode" setting in the order total module, hoping for some explanation.

 

5) Placed another test order, which did go through (no debugging output??), but this was how the final costs were calculated:

6 x 1/8" Eyelet Setters - BULK 019110 0% $19.00 $19.00 $114.00 $114.00

 

Sub-Total: $45.60

Discount Coupon "xyz" applied: -$68.40

 

No final total was listed, but the ultimate charge was for $0.

 

 

 

Help please??

 

By the way, in case this is related, I have set my minimum order amount, for receiving the discount, to $100. I opted to do this so that the shipping charge recalculation wouldn't hurt me as badly. I also happen to have a "free shipping after $100" anyway. Could this be what's messing it all up? What I can't figure out is why that first customer got through checkout fine (albeit with a weird display of her subtotals and totals), but I couldn't in a test order. One difference was that her FINAL discounted total was still above $100 and my test order final amount was only $40something. That's why I'm guessing they may have something to do with each other....

 

Thank you :)

 

Angela

Share this post


Link to post
Share on other sites
Double check the code you added to checkout_process.php. Also, if you're using Paypal IPN, see the README. There's an additional step you need to take to get it working.

 

 

WONDERFUL! :rolleyes: Verifiying my backups to the modified I found a syntax error which I corrected. then it worked.

File: checkout_process.php

Share this post


Link to post
Share on other sites

Hallo kgt,

 

I have 2 more questions :)

 

1) sometimes I get an error

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'or z2g.zone_id = 0 or z2g.zone_id IS NULL ) ' at line 5

 

SELECT dc2z.geo_zone_id FROM discount_coupons_to_zones dc2z LEFT JOIN zones_to_geo_zones z2g USING( geo_zone_id ) WHERE ( z2g.zone_id= or z2g.zone_id = 0 or z2g.zone_id IS NULL ) AND ( z2g.zone_country_id= or z2g.zone_country_id = 0 ) AND dc2z.coupons_id="55C4PDH9"

 

my mysql version is 5 and I use php5 in linux server. I don't accept any zones what can be reason for this problem?

 

2) what happens if the amount will be 0 ?

for example a product costs 10€ and I want to gift somebody this product. then I create a coupon with fixed amount 10€

but if the customer use this coupon the amount will 0 (which is correct) but still the customer is forwarded to the paypal page (with amount of 0!!!) how can fix this?

 

many thanks

 

regards

 

Taylan

Share this post


Link to post
Share on other sites
Hallo kgt,

 

I have 2 more questions :)

 

1) sometimes I get an error

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'or z2g.zone_id = 0 or z2g.zone_id IS NULL ) ' at line 5

 

SELECT dc2z.geo_zone_id FROM discount_coupons_to_zones dc2z LEFT JOIN zones_to_geo_zones z2g USING( geo_zone_id ) WHERE ( z2g.zone_id= or z2g.zone_id = 0 or z2g.zone_id IS NULL ) AND ( z2g.zone_country_id= or z2g.zone_country_id = 0 ) AND dc2z.coupons_id="55C4PDH9"

 

my mysql version is 5 and I use php5 in linux server. I don't accept any zones what can be reason for this problem?

 

2) what happens if the amount will be 0 ?

for example a product costs 10€ and I want to gift somebody this product. then I create a coupon with fixed amount 10€

but if the customer use this coupon the amount will 0 (which is correct) but still the customer is forwarded to the paypal page (with amount of 0!!!) how can fix this?

 

many thanks

 

regards

 

Taylan

 

and if I write an invalid code I get the error but then I cannot continue to use oscommerce . I get this error

 

Call to a member function add_current_page() on a non-object in /var/www/localhost/htdocs/includes/application_top.php on line 319

 

has onyone get this error before??

Share this post


Link to post
Share on other sites
If you PM or email me the code for your paypal module (found in includes/modules/payment/name_of_paypal_module.php, then I can take a look at it for you. What I will be adding is something like this:

 

global $currencies;
$order_total = number_format($order->info['total'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

 

And replace all instances of $order->info['total'] with $order_total (the rounded version of $order->info['total']).

 

By the way, good job on the debugging. I think you're probably correct on the reason for the error.

 

Thanks, KG. I just PMed you the code. Thanks also for the compliment. I'm new here, but I love OSCommerce, and I want to provide as much information as I can to help other people too. :-)

 

Stace


The soul is greater than the hum of its parts. -- Douglas R. Hofstadter in Gödel, Escher, Bach

Share this post


Link to post
Share on other sites

Hi,

 

i've applied version 3.3.

 

i still noticed that eventhough i set my coupon Max Use to 1, i can actually use it over and over again. hmm, it supposedly fixed right?

 

i follow the installation steps for clean install.

 

can anyone help me?

 

thank you.

Share this post


Link to post
Share on other sites
global $currencies;
$order_total = number_format($order->info['total'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

 

Hi KG,

 

I've been looking at the 1300+ lines of code in paypal_wpp.php, and have found the following lines that seem to relate to my rounding problem.

 

Line 419:

	  $order_info['PAYPAL_ORDER_TOTAL'] = number_format($order->info['total'], 2);

 

Lines 979-992:

	  $order_info = array();
  $order_info['PAYPAL_CURRENCY'] = $wpp_currency;
  $order_info['PAYPAL_ORDER_TOTAL'] = number_format($order->info['total'], 2);

  $order_info['PAYPAL_ORDER_DESCRIPTION'] = 'Order placed on ' . date("F j, Y, g:i a") . ' by ' . $order->customer['firstname'] . ' ' . $order->customer['lastname'] . ' (ID: ' . $_SESSION['customer_id'] . ')';
  $order_info['PAYPAL_CUSTOM'] = 'Phone: ' . $order->customer['telephone'] . ' -- Email: ' . $order->customer['email_address'];
  $order_info['PAYPAL_ITEM_TOTAL'] = $order->info['subtotal'];
  //The shipping total must be under $10,000.  I've removed the check that would
  //set the shipping total at $10,000 if it was over, but that didn't make any sense
  //as the totals would be off, causing other errors.  Just don't ship anything that'll cost more than $10k
  $order_info['PAYPAL_SHIPPING_TOTAL'] = $order->info['shipping_cost'];
  $order_info['PAYPAL_HANDLING_TOTAL'] = '';
  $order_info['PAYPAL_TAX_TOTAL'] = round($order->info['tax'], 2);
  $order_info['PAYMENT_DETAILS_ITEM'] = $this->wpp_generate_PDI($wpp_currency);

 

And finally, lines 1120-1124:

		   $transaction_info['PAYPAL_START_DATE'] = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d")-1,  date("Y"))) . 'T00:00:00-0700';
		$transaction_info['PAYPAL_PAYER'] = $order->customer['email_address'];
		$transaction_info['PAYPAL_AMOUNT'] = number_format($order->info['total'], 2);
		$transaction_info['PAYPAL_CURRENCY'] = $wpp_currency;
		$ts_req = $this->wpp_execute_transaction('transactionSearch', $transaction_info);

 

It appears that the WPP module developer is rounding (truncating?) the amounts, but uses a different rounding method than you described above. Could that be part of the problem, or does it discount my theory about the extra digits?

 

Thanks,

Stace


The soul is greater than the hum of its parts. -- Douglas R. Hofstadter in Gödel, Escher, Bach

Share this post


Link to post
Share on other sites
Can anyone provide me with assistance in getting the "coupons" link in my admin panel please?? I still can't figure this out! Thanks in advance..

 

Did you edit your admin/includes/boxes/catalog.php?

 

Also, when I edited this with the code given, it gave me an error message. Figured out why, needs a period at the end of the second line. Seemed to fix it. The second line given looks like this:

 

'<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a><br>'

 

just add the period like this (fixed mine):

 

'<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a><br>' .

 

Altogether with the other lines needed for the entire code should look like this:

 

//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>');

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

'<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a>');

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

//end kgt - discount coupons

 

Hope this helps :thumbsup:

Share this post


Link to post
Share on other sites
and if I write an invalid code I get the error but then I cannot continue to use oscommerce . I get this error

 

Call to a member function add_current_page() on a non-object in /var/www/localhost/htdocs/includes/application_top.php on line 319

 

has onyone get this error before??

 

 

I have solved this problem. This problem occurs because I have installed the german language package and the error definitions are very long. therefore it causes this error.

 

I have changed the error definitions in german.php and now it works.

 

but I have still other question.

 

what happens if the amount will be 0 ?

for example a product costs 10€ and I want to gift somebody this product. then I create a coupon with fixed amount 10€

but if the customer use this coupon the amount will 0 (which is correct) but still the customer is forwarded to the paypal page (with amount of 0!!!) how can fix this?

 

 

many thanks

Share this post


Link to post
Share on other sites

Hi,

 

I have a problem with the totaling of amounts. My site is still in development but I have entered the following products:

 

1 x 200 Problem Solving Tips $1.40

1 x 9 Deadly Mistakes Online $0.00

1 x Beginners Guide to Golf $1.50

1 x Bringing Your Golf Scores To Life! $0.00

2 x 10,000 Dreams Interpreted $1.80

1 x 101 Steps to Better Health $0.00

1 x 10 Steps to Google Friendly Page $0.70

1 x 49 Photoshop Web Templates $1.40

1 x Joint Ventures Inside and Out $1.40

1 x Home Business Guide $1.40

1 x Amazing Web Tools $5.08

1 x Business Website icon Collection $6.60

1 x Geographical Clipart Collection $5.08

1 x Fast Selling Software Package $5.08

1 x Google Power Pack $4.98

1 x iProfit eBook Package $6.08

1 x Marketing Devil Power Pack $4.98

1 x Niche Products Power Package $4.98

1 x Java Script Pro $5.98

1 x iProfit Template Package $5.08

 

and this is how the total is displayed:

Discount Coupon "Tyron turns 5 (Birthday)" applied (-$0.10): -$60.99

Tax not applied: -$0.00

Sub-Total: $2.53

Flat Rate (Best Way): $0.00

Total: $2.53

 

I have copied over the files but still get errors. I need help pls.

 

Pls check out www.serradinho.com for example.

Share this post


Link to post
Share on other sites

I have a new site that is just coming online and I am having a heck of a time getting this to work. I am a little frustrated (I have read through everything and can not find my problem, or I am just blind by now... You never know.) In admin everything seems to work fine. I can see the coupon and it assignes a number, asks for it on the checkout, however it never applies it or shows it being applied to the customer. Is this just a setting error or did I miss something? Any help for the newb....

Share this post


Link to post
Share on other sites

I have a new site that is just coming online and I am having a heck of a time getting this to work. I am a little frustrated (I have read through everything and can not find my problem, or I am just blind by now... You never know.) In admin everything seems to work fine. I can see the coupon and it assignes a number, asks for it on the checkout, however it never applies it or shows it being applied to the customer. Is this just a setting error or did I miss something? Any help for the newb....

Share this post


Link to post
Share on other sites

i have a slightly different problem from what i have seen on here ,

all the contrib has been added but when i get to my admin page most of it is missing, just the top left config box remains.

 

i had to manually add the table to the database but got frequent PRIMARY KEY must NOT NUL errors saying i should use UNIQUE instead.

 

so the i was left with a non functioning admin panel.

 

i reinstalled my original pre mod admin files (these only) and got my admin panel back

with the discount coupon order totals module still there.

 

when i try to install the module i get :-

 

1171 - All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead

 

CREATE TABLE IF NOT EXISTS discount_coupons_to_orders ( coupons_id VARCHAR(32) NOT NULL DEFAULT '', orders_id INT(11) DEFAULT '0', PRIMARY KEY (coupons_id,orders_id) )

 

[TEP STOP

 

and when i reinstall the mod i lose my admin panel again

 

 

HELP

Share this post


Link to post
Share on other sites
i have a slightly different problem from what i have seen on here ,

all the contrib has been added but when i get to my admin page most of it is missing, just the top left config box remains.

 

i had to manually add the table to the database but got frequent PRIMARY KEY must NOT NUL errors saying i should use UNIQUE instead.

 

so the i was left with a non functioning admin panel.

 

i reinstalled my original pre mod admin files (these only) and got my admin panel back

with the discount coupon order totals module still there.

 

when i try to install the module i get :-

 

1171 - All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead

 

CREATE TABLE IF NOT EXISTS discount_coupons_to_orders ( coupons_id VARCHAR(32) NOT NULL DEFAULT '', orders_id INT(11) DEFAULT '0', PRIMARY KEY (coupons_id,orders_id) )

 

[TEP STOP

 

and when i reinstall the mod i lose my admin panel again

HELP

 

 

Replace includes/modules/order_total/ot_discount_coupons.php with the following:

 

<?php
/*
* ot_discount_coupons.php
* August 4, 2006
* author: Kristen G. Thorson
* ot_discount_coupon_codes version 3.0
*
*
* Released under the GNU General Public License
*
*/

 class ot_discount_coupon {
var $title, $output, $coupon;

function ot_discount_coupon() {
  $this->code = 'ot_discount_coupon';
  $this->title = MODULE_ORDER_TOTAL_DISCOUNT_COUPON_TITLE;
  $this->enabled = ((MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true') ? true : false);
  $this->sort_order = MODULE_ORDER_TOTAL_DISCOUNT_COUPON_SORT_ORDER;
  $this->output = array();
}

function process() {
  global $order, $currencies;
  if( is_object( $order->coupon ) ) {

	//if the order total lines for multiple tax groups should be displayed as one, add them all together
	if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_LINES == 'false' ) $discount_lines = array( array_sum( $order->coupon->applied_discount ) );
	else $discount_lines = $order->coupon->applied_discount;

	if( is_array( $discount_lines ) ) foreach( $discount_lines as $tax_group => $discount ) {
	  if( $discount > 0 ) {
		//add in the tax if needed:
		if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX == 'Display discount with discounted tax applied' && is_array( $order->coupon->discount_tax ) ) $discount += array_sum( $order->coupon->discount_tax );
		//determine the display type (with or without the minus sign):
		$display_type = ( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TYPE == 'true' ? '-' : '' );
		$text = $display_type . $currencies->format( $discount, true, $order->info['currency'], $order->info['currency_value'] );
		//add debug text if debug is on:
		if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $text .= print_r( "\n\n<!-- Discount Coupons DEBUG\n".print_r( $order, true )."\nEnd Discount Coupons DEBUG-->\n\n", true );
		$this->output[] = array( 'title' => $order->coupon->format_display( $tax_group ) . ':',
								 'text' => $text,
								 'value' => $display_type . $discount );
	  }
	}
	//determine if we need to display a second line to show tax no longer applied
	if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX == 'Display discounted tax in separate line' && is_array( $order->coupon->discount_tax ) ) {
	  $discounted_tax = array_sum( $order->coupon->discount_tax );
	  $text = $display_type . $currencies->format( $discounted_tax, true, $order->info['currency'], $order->info['currency_value'] );
	  $this->output[] = array( 'title' => MODULE_ORDER_TOTAL_DISCOUNT_COUPON_TAX_NOT_APPLIED . ':',
							   'text' => $text,
							   'value' => $display_type . $discounted_tax );
	}
  } else $this->enabled = false;
}

function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }

  return $this->_check;
}

function keys() {
  return array( 'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_SORT_ORDER',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TYPE',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_EXCLUDE_SPECIALS',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_RANDOM_CODE_LENGTH',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_LINES',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_RECALC_SHIPPING',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_ALLOW_NEGATIVE',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_USE_LANGUAGE_FILE',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_CONFIG',
				'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG');
}

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
				  ('Enable discount coupon?',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS',
				   'true',
				   '',
				   '615',
				   '1',
				   'tep_cfg_select_option(array(\'true\', \'false\'), ',
				   now()),
				  ('Sort Order',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_SORT_ORDER',
				   '0',
				   'Order in which the discount coupon code order total line will be displayed on order confirmation, invoice, etc.',
				   '615',
				   '2',
				   '',
				   now()),
				  ('Display discount with minus (-) sign?',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TYPE',
				   'true',
				   '<b>true</b> - the discount will be displayed with a minus sign<br><b>false</b> - the discount will be displayed without a minus sign',
				   '615',
				   '3',
				   'tep_cfg_select_option(array(\'true\', \'false\'), ',
				   now()),
				  ('Display subtotal with applied discount?',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL',
				   'true',
				   '<b>true</b> - the order subtotal will be displayed with the discount applied<br><b>false</b> - the order subtotal will be displayed without the discount applied',
				   '615',
				   '4',
				   'tep_cfg_select_option(array(\'true\', \'false\'), ',
				   now()),
				  ('Display tax in discount line?',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX',
				   'None',
				   'Select the method for displaying tax in the discount line.',
				   '615',
				   '5',
				   'tep_cfg_select_option(array(\'None\', \'Display discounted tax in separate line\', \'Display discount with discounted tax applied\'), ',
				   now()),
				  ('Exclude product specials?',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_EXCLUDE_SPECIALS',
				   'true',
				   '<b>true</b> - products with active specials will be excluded from discounts<br><b>false</b> - products with active specials will NOT be excluded from discounts',
				   '615',
				   '6',
				   'tep_cfg_select_option(array(\'true\', \'false\'), ',
				   now()),
				  ('Random Code Length',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_RANDOM_CODE_LENGTH',
				   '6',
				   'Length for randomly generated coupon codes.',
				   '615',
				   '7',
				   '',
				   now()),
				  ('Display discount total lines for each tax group?',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_LINES',
				   'false',
				   '<b>true</b> - the discount coupon order total lines will be displayed for each tax group for the order<br><b>false</b> - the discount order total lines will be combined and displayed as one line',
				   '615',
				   '8',
				   'tep_cfg_select_option(array(\'true\', \'false\'), ',
				   now()),
				  ('Recalculate Free Shipping and Table Shipping limits?',
				   'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_RECALC_SHIPPING',
				   'true',
				   '<b>true</b> - the discounted order total will be used to determine if the shipping rate has changed<br><b>false</b> - the shipping rate will be based on the original (non-discounted) order total',
				   '615',
				   '9',
				   'tep_cfg_select_option(array(\'true\', \'false\'), ',
				   now()),
				  ('Allow negative order total?',
					'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_ALLOW_NEGATIVE',
					'false',
					'Set to true if you want negative order totals when the discount is greater than the order total.',
					'615',
					'10',
					'tep_cfg_select_option(array(\'true\', \'false\'), ',
					now()),
				   ('Use the language file to format display string?',
					'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_USE_LANGUAGE_FILE',
					'false',
					'<b>true</b> - use the format found in language file (used for when you have multiple languages and want the order total line to format display depending on language choice)<br><b>false</b> - use the format and language below',
					'615',
					'11',
					'tep_cfg_select_option(array(\'true\', \'false\'), ',
					now()),
				   ('Display Format for Order Total Line',
					'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_CONFIG',
					'Discount Coupon [code] applied',
					'Display format for the discount coupon code order total line.<br><br>Variables:<br>[code]<br>[coupon_desc]<br>[discount_amount]<br>[min_order]<br>[number_available]<br>[tax_desc]',
					'615',
					'12',
					'',
					now()),
				   ('Debug Mode',
					'MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG',
					'false',
					'To use: on checkout confirmation page, View Source in browser for debug output. <b>This must be set to false for live shops or error messages will not display.</b>',
					'615',
					'13',
					'tep_cfg_select_option(array(\'true\', \'false\'), ',
					now())");

  tep_db_query("CREATE TABLE IF NOT EXISTS discount_coupons (
				  coupons_id VARCHAR(32) NOT NULL DEFAULT '',
				  coupons_description VARCHAR(64) NOT NULL DEFAULT '',
				  coupons_discount_amount DECIMAL(15,12) NOT NULL DEFAULT '0.0000',
				  coupons_discount_type ENUM ('fixed','percent','shipping') NOT NULL DEFAULT 'percent',
				  coupons_date_start DATETIME DEFAULT NULL,
				  coupons_date_end DATETIME DEFAULT NULL,
				  coupons_max_use INT(3) NOT NULL DEFAULT 0,
				  coupons_min_order DECIMAL(15,4) NOT NULL DEFAULT '0.0000',
				  coupons_min_order_type ENUM('price','quantity') DEFAULT 'price',
				  coupons_number_available INT(3) NOT NULL DEFAULT 0,
				  PRIMARY KEY  (coupons_id)
				)");

  tep_db_query("CREATE TABLE IF NOT EXISTS discount_coupons_to_orders (
				  coupons_id VARCHAR(32) NOT NULL DEFAULT '',
				  orders_id INT(11) NOT NULL DEFAULT '0',
				  PRIMARY KEY  (coupons_id,orders_id)
				)");

  tep_db_query("CREATE TABLE IF NOT EXISTS discount_coupons_to_categories (
				  coupons_id VARCHAR(32) NOT NULL DEFAULT '',
				  categories_id INT(11) NOT NULL DEFAULT '0',
				  PRIMARY KEY  (coupons_id,categories_id)
				)");

  tep_db_query("CREATE TABLE IF NOT EXISTS discount_coupons_to_products (
				  coupons_id VARCHAR(32) NOT NULL DEFAULT '',
				  products_id INT(11) NOT NULL DEFAULT '0',
				  PRIMARY KEY  (coupons_id,products_id)
				)");

  tep_db_query("CREATE TABLE IF NOT EXISTS discount_coupons_to_manufacturers (
				  coupons_id VARCHAR(32) NOT NULL DEFAULT '',
				  manufacturers_id INT(11) NOT NULL DEFAULT '0',
				  PRIMARY KEY  (coupons_id,manufacturers_id)
				)");

  tep_db_query("CREATE TABLE IF NOT EXISTS discount_coupons_to_customers (
				  coupons_id VARCHAR(32) NOT NULL DEFAULT '',
				  customers_id INT(11) NOT NULL DEFAULT '0',
				  PRIMARY KEY  (coupons_id,customers_id)
				)");

  tep_db_query("CREATE TABLE IF NOT EXISTS discount_coupons_to_zones (
				  coupons_id VARCHAR(32) NOT NULL DEFAULT '',
				  geo_zone_id INT(11) NOT NULL DEFAULT '0',
				  PRIMARY KEY  (coupons_id,geo_zone_id)
				)");

}

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
 }
?>

 

This fix only affects MySQL 5 users with strict SQL turned on.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
I have a new site that is just coming online and I am having a heck of a time getting this to work. I am a little frustrated (I have read through everything and can not find my problem, or I am just blind by now... You never know.) In admin everything seems to work fine. I can see the coupon and it assignes a number, asks for it on the checkout, however it never applies it or shows it being applied to the customer. Is this just a setting error or did I miss something? Any help for the newb....

 

 

See the README for help with common problems like this one. Likely causes are a non-unique sort order, you missed the changes to includes/classes/order.php, or you missed the changes to checkout_confirmation.php.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
Hi,

 

I have a problem with the totaling of amounts. My site is still in development but I have entered the following products:

 

1 x 200 Problem Solving Tips $1.40

1 x 9 Deadly Mistakes Online $0.00

1 x Beginners Guide to Golf $1.50

1 x Bringing Your Golf Scores To Life! $0.00

2 x 10,000 Dreams Interpreted $1.80

1 x 101 Steps to Better Health $0.00

1 x 10 Steps to Google Friendly Page $0.70

1 x 49 Photoshop Web Templates $1.40

1 x Joint Ventures Inside and Out $1.40

1 x Home Business Guide $1.40

1 x Amazing Web Tools $5.08

1 x Business Website icon Collection $6.60

1 x Geographical Clipart Collection $5.08

1 x Fast Selling Software Package $5.08

1 x Google Power Pack $4.98

1 x iProfit eBook Package $6.08

1 x Marketing Devil Power Pack $4.98

1 x Niche Products Power Package $4.98

1 x Java Script Pro $5.98

1 x iProfit Template Package $5.08

 

and this is how the total is displayed:

Discount Coupon "Tyron turns 5 (Birthday)" applied (-$0.10): -$60.99

Tax not applied: -$0.00

Sub-Total: $2.53

Flat Rate (Best Way): $0.00

Total: $2.53

 

I have copied over the files but still get errors. I need help pls.

 

Pls check out www.serradinho.com for example.

 

Please PM or email me a debug output. See the README for help with this.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
what happens if the amount will be 0 ?

for example a product costs 10€ and I want to gift somebody this product. then I create a coupon with fixed amount 10€

but if the customer use this coupon the amount will 0 (which is correct) but still the customer is forwarded to the paypal page (with amount of 0!!!) how can fix this?

many thanks

 

 

Several people have asked about this. I gave suggestions in a previous thread. Basically it's something you have to take care of in the Paypal module.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites

Hi,

 

First of all, thanks to Kristen for this excellent contribution and the sustained support.

I have installed it and started to play with the different configurations. Everything seems to work just fine until now except for one thing: the subtotal always display with the discount applied, wheteher I set to value "Display subtotal with applied discount?" in config to true or to false. The MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL value changes well in the database when I make the change in config but the subtotal dispalys the same in both cases. Any idea???

 

Thanks,

Andybird

Share this post


Link to post
Share on other sites
Hi,

 

i've applied version 3.3.

 

i still noticed that eventhough i set my coupon Max Use to 1, i can actually use it over and over again. hmm, it supposedly fixed right?

 

i follow the installation steps for clean install.

 

can anyone help me?

 

thank you.

 

 

Make sure you've made the changes to checkout_process.php. Also see the README for help with fixing Paypal IPN if you use that as a payment module. Some payment modules may alter the way checkout_process.php operates or bypass it completely. It all depends on what else you have installed.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
Hi,

 

First of all, thanks to Kristen for this excellent contribution and the sustained support.

I have installed it and started to play with the different configurations. Everything seems to work just fine until now except for one thing: the subtotal always display with the discount applied, wheteher I set to value "Display subtotal with applied discount?" in config to true or to false. The MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL value changes well in the database when I make the change in config but the subtotal dispalys the same in both cases. Any idea???

 

Thanks,

Andybird

 

Can you PM or email me debug output? See the README for help with that.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
Can you PM or email me debug output? See the README for help with that.

 

thanks for your fast replay. You mean to look at the README for help on my problem or for how activating the debug mode?

 

Andybird

Share this post


Link to post
Share on other sites
thanks for your fast replay. You mean to look at the README for help on my problem or for how activating the debug mode?

 

Andybird

 

I mean look in the README file on how to go about capturing the debug output, then send it to me in a PM or email.


Contributions

 

Discount Coupon Codes

Donations

Share this post


Link to post
Share on other sites
Hi,

 

First of all, thanks to Kristen for this excellent contribution and the sustained support.

I have installed it and started to play with the different configurations. Everything seems to work just fine until now except for one thing: the subtotal always display with the discount applied, wheteher I set to value "Display subtotal with applied discount?" in config to true or to false. The MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL value changes well in the database when I make the change in config but the subtotal dispalys the same in both cases. Any idea???

 

Thanks,

Andybird

 

Kristen has just been giving me the solution. You guys having this problem should edit discount_coupon.php like follows:

 

Changing lines 369-373 from this:

 

 

CODE

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

$actual_shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );

$applied_discount = 0;

}

 

 

to this:

 

 

CODE

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

$actual_shown_price = ( $this->apply_tax( $product['final_price'], $product['tax'] ) * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );

$discount['applied_discount'] = 0;

}

 

Best,

Andybird

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×