close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

have used coupon post to db and orders table

Thread began 10/22/2012 12:37 pm by watercolor346374 | Last modified 10/25/2012 11:45 am by Jason Byrnes | 2443 views | 9 replies |

watercolor346374

have used coupon post to db and orders table

Hello,
Doing groupon type coupon with daily candy. They will assign the code numbers, to purchasers and I will post the info into DB daily_candy. Database is set up as well as coupon. I tested it and it works as it should. I need to add the following. In the coupon DB, I have a column called couponUsed. It is a tiny integer and now set to 1, this indicates it is not used. When the customer uses the coupon, I want 0 in the couponUsed field and the code posted to the customer's order in the orders DB, the column is called couponCode. This can be done at final checkout to paypal.
If the customer comes back and attempts to reuse the code, is there a way to check the DB and if there is a 0 by the code have a message pop up saying, That coupon has been redeemed"?
Thank you for your help.
Karen

Sign in to reply to this post

watercolor346374

Db driven coupon, now is all messed up

Hello,
I thought the coupon was working and now it is all messed up. It gives a discount no matter what is put into the txtPromoCode box. My database is daily_candy. The columns are:
couponId--key
couponCat --planning to delete this column
couponCode-- number that customer puts in
couponAmt --how much it is worth in dollars
couponUsed --a tiny int 1 is not used 0 is used
I have attached my files.
It was working last week and now it is not, as I said no matter what number I put in the box I get a discount.
Thank you for your help.

Doing groupon type coupon with daily candy. They will assign the code numbers, to purchasers and I will post the info into DB daily_candy. Database is set up as well as coupon. I tested it and it works as it should. I need to add the following. In the coupon DB, I have a column called couponUsed. It is a tiny integer and now set to 1, this indicates it is not used. When the customer uses the coupon, I want 0 in the couponUsed field and the code posted to the customer's order in the orders DB, the column is called couponCode. This can be done at final checkout to paypal.
If the customer comes back and attempts to reuse the code, is there a way to check the DB and if there is a 0 by the code have a message pop up saying, That coupon has been redeemed"?
Thank you for your help.
Karen

Attached Files
ecart_files.zip
Sign in to reply to this post

Jason ByrnesWebAssist

once the session for the promo code is set it wont clear if you enter an invalid promo code.

Where you say it was working before and now it is not, i think the real problem is that you are not closing the browser between tests.

the code that sets the session:

php:
<?php

if (!session_id()) session_start();
if(!(
$totalRows_rsCoupon == 0))     {
  
$_SESSION["PromoAmount"] = "".$row_rsCoupon['couponAmt']  .""
}
?>



will only set it if the entered code is found in the database. If you resubmit a bad promo code, it wont clear the previous one. to clear the previous code, you need to close the browser completely between tests.


as for single use coupons:

You would need to add a PromoCode column to the orders table, then update the Store Order Summary behavior on the Confirm page to store the coupon that is used for the order.

you can then update the rsCouponCode recordset to use a joined query

SELECT * FROM daily_candy
WHERE couponCode
OUTER JOIN orders
ON daily_candy.couponCode = orders.couponCode
WHERE daily_candy.couponCode = paramCouponCode1 AND orders.couponCode <> paramCouponCode2


Parameters:
name:paramCouponCode1
Type: text
Default value: -1
Runtime Value = $_POST['txtPromoCode']

name:paramCouponCode2
Type: text
Default value: -1
Runtime Value = $_POST['txtPromoCode']


This will return the promo code only if it does not exist in the orders table already

Sign in to reply to this post

watercolor346374

Thank you Jason, I will try that and let you know how it turns out. I did test it in a new browser and it did work. I am noticing that the discounted price is not being shown in the orders db, it shows the full price. What am I missing in the checkout file?
Thank you,
K

Sign in to reply to this post

Jason ByrnesWebAssist

the discount is reflected in the Order Grand Total, make sure the store order details is capturing the grand total.

Sign in to reply to this post

watercolor346374

Hi Jason,
Everytime I changed the total to grandtotal, and test the page I get a message about that variable. I do get the total pre shipping, tax and discount. So I added the discount amount and I can work around this.
I attempted to use the info you gave me re the couponCode on the confirm page. When I added the recordset rsCouponCode to the confirm.php, I got the message that the rs was not ok, so it would not add to the page. Is there a way to do the following: Once check out is clicked the coupon code gets posted to the orders table with the other info. Then on the daily_candy db, the column couponUsed (which is a tiny int. and set to 1) gets a 0 (this would indicate that it has been used. On the cart page when the customer enters the coupon code, if the column couponUsed is 0 they get a message that the coupon has been used.
Thank you,
K

Sign in to reply to this post

watercolor346374

Hi Jason,
Well the good news is I got the coupon code to post to the orders table by carrying the PromoCode session forward into the confirm.php. Do you think that that is ok? It works.

Now, In confirm.php, how would I now make a 0 post into the daily_candy database where that couponCode was? and in the cart.php have that column checked for the 0 and if it is present in the couponCode column have an echo of "Sorry that code was redeemed"
Thank you,
K

Sign in to reply to this post

Jason ByrnesWebAssist

  Now, In confirm.php, how would I now make a 0 post into the daily_candy database where that couponCode was? and in the cart.php have that column checked for the 0 and if it is present in the couponCode column have an echo of "Sorry that code was redeemed"
Thank you,
K  




That is not really the right way to go about it, use 2 recordsets, one to query the daily_candy table for the entered coupon code, and a second to query the orders table for the coupon code.

using this rout, you would add a second set session value behavior, use the recordset for the orders table Is Not Empty Trigger and set the coupon session to an empty value, make sure this come after the original set session code.

you can also use a show region behavior to show your message about the coupon being used if the orders recordset is not empty.

Sign in to reply to this post

watercolor346374

HI Jason,
What you say makes sense, instead of having a useCoupon column in the table etc. I'm not sure that I am getting this correct. I added the two recordsets to cart.php
1. rsCandyCoupon from daily_candy table
2. rsCandyOrders from the orders table
3. Session variable usedCoupon
Still allows the coupon to go through even though it is listed in the orders table in couponCode column
Also I notice that sometimes my rsCoupon will change from form variable = txtPromoCode to entered value = a blank. So I have to keep checking it.
Can you take a look at my cart script?
Thank you,
K

Attached Files
cart.php.zip
Sign in to reply to this post

Jason ByrnesWebAssist

I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
supporthistory.php

If anyone else is experiencing this same issue, please append to this thread.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...