close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Coupon Codes and eCart6

Thread began 3/26/2014 9:25 am by larry268887 | Last modified 3/28/2014 12:20 pm by Jason Byrnes | 2149 views | 12 replies |

larry268887

Coupon Codes and eCart6

I've added a coupon code form to my cart page and everything works correctly as far as applying the correct discount when the correct discount code is entered. What I can't do is validate if a correct coupon code is entered. How can I validate when someone enters a coupon code if it is a valid coupon code and if it isn't valid display a message not a valid coupon code?

Sign in to reply to this post

Jason ByrnesWebAssist

you would need to hand code this:


<?php
if(isset($_POST['CouponCode']) {
if($_POST['CouponCode'] != "ValidCode") {
$_SESSION['badCoupon'] = "yes";
} else {
$_SESSION['badCoupon'] = "no";
}
}
?>



then to show the error:

<?php if(isset($_SESSION['badCoupon']) && $_SESSION['badCoupon'] == "yes")) echo "you entered an incorrect coupon code"; ?>

Sign in to reply to this post

larry268887

Lets say that I have 3 valid coupon codes: 1.airflight 2.facebook 3.pinterest How should the top portion of the code be written?

Sign in to reply to this post

Jason ByrnesWebAssist

if(($_POST['CouponCode'] != "airflight") || ($_POST['CouponCode'] != "facebook") || ($_POST['CouponCode'] != "pinterest")) {

Sign in to reply to this post

larry268887

I can't seem to get it to work can you take a look at the code and tell me what I'm doing wrong?

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

Jason ByrnesWebAssist

you have the code inside a validatonb show if:

<?php
if (ValidatedField('cart','cart')) {
if ((strpos((",".ValidatedField("cart","cart").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<?php
if(isset($_POST['Coupon_Code'])) {
if(($_POST['Coupon_Code'] != "airflight") || ($_POST['Coupon_Code'] != "facebook") || ($_POST['Coupon_Code'] != "pinterest")) {
$_SESSION['badCoupon'] = "yes";
} else {
$_SESSION['badCoupon'] = "no";
}
}
?>
<?php if(isset($_SESSION['badCoupon']) && ($_SESSION['badCoupon'] == "yes")) echo "you entered an incorrect coupon code"; ?>
<span class="serverInvalidState" id="Coupon_Code_ServerError">Please enter valid coupon code</span>
<?php //WAFV_Conditional cart.php cart(1:)
}
}
}?>

it needs to be outside of the validation show if.

Sign in to reply to this post

larry268887

Moved it outside and I'm getting closer but whether you out in a valid code or invalid it says the coupon code is invalid. Here is the code:
<?php
if(isset($_POST['Coupon_Code'])) {
if(($_POST['Coupon_Code'] != "airflight") || ($_POST['Coupon_Code'] != "facebook") || ($_POST['Coupon_Code'] != "pinterest")) {
$_SESSION['badCoupon'] = "yes"; }
else {
$_SESSION['badCoupon'] = "no";
}
}
?>

Can't figure out why all coupon codes are invalid.

Sign in to reply to this post

Jason ByrnesWebAssist

I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post

larry268887

Here is the requested info

Sign in to reply to this post

larry268887

When you compare to only one coupon code everything works fine.

<?php
if(isset($_POST['Coupon_Code'])) {
if($_POST['Coupon_Code'] != "airflight") {
$_SESSION['badCoupon'] = "yes";
} else {
$_SESSION['badCoupon'] = "no";
}
}
?>
This code works fine. Its the code for three coupon codes that isn't working

<?php
if(isset($_POST['Coupon_Code'])) {
if(($_POST['Coupon_Code'] != "airflight") || ($_POST['Coupon_Code'] != "facebook") || ($_POST['Coupon_Code'] != "pinterest")) {
$_SESSION['badCoupon'] = "yes"; }
else {
$_SESSION['badCoupon'] = "no";
}
}
?>

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