Marking Products private (Off the site) after OrderPaid

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
MMIKAL
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Thu Mar 11, 2010 9:30 am

Marking Products private (Off the site) after OrderPaid

Post by MMIKAL » Wed Jun 23, 2010 6:38 pm

We carry unique products, so we need to take the product OFF the site after an order is placed and paid.
(We set the Status trigger to De-Stock after order is paid and the Instock to 1 for every product and allow backorder is Off.)

What would be the best way to do that ?

We have created a database INSERT trigger on the orderItems table, so when a product is inserted in the orderItems table, the trigger will go and mark the product in Products table Private. It works fine, but most of the times it somehow empties the basket/Cart and when the customer wants to check out it shows "your cart is empty". We could not see the relationship.



Appriciate any help.

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

Re: Marking Products private (Off the site) after OrderPaid

Post by mazhar » Thu Jun 24, 2010 4:31 am

Instead of writing database trigger, put some code to handle this. In your ConLib/OnePageCheckout .acx.cs file locate CheckedOut event handler then place following code block just above the closing brace of IF block in this function.

Code: Select all

Order order = OrderDataSource.Load(e.OrderId, false);
            if (order.OrderStatus.Name == "Paid")
            {
                foreach (OrderItem orderItem in order.Items)
                {
                    if (orderItem.OrderItemType == OrderItemType.Product && orderItem.Product != null)
                    {
                        orderItem.Product.Visibility = CommerceBuilder.Catalog.CatalogVisibility.Private;
                        orderItem.Product.Save();
                    }
                }
            }
Where replace the word Paid with name of your desired order status for which you want to hide the products.

Post Reply