/// <summary>
    /// Returns order item edit action HTML.
    /// </summary>
    protected string GetOrderItemEditAction(object value)
    {
        var  editOrderItemElemHtml = "";
        Guid itemGuid = ValidationHelper.GetGuid(value, Guid.Empty);

        if (itemGuid != Guid.Empty)
        {
            var item = ShoppingCartInfoProvider.GetShoppingCartItem(ShoppingCart, itemGuid);

            // Hide edit link for attribute product option
            if (item.IsAttributeOption)
            {
                return(null);
            }

            var query       = "itemguid=" + itemGuid + GetCMSDeskShoppingCartSessionNameQuery();
            var editItemUrl = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.OrderItemProperties", 0, query);

            var priceDetailButton = new CMSGridActionButton
            {
                IconCssClass  = "icon-edit",
                IconStyle     = GridIconStyle.Allow,
                ToolTip       = GetString("shoppingcart.editorderitem"),
                OnClientClick = ScriptHelper.GetModalDialogScript(editItemUrl, "OrderItemEdit", 720, 420)
            };

            editOrderItemElemHtml = priceDetailButton.GetRenderedHTML();
        }

        return(editOrderItemElemHtml);
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (ShoppingCart != null)
        {
            // Do not update order if it is already paid
            if (OrderIsPaid)
            {
                return;
            }

            if (selectCurrency.SelectedID > 0)
            {
                ShoppingCart.ShoppingCartCurrencyID = selectCurrency.SelectedID;
            }

            // Skip if method was called by btnAddProduct
            if (sender != btnAddProduct)
            {
                foreach (GridViewRow row in gridData.Rows)
                {
                    // Get shopping cart item Guid
                    Guid cartItemGuid = ValidationHelper.GetGuid(((Label)row.Cells[1].Controls[1]).Text, Guid.Empty);

                    // Try to find shopping cart item in the list
                    var cartItem = ShoppingCartInfoProvider.GetShoppingCartItem(ShoppingCart, cartItemGuid);
                    if (cartItem != null)
                    {
                        // If product and its product options should be removed
                        if (((CMSCheckBox)row.Cells[4].Controls[1]).Checked && (sender != null))
                        {
                            // Remove product and its product option from list
                            ShoppingCartInfoProvider.RemoveShoppingCartItem(ShoppingCart, cartItemGuid);

                            if (!ShoppingCartControl.IsInternalOrder)
                            {
                                // Log activity
                                if (!cartItem.IsProductOption && !cartItem.IsBundleItem)
                                {
                                    var logger = Service.Resolve <IEcommerceActivityLogger>();
                                    logger.LogProductRemovedFromShoppingCartActivity(cartItem.SKU, cartItem.CartItemUnits, ContactID);
                                }

                                // Delete product from database
                                ShoppingCartItemInfoProvider.DeleteShoppingCartItemInfo(cartItem);
                            }
                        }
                        // If product units has changed
                        else if (!cartItem.IsProductOption)
                        {
                            // Get number of units
                            int itemUnits = ValidationHelper.GetInteger(((TextBox)(row.Cells[7].Controls[1])).Text.Trim(), 0);
                            if ((itemUnits > 0) && (cartItem.CartItemUnits != itemUnits))
                            {
                                // Update units of the parent product
                                ShoppingCartItemInfoProvider.UpdateShoppingCartItemUnits(cartItem, itemUnits);
                            }
                        }
                    }
                }
            }

            var couponCode = txtCoupon.Text.Trim();

            if (!string.IsNullOrEmpty(couponCode))
            {
                if (!ShoppingCart.AddCouponCode(couponCode))
                {
                    // Discount coupon is not valid
                    lblError.Text = GetString("ecommerce.error.couponcodeisnotvalid");
                }
                else
                {
                    txtCoupon.Text = string.Empty;
                }
            }

            ShoppingCart.Evaluate();
            ReloadData();

            // Inventory should be checked
            checkInventory = true;
        }
    }