Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Coupon Addon - questions/suggestions


Recommended Posts

Hi everybody


You'll have to excuse any mistakes I make as I am new to osCommerce.


After adding the Coupon Class to a site we are building I found a few problems that I thought I should pass on. Now these may have been created because of something I missed (I copied the code across line by line as we are testing and developing with oscommerce 2.1 and I didn't want to overwrite anything)


Problem 1 - Multiple Updates after preview page

Everytime I edited or added a new coupon and viewed it and then clicked on a heading within the left column of links the page tried to update the database again - often returning a duplicate key of '' or updating my newly created coupon to have blank field entries.


I fixed this by adding the following line of code just after the database updates have been completed. This clears the action code out of the url and stops the page from completing multiple submits when you try to navigate to other pages with the admin site.




Problem 2 - Date Formatting

I soon found an error with the inserting of dates into the database. Being a New Zealand company we have our dates set to display (DATE_FORMAT) as d/M/Y. Because there is a line within the coupin_admin page that uses DATE_FORMAT to format the coupon_finishdate and coupon_startdate variables before they are placed into a hidden field for passing to the tep_date_raw function we had some problems with dates not being inserted into the database when the day was greater than 12 - dates with days under 12 were inserted back to front. To fix this I am now passing my dates as:


echo tep_draw_hidden_field('coupon_startdate_month', $HTTP_POST_VARS['coupon_startdate_month']);

echo tep_draw_hidden_field('coupon_startdate_day', $HTTP_POST_VARS['coupon_startdate_day']);

echo tep_draw_hidden_field('coupon_startdate_year', $HTTP_POST_VARS['coupon_startdate_year']);

echo tep_draw_hidden_field('coupon_finishdate_month', $HTTP_POST_VARS['coupon_finishdate_month']);

echo tep_draw_hidden_field('coupon_finishdate_day', $HTTP_POST_VARS['coupon_finishdate_day']);

echo tep_draw_hidden_field('coupon_finishdate_year', $HTTP_POST_VARS['coupon_finishdate_year']);


and inserting them into the database as:

'startdate' => $HTTP_POST_VARS['coupon_startdate_year'] . $HTTP_POST_VARS['coupon_startdate_month']. $HTTP_POST_VARS['coupon_startdate_day'],

                                 'finishdate' => $HTTP_POST_VARS['coupon_finishdate_year'] . $HTTP_POST_VARS['coupon_finishdate_month']. $HTTP_POST_VARS['coupon_finishdate_day'],



I also have updated the code so that the select list displays the current date for start date and finish date dropdowns by default on the insert page and still retains the dates pulled from the database on the edit page. This would be a nice feature for an update.


My final question (sorry this takes so long) is about the coupon_active field and type field. I am getting an error on deletion of a coupon saying that coupon_active does not exist. I can't find reference to this field in the SQL update code. I am about to add the field in but wish to know if it is not in there for a reason and also what the type field is used for and what are the normal settings for it.


Any help would be appreciated.

Link to comment
Share on other sites

Okay sorry I found the sql code for the coupon_active field. Yes I had searched the forum for it but found it after submitting my question. Ignore that part of my question.




Link to comment
Share on other sites

If you have any success at all I'd be suprised. The coupon/credit class code was written specifically for v2.2.


Good luck on getting it working with 2.1

Trust me, I'm an Accountant.

Link to comment
Share on other sites

  • 2 weeks later...

Yes Yes Yes... :oops:


Sorry bout that - Yes we were using 2.2 (we are only new to this and downloaded a few versions within a short time), yes it is all working fine now.


Thanks for that - what a great contribution - exactly what we needed. Great work.


Now - back to working out how to upgrade that invoice system...

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.

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