Page 1 of 1

stop purchase if subscription exists

Posted: Tue Apr 13, 2010 9:43 am
by mezojeff
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!

Re: stop purchase if subscription exists

Posted: Wed Apr 14, 2010 8:36 am
by mazhar
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");
        }