Latest News: (loading..)
high-quality-php-coding

[add-on] Discount Code (support)

153 posts in this topic

Using this "fix", tax are ok

 

catalog/includes/modules/order_total/ot_discount.php

 

Find:

if (!empty($order->products[$i]['tax'])){

And replace with:

if ((!empty($order->products[$i]['tax'])) && (strpos($check['discount_values'], '%') == true)){

 

Find:

	  if (!empty($discount)) {
	$order->info['total'] -= array_sum($tax_discount);
	$order->info['total'] -= $discount;

Add after:

	  if (strpos($check['discount_values'], '%') == true) {
	$discount = $discount + array_sum($tax_discount);			
	}

 

Save the file and upload wink.gif

 

Regards!!

 

I have problems with taxes too. I change code as above but it doesn't fix my problem.

 

Products price is with tax and discount should be show with tax. I asked advice for my problem from http://high-quality-php-coding.com/ but they only said that i have to adjust $order->info['total']. I didn't know what I have to do but now I am almost solved this problem. I fix ot_tax.php file:

 

Find:

if ($value > 0) {

Add below:

 $step1 = $order->info['subtotal'] - $value;
 $step2 = $order->info['subtotal'] / $step1;
 $step3 = $order->info['total'] - ($order->info['total'] / $step2);

 

 

Find:

		
$this->output[] = array('title' => $key . ':',
							  'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']),
							  'value' => $value);

 

 

Replace with:

 

	  $this->output[] = array('title' => $key . ':',
							 // 'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']),
							 // 'value' => $value);
							  'text' => $currencies->format($step3, true, $order->info['currency'], $order->info['currency_value']),
							  'value' => $step3);

 

 

Everything works fine if total is over free shipping limit. If total is under then comes shipping fee. Fee includes tax also and now problem is that this tax got discount too.

 

How I can exlude tax of shipping from this?

Share this post


Link to post
Share on other sites

Thought I had it fixed but get errors when I go into the admin section.... Any suggestions? I am at a loss.

 

define('FILENAME_DISCOUNT_CODES', 'discount_codes.php'); // Discount Code 2.6 // Discount Code 2.6 - start define('TABLE_CUSTOMERS_TO_DISCOUNT_CODES', 'customers_to_discount_codes'); define('TABLE_DISCOUNT_CODES', 'discount_codes'); // Discount Code 2.6 - end

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/hugsnsti/public_html/store/admin/includes/filenames.php:57) in /home/hugsnsti/public_html/store/admin/includes/functions/sessions.php on line 102

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/hugsnsti/public_html/store/admin/includes/filenames.php:57) in /home/hugsnsti/public_html/store/admin/includes/functions/sessions.php on line 102

 

Warning: Cannot modify header information - headers already sent by (output started at /home/hugsnsti/public_html/store/admin/includes/filenames.php:57) in /home/hugsnsti/public_html/store/admin/includes/functions/general.php on line 34

Share this post


Link to post
Share on other sites

Hi -

I just installed this module and the most recent update for it on my store. It is working fine in the admin side, but when I just went to checkout and order to test it I get a white, blank screen when you get to the "payment information"( or checkout_payment.php) page.

 

Does anyone have any idea of what would be causing this to happen?

 

Thanks

Liz

Share this post


Link to post
Share on other sites

I was happy to find that the Discount code was upgraded to work on Paypal so I went from my v2.6 step by step till I reached 3.1.1

 

The problem I now have is that my default currency is GBP, checkout is great, discount is applied and then... when you get to Paypal payment, paypal charges the same amount in US$

 

i.e. Total purchase is GBP 10 ---> Paypal charges the customer US$ 10

Now even when I disable the discount code module, I still have the same problem!!

 

Even when selecting US$ currency, when you go to checkout PayPal will charge the GBP value but in US$

 

i.e. Total Purchase is US$ 150 ---> Paypal charges US$ 100 (Which is what it would have been in GBP)

 

Hope I make sense

Thanks for any help as my site is now useless

 

Emile

Share this post


Link to post
Share on other sites

This add-on is great but there is missing one important attribute, customer groups. It is so much easier to handle groups than individual persons. I tried yesterday to code customer group for Discount Code and get it almost work.

 

Now I can:

- Add customer groups via admin

- Add customers to groups

- Adjust discount codes to groups

 

Problem is what I should to change to ot_discount.php file?

 

If some one wants to continue this project or give some advice I appreciate that help a lot. thumbsup.gif

 

I attached files and instructions for what I have done.

Share this post


Link to post
Share on other sites

Hi guys, great addon - Thanks.

 

I have two issues however, which are probably very simple to fix, but just can't get my head around.

 

1 - The discount code section should be in its own box, this however isn't showing.

 

helpcs.jpg

 

2 - Paypal - The PayPal isn't working on "Discount Code 2.9 for osCommerce 2.2" version. I've applied the paypal fix but to no joy.

 

Wanting to get a mailshot sent out asap, so would really appreciate an answer.

 

Many Thanks

 

Alex

Edited by Whittie

Share this post


Link to post
Share on other sites

Hi, I just installed this, got to step 14: Install the module under Administration -> Modules -> Order Total -> Discount Code.

When I go to this page Discount Code is listed, but when I click on it, nothing happens. There's no "install" button. Any ideas of where the problem could be?

 

Thank you.

 

I installed Discount Code 2.9 for osCommerce 2.2

Edited by jordana

Share this post


Link to post
Share on other sites

Hi,

 

I installed Discount Code 2.9 for osCommerce 2.2 on V2.2 RC2. Everythings working fine until checkout_confirmation.php where i cant see the discount field or its being applied to the Sub-total.

 

Attached a Screencap of how it looks.

 

Appriciate any help on this.

 

http://i.imgur.com/ZDAkz.png

 

thanks

Edited by nammm

Share this post


Link to post
Share on other sites

ok install this and the paypal standard fix but it only seems to send the right amount to pay to paypal when you do apply to order sub total if you apply to total it ignores the discount

Share this post


Link to post
Share on other sites

Hi Kevin, thanks for your solution but I would like to set Paypal IPN module set to 'per item' mode. Do you know what modification is required in order to make it work with 'per item'? Thanks!

 

I've got this to work with 'per item' mode (whoop!), it seems the following are important;

  • discount should be in the 'discount_amount_cart' parameter
  • there should be NO tax_1, tax_2, etc parameters declared.
  • declare the full tax in the 'tax_cart' parameter instead

The second point is crucial, if these variables are declared, then paypal ignores the discount amount.

 

 

So to fix;

 

Step 1 - Comment out the following line:

 

 $parameters['tax_' . $item] = number_format($tax_value * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

 

Step 2 - Change the discount code added from my previous post (quoted at the bottom), to instead be;

 

if (isset($order_total['ot_discount'])) {	
$parameters['discount_amount_cart'] = number_format(($order_total['ot_discount']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
if (MOVE_TAX_TO_TOTAL_AMOUNT != 'True') $parameters['tax_cart'] = $tax_total;
}

 

The method will apply generally to other setups, just you will have to figure out where to code the parameters. (my original post quoted below is the code I added for my setup)

 

I've found the solution to making this mod work with Paypal IPN 2.3.4.6 thumbsup.gif

This may also work with other paypal mods and other discount mods, but you need to check the variable names to be certain.

This is only for use with the Paypal IPN module set to 'aggregate' mode, not 'per item' (although it would work with a bit of modification).

 

 

Open \catalog\includes\modules\payment\paypal_ipn.php

 

Find the code:

 

	if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
	  $parameters['amount'] = number_format(($subtotal + $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	} else {
	  // default
	  $parameters['amount'] = number_format($subtotal * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	  $parameters['tax'] = number_format($order->info['tax'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	}

 

(make sure this is correct, there's another 'IF' block that looks very similar in a different loop)

Add the following code directly after:

 

if (isset($order_total['ot_discount'])) {	
$parameters['discount_amount'] = number_format(($order_total['ot_discount']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
}

 

 

Done!

 

The discount will now be included in the paypal payment page, and its event under a special 'discount' heading so your customer can see how much they're saving!

 

 

EDIT: I guess you could also set the variable 'discount_amount_cart' instead of 'discount_amount' (see https://cms.paypal.c...d_htmlvariables), but this seems to work so I haven't played around too much. 'discount_amount_cart' is infact for the whole cart so this may work better for aggregate mode.

Share this post


Link to post
Share on other sites

Yep.....completely lost. I set my site up but I can't, for the life of me, figure out how to get the discount code to work.

Share this post


Link to post
Share on other sites

So....since I'm not figuring this out....where do I need to install the Discount Code file. I have made it through getting the site up and running and set up but I am having a HUGE brain fart right now.

Share this post


Link to post
Share on other sites

What a great add-on!! Everything works great except.......has anyone come up with a solution for the tax problem? I've tried all the solutions mentioned in this post, with no luck. None of those work properly either. It looks as though the taxes are being calculated before the discount takes place. In other words, on the original price, Any and all information will be well received by many.

 

Peace,

 

Jason

Share this post


Link to post
Share on other sites

I contacted high-quality-php-coding.com that created this handy ADD-ON and explained the problem and got following reply:

 

 

Hello,

 

Thank you for your interest in our product.

 

To get correct order total info, you should adjust the following

variables:

 

$order->info['tax']

$order->info['tax_groups'][<your tax>]

$order->info['total']

 

Sincerely,

The High Quality PHP Coding Team.

 

This was posted by someone previously regarding fixing the tax problem with this contribution. Does anyone know how to adjust this so we can get this invaluable contribution to work properly with taxes?

 

Thanks so much!

 

Jason

Share this post


Link to post
Share on other sites

Hi all,

 

Anyone able to make it work with One Page checkout? right now I am able to include the discount field and also the ajax validation. it works. Can someone point me or help how to trigger the java to load the discount into the Order total. please.

Share this post


Link to post
Share on other sites

Hello

 

I could use help in changing the code for a discount.

 

The default should always be that items are not included in the campaign. Currently, so that all items immediately in action with the code for the discount. I could use the inverse operation to choose which items are included.

 

Can anyone help me?

Share this post


Link to post
Share on other sites

Gang,

 

Total newb here and I'm pretty sure my backup is corrupt so whatever assistance you can provide is greatly appreciated.

 

I tried installing the 3.1.1 full but ran into some trouble. I can't recall exactly what the issue was but we reverted to backup. All was well.

 

Now that the store is up and running, discount codes were requested again. Instead of going from 3.1.1 again, opted to go from 2.6 and upgrade so I could not any errors.

 

Well boy did I get one. The following appears at the top of every page in the site except checkout:

 

// Discount Code 2.6 - start define('TABLE_CUSTOMERS_TO_DISCOUNT_CODES', 'customers_to_discount_codes'); define('TABLE_DISCOUNT_CODES', 'discount_codes'); // Discount Code 2.6 - end

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ab20256/public_html/shop/includes/database_tables.php:67) in /home/ab20256/public_html/shop/includes/functions/sessions.php on line 102

// Discount Code 2.6 - start define('TEXT_DISCOUNT', 'Discount'); define('TEXT_DISCOUNT_CODE', 'Discount Code'); // Discount Code 2.6 - end // Discount Code 2.6 - start if (MODULE_ORDER_TOTAL_DISCOUNT_STATUS == 'true') { if (!tep_session_is_registered('sess_discount_code')) tep_session_register('sess_discount_code'); if (!empty($HTTP_GET_VARS['discount_code'])) $sess_discount_code = tep_db_prepare_input($HTTP_GET_VARS['discount_code']); if (!empty($HTTP_POST_VARS['discount_code'])) $sess_discount_code = tep_db_prepare_input($HTTP_POST_VARS['discount_code']); } // Discount Code 2.6 - end

 

Checkout brings the following error:

 

// Discount Code 2.6 - start define('TABLE_CUSTOMERS_TO_DISCOUNT_CODES', 'customers_to_discount_codes'); define('TABLE_DISCOUNT_CODES', 'discount_codes'); // Discount Code 2.6 - end

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ab20256/public_html/shop/includes/database_tables.php:67) in /home/ab20256/public_html/shop/includes/functions/sessions.php on line 102

// Discount Code 2.6 - start define('TEXT_DISCOUNT', 'Discount'); define('TEXT_DISCOUNT_CODE', 'Discount Code'); // Discount Code 2.6 - end // Discount Code 2.6 - start if (MODULE_ORDER_TOTAL_DISCOUNT_STATUS == 'true') { if (!tep_session_is_registered('sess_discount_code')) tep_session_register('sess_discount_code'); if (!empty($HTTP_GET_VARS['discount_code'])) $sess_discount_code = tep_db_prepare_input($HTTP_GET_VARS['discount_code']); if (!empty($HTTP_POST_VARS['discount_code'])) $sess_discount_code = tep_db_prepare_input($HTTP_POST_VARS['discount_code']); } // Discount Code 2.6 - end

Warning: Cannot modify header information - headers already sent by (output started at /home/ab20256/public_html/shop/includes/database_tables.php:67) in /home/ab20256/public_html/shop/includes/functions/general.php on line 45

 

 

Any advice? Really need this fixed as soon as possible but I'm at a complete loss.

 

Thanks!

Edited by Mike Owings

Share this post


Link to post
Share on other sites

I thought this would be a great way to give our club members a discount so I downloaded the add-on and read the readme.txt till I was blue in the face. I installed just the way it said and when I go to install the module I get all of this:

 

Order Total
pixel_trans.gif

Warning
: include(/hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/includes/languages/english/modules/order_total/ot_discount.php) [
]: failed to open stream: No such file or directory in
/hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/admin/modules.php
on line
129

 

Warning
: include() [
]: Failed opening '/hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/includes/languages/english/modules/order_total/ot_discount.php' for inclusion (include_path='.:/usr/local/lib/php-5.2.17/lib/php') in
/hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/admin/modules.php
on line
129

 

Warning
: include(/hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/includes/languages/english/modules/order_total/ot_shipping.php.php) [
]: failed to open stream: No such file or directory in
/hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/admin/modules.php
on line
129

 

Warning
: include() [
]: Failed opening '/hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/includes/languages/english/modules/order_total/ot_shipping.php.php' for inclusion (include_path='.:/usr/local/lib/php-5.2.17/lib/php') in
/hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/admin/modules.php
on line
129

Modules Sort Order Action MODULE_ORDER_TOTAL_DISCOUNT_TITLE
icon_arrow_right.gif
Low Order Fee
icon_info.gif
Module Directory: /hermes/bosweb26d/b447/ipw.leathernecksswflcom/public_html/leathernecks/store/includes/modules/order_total/
MODULE_ORDER_TOTAL_DISCOUNT_TITLE

MODULE_ORDER_TOTAL_DISCOUNT_DESCRIPTION

Can someone give me some help on this, and please keep in mind I am fairly new to all of this.

Share this post


Link to post
Share on other sites

Gang,

 

Total newb here and I'm pretty sure my backup is corrupt so whatever assistance you can provide is greatly appreciated.

 

I tried installing the 3.1.1 full but ran into some trouble. I can't recall exactly what the issue was but we reverted to backup. All was well.

 

Now that the store is up and running, discount codes were requested again. Instead of going from 3.1.1 again, opted to go from 2.6 and upgrade so I could not any errors.

 

Well boy did I get one. The following appears at the top of every page in the site except checkout:

 

// Discount Code 2.6 - start define('TABLE_CUSTOMERS_TO_DISCOUNT_CODES', 'customers_to_discount_codes'); define('TABLE_DISCOUNT_CODES', 'discount_codes'); // Discount Code 2.6 - end

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ab20256/public_html/shop/includes/database_tables.php:67) in /home/ab20256/public_html/shop/includes/functions/sessions.php on line 102

// Discount Code 2.6 - start define('TEXT_DISCOUNT', 'Discount'); define('TEXT_DISCOUNT_CODE', 'Discount Code'); // Discount Code 2.6 - end // Discount Code 2.6 - start if (MODULE_ORDER_TOTAL_DISCOUNT_STATUS == 'true') { if (!tep_session_is_registered('sess_discount_code')) tep_session_register('sess_discount_code'); if (!empty($HTTP_GET_VARS['discount_code'])) $sess_discount_code = tep_db_prepare_input($HTTP_GET_VARS['discount_code']); if (!empty($HTTP_POST_VARS['discount_code'])) $sess_discount_code = tep_db_prepare_input($HTTP_POST_VARS['discount_code']); } // Discount Code 2.6 - end

 

Checkout brings the following error:

 

// Discount Code 2.6 - start define('TABLE_CUSTOMERS_TO_DISCOUNT_CODES', 'customers_to_discount_codes'); define('TABLE_DISCOUNT_CODES', 'discount_codes'); // Discount Code 2.6 - end

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ab20256/public_html/shop/includes/database_tables.php:67) in /home/ab20256/public_html/shop/includes/functions/sessions.php on line 102

// Discount Code 2.6 - start define('TEXT_DISCOUNT', 'Discount'); define('TEXT_DISCOUNT_CODE', 'Discount Code'); // Discount Code 2.6 - end // Discount Code 2.6 - start if (MODULE_ORDER_TOTAL_DISCOUNT_STATUS == 'true') { if (!tep_session_is_registered('sess_discount_code')) tep_session_register('sess_discount_code'); if (!empty($HTTP_GET_VARS['discount_code'])) $sess_discount_code = tep_db_prepare_input($HTTP_GET_VARS['discount_code']); if (!empty($HTTP_POST_VARS['discount_code'])) $sess_discount_code = tep_db_prepare_input($HTTP_POST_VARS['discount_code']); } // Discount Code 2.6 - end

Warning: Cannot modify header information - headers already sent by (output started at /home/ab20256/public_html/shop/includes/database_tables.php:67) in /home/ab20256/public_html/shop/includes/functions/general.php on line 45

 

 

Any advice? Really need this fixed as soon as possible but I'm at a complete loss.

 

Thanks!

 

 

I'm a doofus - i tracked down the trailing spaces and improper insertion of changed code.

 

I tell you, when you take the time to double-check instead of going into blue-assed panic mode, this add-on really is a joy to work with.

 

Sorry for the temporary idiocy.

Share this post


Link to post
Share on other sites

I have installed the Discount Code as per instructions, but it don't seem to be working.

When you go through the checkout process, it does not deduct the discount percentage from the total..

 

Can anyone help me with this..

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