Jump to content



* * * - - 3 votes

[add-on] Discount Code (support)


  • Please log in to reply
141 replies to this topic

#1   high-quality-php-coding

high-quality-php-coding
  • Members
  • 1 posts
  • Real Name:John Doe

Posted 11 May 2010 - 01:40 PM

Discount code module allows you to assign a discount code to a product, category (for each product of this category) and total order. You can specify a fixed discount rate or a percentage of the total order, set expiration date and minimum order amount for a discount code.

#2   kdupuis

kdupuis
  • Members
  • 1 posts
  • Real Name:Kevin Dupuis

Posted 12 May 2010 - 08:10 PM

Hi,

I downloaded the Discount Code contribution and really like it.  There is one problem with calculating taxes.
When I have a discount code set up for 10% on a category.  It does not calculate the tax portion properly.

Example:

Subtotal: $590.00
Discount:  $59.00
5% Tax:    $29.50
Total:    $560.50

The tax amount should be 26.55 and the Total should be $557.55

Here is the ot_tax.php as requested:



<?php
/*
  $Id: ot_tax.php 1739 2007-12-20 00:52:16Z hpdl $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright © 2003 osCommerce

  Released under the GNU General Public License
*/

  class ot_tax {
    var $title, $output;

    function ot_tax() {
      $this->code = 'ot_tax';
      $this->title = MODULE_ORDER_TOTAL_TAX_TITLE;
      $this->description = MODULE_ORDER_TOTAL_TAX_DESCRIPTION;
      $this->enabled = ((MODULE_ORDER_TOTAL_TAX_STATUS == 'true') ? true : false);
      $this->sort_order = MODULE_ORDER_TOTAL_TAX_SORT_ORDER;

      $this->output = array();
    }

    function process() {
      global $order, $currencies;

      reset($order->info['tax_groups']);
      while (list($key, $value) = each($order->info['tax_groups'])) {
        if ($value > 0) {
          $this->output[] = array('title' => $key . ':',
                                  'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']),
                                  'value' => $value);
        }
      }
    }

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

      return $this->_check;
    }

    function keys() {
      return array('MODULE_ORDER_TOTAL_TAX_STATUS', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER');
    }

    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 ('Display Tax', 'MODULE_ORDER_TOTAL_TAX_STATUS', 'true', 'Do you want to display the order tax value?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER', '3', 'Sort order of display.', '6', '2', now())");
    }

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

#3   james_uk

james_uk
  • Members
  • 5 posts
  • Real Name:James Hatton

Posted 13 May 2010 - 04:03 PM

Hi, I've chosen osCommerce because of this module (no other open source shopping cart system features a per-product discount). Potentially great module so thanks in advance but it does not work for me yet.

I installed the module to the instructions exactly and activated it. I have entered a discount code against a product and run through the purchase of that product. The discount line is not appearing in the 'Order Confirmation' screen of the checkout process and the total is not affected by the discount.

Is anybody else having an issue with this module? Any advice appreciated...

#4   james_uk

james_uk
  • Members
  • 5 posts
  • Real Name:James Hatton

Posted 13 May 2010 - 04:32 PM

Okay, self-solved, for the moment. I played around with the 'sort order' of the 'Order Total Modules' section of the module administration. I positioned this module as no.4 and re-positioned the total as no. 5

#5   robweidman

robweidman
  • Members
  • 14 posts
  • Real Name:RobW

Posted 13 May 2010 - 10:00 PM

I too like the concept of the module. However, my site utilizes the one-page checkout, as do many others.  Can anyone offer advice as to where to place the appropriate code on the checkout_shipping and/or checkout_confirmation pages?  Thanks.

#6   cantex123

cantex123
  • Members
  • 3 posts
  • Real Name:Tans

Posted 19 May 2010 - 06:07 PM

View Postrobweidman, on 13 May 2010 - 10:00 PM, said:

I too like the concept of the module. However, my site utilizes the one-page checkout, as do many others.  Can anyone offer advice as to where to place the appropriate code on the checkout_shipping and/or checkout_confirmation pages?  Thanks.


I installed the module to the instructions exactly and activated it. I have entered a discount code against a product and run through the purchase of that product. The discount line is not appearing in the 'Order Confirmation' screen of the checkout process and the total is not affected by the discount. i change the sort order too, but still not working.

Help anyone,

Thanks in advanced.

#7   Dettels

Dettels
  • Members
  • 2 posts
  • Real Name:Detlef

Posted 27 May 2010 - 06:23 PM

Hello
This time my experience:
Discount on category -> tax calculation works with version 2.4.
Discounts on individual products -> tax calculation does not work
Fixed amount as a discount (eg 5 €) on total -> tax calculation does not work
Display value after coupon: ---> There is always value without tax
In short, the part is not usable.

Greetings

#8   GraphicsGuy

GraphicsGuy
  • Members
  • 1,144 posts
  • Real Name:Mike
  • Gender:Male
  • Location:Tennessee

Posted 24 August 2010 - 05:46 AM

I just installed it and by adjusting the sort order it works.  But I did notice that it does not seem to work with percentage discounts. (unless I am missing something)  For example I can enter 1.00 and it deducts $1 properly and it shows up everywhere it should.  But if I enter 10% as the discount, it accepts it in the admin panel, accepts the code at checkout but doesn't make any entries on the summary, invoice or email and doesn't deduct from the total.
Rule #1:  Without exception, backup your database and files before making any changes to your files or database.
Rule #2:  Make sure there are no exceptions to Rule #1.

#9   rhubarb

rhubarb
  • Members
  • 177 posts
  • Real Name:Nick
  • Location:Southampton UK

Posted 24 August 2010 - 09:24 AM

In admin > Vouchers/Coupons > Coupon Admin there's a 'Coupon Description' which has a note along side that says "A description of the coupon for the customer", but where does the customer see this appear?

#10   GraphicsGuy

GraphicsGuy
  • Members
  • 1,144 posts
  • Real Name:Mike
  • Gender:Male
  • Location:Tennessee

Posted 24 August 2010 - 01:30 PM

View Postrhubarb, on 24 August 2010 - 09:24 AM, said:

In admin > Vouchers/Coupons > Coupon Admin there's a 'Coupon Description' which has a note along side that says "A description of the coupon for the customer", but where does the customer see this appear?

That sounds like a different (similar) contribution.  Perhaps CCGV (Credit Class Gift Voucher).  The Discount Code contrib's admin panel section is titled Discount Codes and I don't see any place to enter coupon description.
Rule #1:  Without exception, backup your database and files before making any changes to your files or database.
Rule #2:  Make sure there are no exceptions to Rule #1.

#11   nacid

nacid
  • Members
  • 10 posts
  • Real Name:Nencho

Posted 25 August 2010 - 01:56 PM

how do I apply the code and see it without going to checkout_confirmation page?

NN

#12   GraphicsGuy

GraphicsGuy
  • Members
  • 1,144 posts
  • Real Name:Mike
  • Gender:Male
  • Location:Tennessee

Posted 25 August 2010 - 02:52 PM

View Postnacid, on 25 August 2010 - 01:56 PM, said:

how do I apply the code and see it without going to checkout_confirmation page?

NN

As far as I can tell, this contrib doesn't have that ability.  It is pretty simple code and bare bones functions.  That is actually why I am using it.  I have quite a few mods in my store and adding this one avoided some of the complications the other more robust ones were.

If you wanted to add that feature to this, it shouldn't be too complicated for a osc experienced coder to create a java script to display it on page and update the total and then put an "apply" button next to the code entry box that would trigger the javascript.
Rule #1:  Without exception, backup your database and files before making any changes to your files or database.
Rule #2:  Make sure there are no exceptions to Rule #1.

#13   nacid

nacid
  • Members
  • 10 posts
  • Real Name:Nencho

Posted 25 August 2010 - 03:07 PM

View PostGraphicsGuy, on 25 August 2010 - 02:52 PM, said:

As far as I can tell, this contrib doesn't have that ability.  It is pretty simple code and bare bones functions.  That is actually why I am using it.  I have quite a few mods in my store and adding this one avoided some of the complications the other more robust ones were.

If you wanted to add that feature to this, it shouldn't be too complicated for a osc experienced coder to create a java script to display it on page and update the total and then put an "apply" button next to the code entry box that would trigger the javascript.

thanks for the prompt reply.
code is working fine. just you are not able to see the discount unless put credit card details and go to the next page.

#14   nacid

nacid
  • Members
  • 10 posts
  • Real Name:Nencho

Posted 25 August 2010 - 03:38 PM

View PostGraphicsGuy, on 25 August 2010 - 02:52 PM, said:

As far as I can tell, this contrib doesn't have that ability.  It is pretty simple code and bare bones functions.  That is actually why I am using it.  I have quite a few mods in my store and adding this one avoided some of the complications the other more robust ones were.

If you wanted to add that feature to this, it shouldn't be too complicated for a osc experienced coder to create a java script to display it on page and update the total and then put an "apply" button next to the code entry box that would trigger the javascript.


Any idea why it's not working with PayPal IPN v2.3.4.6 payment module?

Paypal get the total without the discount.

Thanks

#15   GraphicsGuy

GraphicsGuy
  • Members
  • 1,144 posts
  • Real Name:Mike
  • Gender:Male
  • Location:Tennessee

Posted 25 August 2010 - 04:48 PM

View Postnacid, on 25 August 2010 - 03:38 PM, said:

Any idea why it's not working with PayPal IPN v2.3.4.6 payment module?

Paypal get the total without the discount.

Thanks

I haven't tested mine on PayPal.  Just guessing here, but maybe the PayPal IPN module takes the subtotal, shipping and tax amounts and calculates its own total.  In which case the IPN module would have to be modified.  

Or the simple workaround would be to change the sort order in the admin->modules->Order Total page so that the Discount Code module is ahead of the subtotal. (that is assuming that the reason for the PayPal problem is that it is calculating its own final total.

Of course you would have to check your local sales tax laws before changing when the sales tax is calculated.  Some jurisdictions require discounts to be deducted after tax is computed so that the customer is paying sales tax on the full amount.  In determining that you may have to consider how you will be using the discount.  If it is promotional discount or coupon, I think most jurisdictions will allow pretax deducting of the discount.  But if it is described as a rebate almost all jurisdictions require it to be deducted after tax computation.
Rule #1:  Without exception, backup your database and files before making any changes to your files or database.
Rule #2:  Make sure there are no exceptions to Rule #1.

#16   rickharr

rickharr
  • Members
  • 3 posts
  • Real Name:Rick Harrison

Posted 31 August 2010 - 05:08 PM

Opps wrong add on support thread
Rick H

Edited by rickharr, 31 August 2010 - 05:11 PM.


#17   GraphicsGuy

GraphicsGuy
  • Members
  • 1,144 posts
  • Real Name:Mike
  • Gender:Male
  • Location:Tennessee

Posted 31 August 2010 - 05:37 PM

I got curious and clicked the contribution author's profile.  I hate to say it but it kind of looks like this contribution has been orphaned.  The author "high-quality-php-coding" registered May 10 and posted the contribution.  On May 11th set up this support thread.  On May 16th posted an update to the contribution.  And hasn't returned to this forum since May 17th in spite of issues posted on the thread.

It's a shame.  It is a nice simple approach to coupon codes with a neat clean admin screen.
Rule #1:  Without exception, backup your database and files before making any changes to your files or database.
Rule #2:  Make sure there are no exceptions to Rule #1.

#18   Shadow-Lord

Shadow-Lord
  • Members
  • 149 posts
  • Real Name:Shadow
  • Gender:Male

Posted 24 September 2010 - 02:47 PM

Hi,

Great Addon.

There is one problem, the discount isn't been carried on to PayPal.
Is there any fix for this please.

Thanks.

#19   kevinb456

kevinb456
  • Members
  • 23 posts
  • Real Name:Kevin

Posted 25 September 2010 - 08:03 PM

It seems the creator is still actively working on this mod - just not avid forum goers like us :) check out http://high-quality-php-coding.com/discount_code_module_for_oscommerce.html  where there are updates 2.3, 2.4 and 2.5 which together add some very nice additions and tax fixes (not sure if they work 100% i haven't tested).

I'm getting my shop setup for 1st october and this is one of the last hurdles (getting it to work with paypal IPN 2.3.4.6) - so hopefully I'll find a solution... I'll keep you all updated of course.

Otherwise this is a very well constructed mod and I likey likey!

#20   kevinb456

kevinb456
  • Members
  • 23 posts
  • Real Name:Kevin

Posted 25 September 2010 - 09:10 PM

I've found the solution to making this mod work with Paypal IPN 2.3.4.6  :thumbsup:
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.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_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.

Edited by kevinb456, 25 September 2010 - 09:12 PM.