stop purchase if subscription exists

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
mezojeff
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 27
Joined: Fri Jan 08, 2010 7:23 am

stop purchase if subscription exists

Post by mezojeff » Tue Apr 13, 2010 9:43 am

What would be the best way to do this? We'd like to give the user a warning if they are attempting to purchase a subscription that they are already subscribed to. Thanks!

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

Re: stop purchase if subscription exists

Post by mazhar » Wed Apr 14, 2010 8:36 am

You can place some alert on product details page for subscription item. For example following code checks on product detail that this item is been already subscribed or not and if its not expired then show the customer some text saying its been already subscribed.

Code: Select all

int productId = PageHelper.GetProductId();
        foreach (Subscription subscription in Token.Instance.User.Subscriptions)
        {
            if (productId == subscription.ProductId && subscription.ExpirationDate > DateTime.Now)
                Response.Write("Already purchased this subscription");
        }

Post Reply