close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Gift Certificates (Part 2)

Thread began 10/27/2009 5:31 pm by scott351953 | Last modified 11/09/2009 5:51 pm by Eric Mittman | 1439 views | 7 replies |

scott351953

Gift Certificates (Part 2)

Ok... Now that I have all my gift certificates in as products and no shipping is applied to these items in the cart, the next part of this journey involves the coupon or gift certificate code.

I need to be able to generate some kind of random code that is emailed to the customer in the receipt (also stored in the DB) and can be later typed in by the user at checkout to apply the gift certificate amount purchased.

I want to go about this the simplest way possible... What is the best way to get started?

Also, I am using Powerstore 1.0 and I have the ecart extension.

Sign in to reply to this post

Eric Mittman

The generating a random number bit is the key to this. There is support for random number generation in PHP but it is not a feature of eCart. We do have a tool that will create a random value that fits your specs, it is Security Assist. With this too you would use the 'random password' binding to generate a random string.

You may also be able to use the session id since it should be random but I don't think this is the most secure way to go.

The idea is that you would generate this random number during the checkout and store it in a session variable. You can store the number in your order details table to record it. You would then sent it out in an email to the user. Our Universal Email tool can handle the creation of the emailing script for you on this. Here is some more info about both of these tools:

SecurityAssist:
securityassist/

Universal Email:
universal-email/

Sign in to reply to this post

scott351953

Thats what I thought... I have security assist & universal email as well and I have seen the "randon password" binding before in the panel. I probably need to break this into a few parts. Here is a more specific question:

The only way I can think to do this, is to have a seperate code generated for each item in the cart (including gift certificates and products, even though this would not be required for these shippable products) then save them in the order details table.

How would I just generate the code for the gift certificates? (Also, I want to make sure they can add multiple gift certificates to the cart... so each would need its own code.)

Sign in to reply to this post

Eric Mittman

One way that I can think of for you to get the correct random values for the only the gift certificates is to add a column for this value to your cart object, but don't update any of the cart displays to display this value.

Next on your add to cart pages when a user purchases a gift certificate you will have a check in place the checks to see if the item is a gift certificate and if so set this new column to the random password binding.

You then need to update your order details table to have this column also and just bind it with the corresponding cart column value. To account for the multiple gift certificates you would need to ensure that you add new items for these rather than update the quantity, this is in the add to cart server behavior in the bindings under the 'if item in cart' settings. Please post back with any questions you have about any part of this and I will help you with whatever I can.

Sign in to reply to this post

scott351953

Ok, I have added the column in the eCart object. Then when I go to the Add to Cart object, on the bindings tab, I can add the value for the gift certificate code.

I tried to add the "Random Password" (from security assist) after clicking the lighting bolt next on default value for the column. But it is not there. I think I need to add something to the page before I can select this. How do I activate this feature?

Sign in to reply to this post

Eric Mittman

The trick for this part is to add the Security Assist random password binding to the page first. Then you will be able to select this value as a binding, when you select it you will configure the settings of the random string it creates.

Once you have got it all setup you will want to adjust the code where this value is set for the item, you will want to check that it is the correct type of item, unless it is static. If you need some additional help with this or more advice let me know.

Sign in to reply to this post

scott351953

Got it... Now that the random password is added on to the eCart Add to Cart Button in the bindings panel. How do I make the code only appear if it is a gift certificate?

Sign in to reply to this post

Eric Mittman

I think the easiest way to ensure that this code is only added for a gift certificate is to add some custom code to the page where the binding is set in the add to cart server behavior. We should check that the item is a gift card, if it is then we will add the random value to that column in the cart, otherwise just leave it blank. The code will look something like this:

php:
$ATC_itemCode = (is gift certificate)?WA_RandomPassword(6, false, true, true, ""):"";// column binding



This code is setting the column for the cart to either the random password binding that you configured or "" depending on weather or not the condition in the parenthesis is true. In this example I just have (is gift certificate) this will need to be updated with a legit check of the item to see if it a gift certificate. What criteria do you use to determine if it is a gift certificate? Is it the category?

This is just an example but it would look very similar to this for you. If you can post back with the current line of code from your add to cart that is setting this value and also some info about how you determine if the item is a gift certificate I can help you craft what this line will look like exactly.

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