close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Coupon Code: compare entered value with value from database

Thread began 5/03/2015 7:55 am by info4753 | Last modified 5/06/2015 9:46 am by Ray Borduin | 1238 views | 4 replies |

info4753

Coupon Code: compare entered value with value from database

I've applied a coupon code and would like to compare the value that has been entered by the customers via form field (and saved into a session variable) with a value from a database table instead of a manually entered value in the cart definition. Is that possible?

Sign in to reply to this post

Ray BorduinWebAssist

Yes... just filter a recordset with the value saved in the session and then save another session variable with the coupon amount from the returned recordset.

Use the coupon amount variable when defining your cart discount and that should complete the loop so that your coupons can be database driven.

Sign in to reply to this post
Did this help? Tips are appreciated...

info4753

Thanks Ray.

You mean like this:

On the cart page:

Filter recordset:

<?php
$rsEventsAktion = new WA_MySQLi_RS("rsEventsAktion",$db_i,1);
$rsEventsAktion->setQuery("select `events`.`EventAktionCode` AS `GutscheinCode`,`events`.`EventAktionVon` AS `EventAktionVon`,`events`.`EventAktionBis` AS `EventAktionBis`,`events`.`EventTitel` AS `EventTitel` from `events` where (now() between `events`.`EventAktionVon` and `events`.`EventAktionBis`) AND `events`.`EventAktionCode` = ?");
$rsEventsAktion->bindParam("s", "".(isset($_SESSION['GutscheinCode'])?$_SESSION['GutscheinCode']:"") ."", "-1"); //WAQB_Param1
$rsEventsAktion->execute();
?>

Define 2nd Session:

<?php
@session_start();
if("" == "") {
$_SESSION["GutscheinCode2"] = "".($rsEventsAktion->getColumnVal("GutscheinCode")) ."";
}
?>


In the cart definition:

//eCart Rule
function WAEC_eCart_DegustationWeine10() {
$totalDiscount = 0;
if (true && (($this->ConditionalTotal("Quantity", "GutscheinCodeArtikel", "1") > 0) && ((isset($_SESSION['GutscheinCode'])?$_SESSION['GutscheinCode']:"") == "".$_SESSION['GutscheinCode2'] .""))) {
$totalDiscount += ($this->ConditionalTotal("TotalPrice", "GutscheinCodeArtikel", "1") * 0.1);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule



Can I also use the value of the filtered recordset directly like this?

//eCart Rule
function WAEC_eCart_DegustationWeine10() {
$totalDiscount = 0;
if (true && (($this->ConditionalTotal("Quantity", "GutscheinCodeArtikel", "1") > 0) && ((isset($_SESSION['GutscheinCode'])?$_SESSION['GutscheinCode']:"") == "".($rsEventsAktion->getColumnVal("GutscheinCode")) .""))) {
$totalDiscount += ($this->ConditionalTotal("TotalPrice", "GutscheinCodeArtikel", "1") * 0.1);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule

Sign in to reply to this post

Ray BorduinWebAssist

You can't refer to the recordset in the cart rule because the recordset may not be on the page. You should only use the Session variable.

Sign in to reply to this post
Did this help? Tips are appreciated...

info4753

That worked. Thanks a lot.

I can even use the two sessions to check if the entered code is correct or not.

Sign in to reply to this post

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