Redeeming coupon code from URL?

Views: 9,202

Results 1 to 14 of 14
06 Feb 2011, 07:49
#1
cindy2010 avatar

cindy2010

Zen Follower

Join Date:
Apr 2010
Posts:
100
Plugin Contributions:
0

Redeeming coupon code from URL?

Guess this should be simple but can't find it in google: Is there a way that customer can redeem a coupon by simply coming to my site via a URL and I put the coupon code in the URL? Like: https://www.mysite.com?coupon=ABCDEFG Then the ABCDEFG will appear in the checkout page.

Thanks.

07 Feb 2011, 16:11
#2
nidkolio avatar

nidkolio

New Zenner

Join Date:
May 2009
Posts:
55
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

Looking for exact same thing!

07 Feb 2011, 16:16
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Redeeming coupon code from URL?

If you send yourself a Discount Coupon from your email, you will see how the URL is written for this to work ...

10 Feb 2011, 10:58
#4
nidkolio avatar

nidkolio

New Zenner

Join Date:
May 2009
Posts:
55
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

Thanks a lot, will try this!

10 Feb 2011, 11:07
#5
nidkolio avatar

nidkolio

New Zenner

Join Date:
May 2009
Posts:
55
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

OK, tryed it...

We're pleased to offer you a Store Coupon You can redeem this coupon during checkout. Just enter the code in the box provided, and click on the redeem button. The coupon code is Дарение The coupon is valid between 02.02.2011 and 02.02.2012 Don't lose the coupon code, make sure to keep the code safe so you can benefit from this special offer. Visit us at http://www.pet-paw.com/

This is the text in the email that i got. I do not see URL with coupon code in it... Any suggestion where i am wrong? Thanks

10 Feb 2011, 14:30
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Redeeming coupon code from URL?

Well ... actually I goofed ... :blush:

I was thinking of Gift Certificates not Discount Coupons ...

Discount Coupons are redeemed on the checkout_payment page ...

There isn't, at this time, a way to redeem Discount Coupons from another location ...

You can do a lookup for a Discount Coupon to see if it is valid and its restrictions ...

The biggest problem is that a Discount Coupon requires valid products in the shopping cart, before it can be redeemed ...

Then, once redeemed, if the content of the shopping cart changes and there are no longer valid products in the cart then the Discount Coupon is removed ...

10 Feb 2011, 15:22
#7
nidkolio avatar

nidkolio

New Zenner

Join Date:
May 2009
Posts:
55
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

Humm, im a bit confused already...

There is an option Customers Referral Status. As i understand, this referral thing works with coupon code. When new costumer register on the page there is a field where this coupon can be set. So we know this costumer is referred by someone. The deal is that the easyest way is to place this code in the url. So when someone join this field will be already filled instead of manually typing it.

Now there is an option to add this manually, but from advertise point of view the person who sends new costumers to my shop will not be sure that they will be referred by him, because they simply can be too lazy to add this code in the field.

Hope that i wrote this understandable... huh

Thanks

10 Feb 2011, 16:31
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Redeeming coupon code from URL?

This would all have to be customize ...

Currently, the Referral Code, even if used as a Discount Coupon still would need to be added during the Checkout on the checkout_payment ...

So you would need a link in an email to take the customer to the Login ...

That link would need to include the Discount Coupon code that could then be used for the referral code to pre populate the field ...

You could take it a step further that on the successful creation of an account that the Referral code is used to set the Discount Coupon ... but if there are any restrictions on the Discount Coupon it will fail as there is nothing in the shopping cart to validate the Discount Coupon ...

The other way the Referral can be done is to use the first Discount Coupon that the customer uses in the checkout ... this would then only need one entry of the Discount Coupon, providing the Shopping Cart Products qualify for the Discount Coupon ...

Another way to do all of this is to build in a check for the URL in the email where there is a code passed and that code is tested for being a valid Discount Coupon code ...

If valid, then per-populate the Referral Code on the create account and set that as the current Discount Coupon coupon_id on the session variable: $_SESSION['cc_id']

then when the customer gets to the Checkout and the checkout_payment if the Discount Coupon is not valid for the Order it would be removed ...

This would take quite a bit of customization but it could be done ...

Granted, this would only work if the customer immediately creates an account, unless you take it a step further and try to set the $_SESSION['cc_id']

from the referral code on the URL and it stays active during the session and the customer would eventually create an account and use that ...

However, if the customer's session times out, then the: $_SESSION['cc_id']

would be lost and the customer would need to manually enter the Discount Coupon code during the create account and/or during the checkout_payment ...

10 Feb 2011, 17:18
#9
nidkolio avatar

nidkolio

New Zenner

Join Date:
May 2009
Posts:
55
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

Thank you for your answer and time! It sounds to complicated for me. My idea was to know if there is something already build in... will figure out his one in the future:-) Thanks again

01 Dec 2011, 22:55
#10
noknots avatar

noknots

New Zenner

Join Date:
Aug 2011
Posts:
12
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

I added this (early on in me execution line):

$sopDiscountCode = $_GET["sopCode"]; //sopCode is what is in my url ***.php?sopCode=balance2011

if (isset($_GET["sopCode"])) { if ($_GET["sopCode"]=='balance2011') {$_SESSION['sopdcode']=1; //1 is the code from the admin consol for that string $_SESSION['sopddesc']="*** 20% off Active<br />Care of Tom Turner"; //this is what shows on the website} if ($_GET["sopCode"]=='relief2011') {$_SESSION['sopdcode']=3; $_SESSION['sopddesc']="*** 20% off Active<br />care of Tom Slusser";} }

if (isset($_SESSION['sopdcode'])) {$sopDiscountCode= $_SESSION['sopdcode'];}

//I then place at the top of: templates/[myTemplate]/templates/checkout_shipping_default.php:

$_SESSION['cc_id']=$sopDiscountCode;

//Which seems to do the trick, hack as it may be..

//We are doing all this for QR Code discounts ##

//hope this helps

07 Dec 2011, 15:59
#11
elius avatar

elius

New Zenner

Join Date:
Jul 2008
Posts:
1
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

@NoKnots: This is exactly what I was looking for: adding value to the use of QR codes. (more than just redirecting to your site)

however, I tried to implement your instructions, so far nothing really happens:

What do you mean "(early on in me execution line)" In which file is that? the index.php or another?

What's the output/use for "1 is the code from the admin consol for that string"

Where does the text show "*** 20% off Active<br />care of Tom Slusser"

Also: you should place the } before the // in ...Tom Turner"; //this is what shows on the website} This becomes Tom Turner";} //this is what shows on the website otherwise you get an error further on in the PHPcode.

Thanks for clarifying a little more! Greetings,

Erik, www.oranjedas.nl

14 Dec 2011, 20:01
#12
noknots avatar

noknots

New Zenner

Join Date:
Aug 2011
Posts:
12
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

Disclaimer: I am sure I will get some of the technical aspects wrong, so take what I say with a grain of salt. I am not a zencart or php expert.

Most of what I have seen in zencart and php for that matter is php running as a scripting platform (vs Object Oriented). eg. a page is called say index.php and then in for the most part code is executed in a straight line via includes and function calls. So yes index.php should work for this. In my case I have added my code to set context in html_header.php primarily because is it in the common directory and executes just prior to any content being sent to the client. Anyway it has worked for me this way. Also nice in that much of the zencart context has been set at that point.

My code has changed from my last post now reads:

//start html_header.php mod

$sopDiscountCode = $_GET["sopCode"];

if (isset($_GET["sopCode"]) and (strlen($_GET["sopCode"])>0)) { if ($_GET["sopCode"]=='balance2011') {$_SESSION['sopdcode']=1; $_SESSION['cc_id']=1; $_SESSION['sopddesc']="*** 20% off Active<br />Care of Tom Turner"; $sopDiscountCode=1; } if ($_GET["sopCode"]=='relief2011') {$_SESSION['sopdcode']=3; $_SESSION['cc_id']=3; $_SESSION['sopddesc']="*** 20% off Active<br />care of Tom Slusser"; $sopDiscountCode=3; } } else { if (strlen($_SESSION['sopdcode'])>0) {$_SESSION['cc_id']=$_SESSION['sopdcode']; $sopDiscountCode= $_SESSION['sopdcode'];} }

if((strlen($_SESSION['cc_id'])>0 )&& ($_SESSION['sopdcode']!=$_SESSION['cc_id']) ) {if ($_SESSION['cc_id']==1) {$_SESSION['sopdcode']=1; $_SESSION['sopddesc']="*** 20% off Active<br />Care of Tom Turner"; $sopDiscountCode=1; } if ($_SESSION['cc_id']==3) {$_SESSION['sopdcode']=3; $_SESSION['sopddesc']="*** 20% off Active<br />care of Tom Slusser"; $sopDiscountCode= 3; } unset($_SESSION['sopdcode']); }

//end html_header

then in modules/order_total/ot_coupon.php

I modified the beginning of the function collect_posts() as follows:

//start function edit

function collect_posts() {

global $db, $currencies, $messageStack, $order;

global $discount_coupon;

// remove discount coupon by request

if (isset($_POST['dc_redeem_code']) && strtoupper($_POST['dc_redeem_code']) == 'REMOVE') {

  unset($_POST['dc_redeem_code']);
  
  unset($_SESSION['cc_id']);

  //sop edit 
  unset($_SESSION['sopdcode']);
  unset($_SESSION['sopddesc']);
  unset($sopDiscountCode);

// end function edit - the rest of this function remains unchanged

again this is definitely a hatchet job but for us it works. Hope this helps others.

http://www.massageblocks.com

24 Feb 2013, 20:15
#13
nootropics avatar

nootropics

New Zenner

Join Date:
Jan 2013
Posts:
5
Plugin Contributions:
0

Re: Redeeming coupon code from URL?

Hello! After viewing the thread here: http://www.zen-cart.com/showthread.php?173762-Redeeming-coupon-code-from-URL

I am having a bit of a problem :blink: I am trying to retrieve a coupon code from the URL .

I entered in the index.php this code

 
// this is for http://localhost/?coupon=spring123

$CouponCode = stripslashes($_GET["coupon"]);
 if ($CouponCode=='')	
 echo 'NO COUPON CODE';

 echo mysql_real_escape_string($CouponCode);
 
?>
  1. How do I exactly verify if the code is valid ?
  2. How to I enter the code in the box at the end of shipping ? Maybe I should include the coupon code in the session .... ?

Thanks!

02 Sep 2013, 02:58
#14
responsivezc avatar

responsivezc

New Zenner

Join Date:
Aug 2013
Posts:
85
Plugin Contributions:
8

Re: Redeeming coupon code from URL?

Hello guys,

I know this post is old but I would like to tell you that I have uploaded the following plugin: Redeem Coupon from URL