Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

I did a manual install..since I'm not fluent in sql. (wouldn't know where to begin)

 

I've made the suggested mods :

 

tep_db_input($_POST["coupons_description"]) . "', '" .

tep_db_input($_POST["coupons_discount_percent"]) ."', " .

 

Still no ability to create a coupon. I'm getting this error:

 

1146 - Table 'libidolondon_com_-_store.discount_coupons' doesn't exist

 

select count(*) as total from discount_coupons cd

 

Step 3 of the instructions tells you that you need to run two statements via phpMyAdmin (generally available via your host's control panel). You need to select your OSC database, then click the SQL tab along the top. Copy and paste the following two statements into the text area provided and click Go.

 

**************** STEP 2 ****************

Create the database tables

 

Run these statements via the SQL tab in phpMyAdmin.

 

 

CREATE TABLE discount_coupons (

coupons_id varchar(32) NOT NULL default '',

coupons_description varchar(64) NOT NULL default '',

coupons_discount_percent decimal(7,4) default NULL,

date_start datetime default NULL,

date_end datetime default NULL,

max_use int(3) NOT NULL default 0,

min_order decimal(15,4) NOT NULL default '0.0000',

PRIMARY KEY (coupons_id)

);

 

CREATE TABLE discount_coupons_to_orders (

discount_coupons_to_orders_id int(11) NOT NULL auto_increment,

coupons_id varchar(32) default NULL,

orders_id int(11) default '0',

PRIMARY KEY (discount_coupons_to_orders_id),

KEY coupons_id (coupons_id)

);

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Great contrib, thinking about installing it after the next update is released... one question I have is, I run the SPPC mod... will that conflict/affect it in any way?

 

thanks!

Link to comment
Share on other sites

Here's one I haven't seen mentioned. Thanks for this Contribution first of all. It looks like exactly what I need. Here's the problem...

 

Everything seems to Install fine, but when I go to Catalog> there isn't a tab for Discount Coupons. I know this must be something simple I'm overlooking. Help ;) . Thanks.

Link to comment
Share on other sites

Step 3 of the instructions tells you that you need to run two statements via phpMyAdmin (generally available via your host's control panel). You need to select your OSC database, then click the SQL tab along the top. Copy and paste the following two statements into the text area provided and click Go.

 

 

Thanks so much KGT!!! Works like a dream now. (Just needed that SQL rock dropped on my head. :)

 

Kelly

Link to comment
Share on other sites

Great contrib, thinking about installing it after the next update is released... one question I have is, I run the SPPC mod... will that conflict/affect it in any way?

 

I cannot say for sure, but I strongly suspect it won't interfere at all. When you insert the code, just double check that the code specified to be replaced is exactly the same in your file as it is in the text file. Most of the code for coupon codes is purely added and doesn't replace existing code.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hi! I'm so happy to see this contribution - I've been working on something similar, but kept getting sidetracked. One odd bit of behaviour I'm noticing, though...

 

I've put the first coupon in and everything seems to work fine. However, if I put in an invalid code, it returns to the payment page, shows the error message as part of the URL, but does not actually display it anywhere on the screen. Any ideas? Thank you!

Link to comment
Share on other sites

Hi,

 

this is a good contribution. I need a quick help though.

 

In Admin -> coupons.php, when I create a new Discount Coupon, the date shows is in MM/DD/YYYY.

 

How do I change to DD/MM/YYYY? My entire site is DD/MM/YYY. If i can mod this discount code contribution to be DD/MM/YYYY, that would be perfect.

 

Can someone please help n advise?

 

Many thanks.

Link to comment
Share on other sites

I had isntall this great contribution.... and seems to be working very good but some problem

 

the display text for "warnig" apper only on the browser address and no in the box down??? anything else it's just perfect.

 

besides I would like to know if there is the posibility to create coupons with fixed amount this will be nice.

 

thank you

Link to comment
Share on other sites

I had isntall this great contribution.... and seems to be working very good but with some problem

 

the display text for "warnig" apper only on the browser address and no in the box down??? anything else it's just perfect.

 

besides I would like to know if there is the posibility to create coupons with fixed amount this will be nice.

 

thank you

Link to comment
Share on other sites

I had isntall this great contribution.... and seems to be working very good but with some problem

 

the display text for "warnig" apper only on the browser address and no in the box down??? anything else it's just perfect.

 

besides I would like to know if there is the posibility to create coupons with fixed amount this will be nice.

 

thank you

Link to comment
Share on other sites

Hi,

 

this is a good contribution. I need a quick help though.

 

In Admin -> coupons.php, when I create a new Discount Coupon, the date shows is in MM/DD/YYYY.

 

How do I change to DD/MM/YYYY? My entire site is DD/MM/YYY. If i can mod this discount code contribution to be DD/MM/YYYY, that would be perfect.

 

Can someone please help n advise?

 

Many thanks.

 

 

Hi, even if u uninstall Discount Coupon from Order total modules,.. "Do you have a promotional code or discount coupon?" still appear in checkout_payment.php?

 

Anyone has any ideas how to change the date format for this contribution?

 

many thanks

Link to comment
Share on other sites

I have installed the Coupons add-on which I really love only there is a small problem; everything works fine until the shopping cart is being passed through to PayPal. There I see the price without the discount.

 

Do you have any idea what I'm doing wrong ? :blink:

Link to comment
Share on other sites

I've just installed this contribution. When I went to Admin>Catalog>Discount Coupons, I got this message:

 

 

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 '-20, 20' at line 1

 

select * from discount_coupons cd order by cd.date_end, date_start limit -20, 20

 

 

I looked into the code in coupons.php and could not find the 'limit -20, 20'.

 

 

Anyone can help me with this?

Link to comment
Share on other sites

I've just installed this contribution. When I went to Admin>Catalog>Discount Coupons, I got this message:

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 '-20, 20' at line 1

 

select * from discount_coupons cd order by cd.date_end, date_start limit -20, 20

I looked into the code in coupons.php and could not find the 'limit -20, 20'.

Anyone can help me with this?

 

This is not contribution related but rather a problem with the older version of osc. See this page, fix at the end:

http://www.oscommerce.com/community/bugs,1605

 

ideally you should download the latest osc update and upgrade your store that includes this fix.

http://www.oscommerce.com/solutions/downloads

Link to comment
Share on other sites

This is not contribution related but rather a problem with the older version of osc. See this page, fix at the end:

http://www.oscommerce.com/community/bugs,1605

 

ideally you should download the latest osc update and upgrade your store that includes this fix.

http://www.oscommerce.com/solutions/downloads

 

That solved the problem. Thanks a lot. I already made too many changes to the code and it will be hard for me to aplly all the patches.

 

Thanks.

Link to comment
Share on other sites

Did you download the latest? There was a bugfix for that problem.

 

Kgt, I download and installed your newest update package ot_discount_coupon_codes_1.2_1, I have the same problem, looks like the "Max Use" doesn't work.

 

Hopefully, you can double check the codes.

 

Thank you very much for this nice addon!!!

Link to comment
Share on other sites

Kgt, I have a suggestion about the codes for Max Use in your addon.

 

The codes you wrote for Max Use is:

if( $row['max_use'] != '0' ) { //if max_use==0, then use is unlimited, otherwise, we need to verify the customer hasn't used this coupon more than max_use times
				$check_use_query = tep_db_query($sql = "select count(*) as cnt from ".TABLE_ORDERS." o inner join ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o on dc2o.orders_id=o.orders_id and o.customers_id = 2 and dc2o.coupons_id='".tep_db_prepare_input( $HTTP_POST_VARS['coupon'] )."'");
				$use = tep_db_fetch_array( $check_use_query );
				if( $row['max_use'] > $use['cnt'] ) $passed = true; //proceed if max_use is greater than the number of times this customer has used the code 
				else {
					$error_message[] = sprintf( ENTRY_DISCOUNT_COUPON_USE_ERROR, $use['cnt'], $row['max_use'] ); //display the error message for number of times used
				}

 

I don know why it doesn't work at all, but looks like if we try to get the value of how many times the coupon had been used, the program need to go throw orders and discount_coupons_to_orders 2 tables.

 

If there are a lot of orders in those 2 tables, it will take longer time to match those orders.

 

I think the better way to count how many times the coupon already been used is to create a new table call "coupons_used_times" (with coupon and times )only for counting the times. so $row['max_use'] just need to match the value from the "coupons_used_times".

 

Sorry about my poor English and knowledge on PHP. Just for an idea

Link to comment
Share on other sites

Kgt, I have a suggestion about the codes for Max Use in your addon.

 

I don know why it doesn't work at all, but looks like if we try to get the value of how many times the coupon had been used, the program need to go throw orders and discount_coupons_to_orders 2 tables.

 

If there are a lot of orders in those 2 tables, it will take longer time to match those orders.

 

I think the better way to count how many times the coupon already been used is to create a new table call "coupons_used_times" (with coupon and times )only for counting the times. so $row['max_use'] just need to match the value from the "coupons_used_times".

 

Sorry about my poor English and knowledge on PHP. Just for an idea

 

 

Darren, you are correct that the join will slow things down if both tables are large. You have brought to my attention that an index should be placed on the orders table for the customers_id and an index on the discount_coupons_to_orders table for the orders_id.

 

Remember that the max_use limits the usage per customer. This means we must have some way to join the coupon code usage to a customer. We can create a table called customer count with a coupon id and a customer_id and an order count, but this removes another possibility that others have requested: a way to see which coupons were used on which orders. DCC is an order_total module, which means it goes in the orders_total table as a text line with an amount. A report would require searching the field for the text value, which would be slower than a join on integer values. It seems to me a toss-up which would be better. The code only does a join if 1) the customer uses a coupon code and 2) the code has a max_use that's no unlimited.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Kgt, I download and installed your newest update package ot_discount_coupon_codes_1.2_1, I have the same problem, looks like the "Max Use" doesn't work.

 

Darren, didn't even notice this until I saw the code you posted. It doesn't work because the customer id got hard-coded!

 

Line 82 of checkout_confirmation.php replace:

 

$check_use_query = tep_db_query($sql = "select count(*) as cnt from ".TABLE_ORDERS." o inner join ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o on dc2o.orders_id=o.orders_id and o.customers_id = 2 and dc2o.coupons_id='".tep_db_prepare_input( $HTTP_POST_VARS['coupon'] )."'");

with

$check_use_query = tep_db_query($sql = "select count(*) as cnt from ".TABLE_ORDERS." o inner join ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o on dc2o.orders_id=o.orders_id and o.customers_id = '".$customer_id."' and dc2o.coupons_id='".tep_db_prepare_input( $HTTP_POST_VARS['coupon'] )."'");

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

In Admin -> coupons.php, when I create a new Discount Coupon, the date shows is in MM/DD/YYYY.

 

How do I change to DD/MM/YYYY? My entire site is DD/MM/YYY. If i can mod this discount code contribution to be DD/MM/YYYY, that would be perfect.

 

For those that wish to use other date formats, you may download the latest which should work. You will need to enter dates in the same format you display them - ie, if you display dates as dd/mm/yyyy, you need to enter them the same way, not as dd/mm/yy, for example. This is set by DATE_FORMAT_SHORT and DATE_FORMAT in includes/languages/english.php (or your corresponding language file).

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hi! I'm so happy to see this contribution - I've been working on something similar, but kept getting sidetracked. One odd bit of behaviour I'm noticing, though...

 

I've put the first coupon in and everything seems to work fine. However, if I put in an invalid code, it returns to the payment page, shows the error message as part of the URL, but does not actually display it anywhere on the screen. Any ideas? Thank you!

 

Do you have a modified header.php that does not contain some version of this code?

 

<?php
 if (isset($HTTP_GET_VARS['error_message']) && tep_not_null($HTTP_GET_VARS['error_message'])) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr class="headerError">
<td class="headerError"><?php echo htmlspecialchars(urldecode($HTTP_GET_VARS['error_message'])); ?></td>
 </tr>
</table>
<?php
 }

 if (isset($HTTP_GET_VARS['info_message']) && tep_not_null($HTTP_GET_VARS['info_message'])) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr class="headerInfo">
<td class="headerInfo"><?php echo htmlspecialchars($HTTP_GET_VARS['info_message']); ?></td>
 </tr>
</table>
<?php
 }
?>

 

If you have a template and have completely redone your includes/header.php, you might be missing this code. This contribution assumes the standard error message code works.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

I have installed the Coupons add-on which I really love only there is a small problem; everything works fine until the shopping cart is being passed through to PayPal. There I see the price without the discount.

 

 

You're not going to see the order total line for the discount coupon in Paypal. Paypal displays the subtotal, the shipping, and the total. You should make sure you have "Display Subtotal with Applied Discount" set to true in Modules > Order Total > Discount Coupons. Verify that your subtotal displayed by Paypal is the item total - discount + taxes, and the total is the subtotal + shipping.

Contributions

 

Discount Coupon Codes

Donations

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