Gift Certificate Activation

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
page8worker
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Wed Dec 10, 2008 11:08 am

Gift Certificate Activation

Post by page8worker » Wed Dec 17, 2008 1:12 pm

Is it possible to have a gift certificate automatically activated if/when the payment method is approved, or the order is marked as paid?

Thanks,
Jackie Apshire Jr.
Page8 Studios.com
Specializing in eCommerce Integrations

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: Gift Certificate Activation

Post by sohaib » Thu Dec 18, 2008 5:27 am

This has been fixed in our development (and will be available in 7.2) ... but a workaround for now could be to write some custom code in 'CheckedOut' event handler on 'One Page Checkout' page.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Gift Certificate Activation

Post by mazhar » Thu Dec 18, 2008 6:08 am

Edit your ConLib/OnePageCheckout.ascx.cs file and change the Checkedout method to look like as below

Code: Select all

 void CheckedOut(object sender, CheckedOutEventArgs e)
    {
..............................................................................
..............................................................................
..............................................................................

 //Activate GiftCertificate 
        Order order = OrderDataSource.Load(e.OrderId, false);
        if (order != null)
        {
            if (order.OrderStatus.Name == "Completed")
            {
                foreach (OrderItem orderItem in order.Items)
                {
                    if (orderItem.OrderItemType == OrderItemType.Product)
                    {
                        if (orderItem.Product.IsGiftCertificate)
                        {
                            GiftCertificateCollection giftCertificates = GiftCertificateDataSource.LoadForOrderItem(orderItem.OrderItemId);

                            if (giftCertificates.Count > 0)
                            {
                                IGiftCertKeyProvider provider = new DefaultGiftCertKeyProvider();
                                foreach (GiftCertificate giftCertificate in giftCertificates)
                                {   
                                    giftCertificate.SerialNumber = provider.GenerateGiftCertificateKey();
                                    giftCertificate.AddActivatedTransaction();
                                    giftCertificate.Save();
                                }
                            }
                        }
                    }
                }
            }
        }
}

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: Gift Certificate Activation

Post by heinscott » Thu Dec 18, 2008 7:39 am

Ah, nice! Thanks Mazhar... This answers a question I had about where to adjust an Inventory History table I was working on. Didn't know that the order # was available before the reciept page.
Thanks!

Scott

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Gift Certificate Activation

Post by AbleMods » Thu Dec 18, 2008 11:57 am

No way - the stored order is available in onepagecheckout??

News to me too - all sorts of new doors open up :twisted:
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

page8worker
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Wed Dec 10, 2008 11:08 am

Re: Gift Certificate Activation

Post by page8worker » Wed Jan 14, 2009 10:56 pm

Sorry for the late response; I've been out of town for the holidays. I just wanted to say thank you for your help with the matter, and I'll give it a try as soon as I get a chance.

Thanks again,
Jackie Apshire Jr.
Page8 Studios.com
Specializing in eCommerce Integrations

Post Reply