close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

adding coupon dynamically

Thread began 9/20/2016 8:03 am by Jose | Last modified 9/21/2016 1:15 pm by Ray Borduin | 3200 views | 19 replies |

Jose

adding coupon dynamically

Hello, I followed this tutorial to add coupon codes from database (First off, you should follow the solution recipe for static coupon codes to get coupon codes working. That tutorial can be found In the Solution Recipes section of the eCart Support Page titled "Creating a Coupon system for your eCart store":
ecart/


To convert that to be database driven:

1) Create a table in your database to hold the coupon codes. it should have a structure similar to:
couuponID - Auto Number, Primary key Column.
couponCode - varchar
couponAmount - double


To add a coupon code of "test" that will give a 10% discount, you would create the follwoing record:
couponID | couponCode | couponAmount
1 | test | 0.10

2) Next is to add a recordset to the page to lookup the coupon amount based on the code the user enters.

On the server behaviors panel, click the plus button and select Recordset. In Simple view, set the record set to use the coupon table we created. Set the name of the recordset to "rsCoupon" In the Filtering Section, set it to filter the couponCode column Equal to the Form Variable txtPromoCode, this is name of the text box created in the coupon code system tutorial.

3) Now we need to create another session variable to hold the discount amount. On the server behaviors panel, click the plus button and select eCart -> General -> Set Session Value. Set the trigger to "recordset rsCoupon Not Empty". Set the name of the session variable to "PromoAmount". Click the lightning bolt next to value, expand the rsCoupon recordset and select the couponAmount column.

4) The PromoCode session variable needs to be modified as well. Set the trigger to "recordset rsCoupon Not Empty" so it will only get set if the promcode sexists in the database.

5) The last step is to modify the Promotional Discount rule in eCart. Remove the "If Session variable == WebAssist" triger.

Add a new trigger "Session variable exists "PromoCode""

Add another trigger "Session variable exists "PromoAmount""

Then Modify the charge rule "Bases on Cart SubTotal "Times" "$_SESSION['PromoAmount']"

so that the discount will use the value stored in the session variable from the database.) I did almost but at step 3 I lost myself so please I would like you explend a little bit what this line means (Set the trigger to "recordset rsCoupon Not Empty".) I have recordset srCoupon but I don't find the this "Not Empty"

Sign in to reply to this post

Ray BorduinWebAssist

You should have "not empty" triggers in your set session value server behavior. Make sure you are using a standard recordset and not MySQLi.

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

Jose

Ok I understand now. But, for example which I have to set. Any post or it should be different? I talking about the first field. Because the other two are very clear I only need to know what goes in the first Tigger

Sign in to reply to this post

Ray BorduinWebAssist

Are you still referring to the trigger for setting the PromoCode session? it should be set to: "recordset rsCoupon Not Empty"

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

Jose

Yes, but this is what I don't understand "recordset rsCoupon Not Empty" when I expand to Tigger to I can't find this "recordset rsCoupon Not Empty" I find rsCoupon but Not Empty I don't find that

Sign in to reply to this post

Ray BorduinWebAssist

This is the Trigger field? I see it in mine. Does the recordset show in the Server Behaviors panel?

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

Jose

Yes, it shows all three fields I have. For example: Id field, varchar field and double field. Question. Do I need separate form? Because I just use the ecart form and I add two more things. Example: one input and one button

Sign in to reply to this post

Ray BorduinWebAssist

This is the "Save in Session" server behavior? Can you send a screen shot?

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

Jose

I am not at home now but I will send you a screenshot tomorrow and you see what it's missing when you have time.

Sign in to reply to this post

Jose

Hello Ray, I am sending the screen shot so you can see the code better. I included a screen shot of variable session

Attached Files
cart.php
eCart_PHP.php
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...