Add Order Number search to all Admin pages

by Joe Payne 22. Julie 2008 00:44
Introduction

This is a quick and dirty one, but oh will it make your day. I don't know about you, but I find myself jumping from order to order and it's always by order number. Well, there really isn't a way to get straight from one order to another by order number. You have to always go back to the main Dashboard and enter the order number there.

So I modified the Admin header navigation control to include an order number field. That way every single page on the Admin side has a box where you can type in any order number and jump straight to the order details page.

Code Changes

Normally I just post the changes to a file. In this case, the file is small so I'm going to post the entire file. That, and I have a dental appointment in 45 minutes :)

Edit the ~/Admin/UserControls/HeaderNavigation.ascx file and replace the entire contents with this code:

Code:
<%@ Control Language="C#" ClassName="HeaderNavigation" EnableViewState="false" %>
<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (Token.Instance.User == null || Token.Instance.User.IsAdmin == false)
        {
            AdminNavigationHeaderPanel.Visible = false;
        }
        else
        {
            OrdersLink.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
            CatalogLink.Visible = (Token.Instance.User.IsInRole(Role.CatalogAdminRoles));
            OrderId.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
            ViewOrderButton.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
        }
    }

    protected void ViewOrderButton_Click(object sender, EventArgs e)
    {
        int tempOrderId = AlwaysConvert.ToInt(OrderId.Text);
        Order order = OrderDataSource.Load(tempOrderId);
        if (order != null)
        {
            Response.Redirect("~/Admin/Orders/ViewOrder.aspx?OrderId=" + tempOrderId.ToString());
        }
        else
        {
            CustomValidator invalidOrderId = new CustomValidator();
            invalidOrderId.ControlToValidate = "OrderId";
            invalidOrderId.ErrorMessage = "*";
            invalidOrderId.Text = "Order number is not valid";
            invalidOrderId.IsValid = false;
            AdminNavigationHeaderPanel.Controls.Add(invalidOrderId);
        }
    }

</script>
<asp:Panel ID="AdminNavigationHeaderPanel" runat="server" >
    <table>
    <tr>
        <td>
       <asp:HyperLink ID="DashboardLink" runat="server" NavigateUrl="~/Admin/Default.aspx" CssClass="dashboard" Text="Dashboard"></asp:HyperLink>
       <asp:HyperLink ID="OrdersLink" runat="server" NavigateUrl="~/Admin/Orders/Default.aspx" CssClass="orders" text="Orders"></asp:HyperLink>
       <asp:HyperLink ID="CatalogLink" runat="server" NavigateUrl="~/Admin/Catalog/Browse.aspx" CssClass="catalog" Text="Catalog"></asp:HyperLink>
       <asp:HyperLink ID="StoreLink" runat="server" NavigateUrl="~/Default.aspx" CssClass="stores" Text="Store"></asp:HyperLink>
       <asp:HyperLink ID="LogoutLink" runat="server" NavigateUrl="~/Logout.aspx" CssClass="logout" Text="Logout"></asp:HyperLink>
       </td>
       <td class="header" align="left" valign="bottom"><asp:Localize ID="ViewOrderNumberCaption" runat="server" Text="View Order:"></asp:Localize><br />
       <asp:TextBox ID="OrderId" runat="server" Width="40px" ValidationGroup="OrderSummary"></asp:TextBox>
        <asp:Button ID="ViewOrderButton" runat="server" ValidationGroup="OrderSummary" OnClick="ViewOrderButton_Click" Text="Go" />
        </td>
   </tr>
    </table>
</asp:Panel>


Save it.

Conclusion

You might notice the text color isn't right. Well, I hate CSS styles and CSS styles hate me. It's mutual and I'm ok with that. If you know how to make two stupid little words show the proper style color from the style sheet, please post it here. Others will be grateful and the score will become CSS 220, Joe 0 :wink:

Tags: , , ,

AC7 Articles

Add pager controls to the category grid page

by Joe Payne 16. Mei 2008 00:08
Introduction
Well, it's been some time since I've done an article. Life has been busy for Solunar.com. I've brought on more staff now helping with backend accounting and order tasks. I just bought a small commercial phone system to support multiple extensions and phone lines to enhance our ability to make/receive customer calls. Life is good. Busy, but good.
I recently had a request to publish a little modification I made to my site some time ago. If you've wandered through my categories, you might have noticed I have paging controls both above and below the product or category images on a category display page. This change was actually pretty easy to accomplish so I will offer it here for all to enjoy.

What to do
My example today involves the CategoryGridPage4.ascx user control. This is the one I use throughout most of my site. The pager control programming is very well designed so it is easy for a programmer to manipulate them on the page. To start, we need to edit the ~/ConLib/CategoryGridPage4.ascx file and find this line of code:
Code:
            <div class="catalogWrapper">


and replace it with this:
Code:
            <div class="catalogWrapper">
                <asp:PlaceHolder ID="PagerPanelUpper" runat="server">
                    <div class="paging">
                        <asp:Repeater ID="PagerControlsUpper" runat="server" OnItemCommand="PagerControls_ItemCommand" EnableViewState="true">
                            <ItemTemplate>
                                <asp:LinkButton ID="PageLink" runat="server" Text='<%#Eval("Text")%>' CommandName="Page" CommandArgument='<%#Eval("PageIndex")%>' Enabled='<%#Eval("Enabled")%>'></asp:LinkButton>
                            </ItemTemplate>
                        </asp:Repeater>
                    </div>
                </asp:PlaceHolder>                   


What that does is create an upper version of the same pager controls that already exist on the bottom of the page. Save the file as this is the only change we need to make to the HTML side of things.

Next, let's edit the ~/ConLib/CategoryGridPage4.ascx.cs file. Here is where we have just a little work to do - we need to configure the extra set of pager controls. Edit the file and look for this code in the BindPagingControls() subroutine (note you might have to expand the PagingControls region by clicking the little 'plus sign' if you use VWD like me). If all else, just search for the text "BindPagingControls":
Code:
            PagerControls.DataSource = pagerLinkData;
            PagerControls.DataBind();
        }
        else
        {
            PagerPanel.Visible = false;
        }


Now replace it with this:
Code:
            PagerControls.DataSource = pagerLinkData;
            PagerControls.DataBind();
            //BEGIN: Solunar Mod
            PagerControlsUpper.DataSource = pagerLinkData;
            PagerControlsUpper.DataBind();
            //END: Solunar Mod

        }
        else
        {
            PagerPanel.Visible = false;
            //BEGIN: Solunar Mod
            PagerPanelUpper.Visible = false;
            //END: Solunar Mod
        }


All done? Good, save the file. Fire up a category page on your site that uses CategoryGridPage4 and see how it looks - paging controls at the top should appear and function identical to those on the bottom.

How it works
On the HTML side, we created a second "area" defined with the name "PagerPanelUpper". In this "area", we simply duplicated the same code used to make the pager controls at the bottom.
On the code side, we assigned a datasource to the new upper pager control, just like the bottom pager control. Then we told IIS to bind that datasource to the control i.e. connect it and initialize it. The really cool part is we're able to use the same programming routines the bottom pager control uses, so there's really no new code. Any future changes we make to the programming of the pager controls will automatically affect both the upper and lower ones.

Conclusion
Every opportunity to improve your site visitor experience is an opportunity to make a sale. By adding additional pager controls to your category pages, you make it easier for customers to navigate the products you sell.

Tags: , ,

AC7 Articles

Add a Delete feature to the Admin Order Summary

by Joe Payne 19. Februarie 2008 00:21
Advisory
Please use extreme caution when using this modification. It is unforgiving. Make a mistake and you're restoring your database. There is no "Undo". Seriously. There is also no "Are you sure?" when using this modification. Real site admins don't need it (plus I don't know how to add one) 

Introduction
There are many times where I have found the need to delete an order. It usually involves my own testing or an unusual payment processing failure.
When an order gets messed up, the customer usually places another order, if they even know there was a problem. Usually this results in 3-4 bad orders on the Admin side. there's no way to delete them, so you're forced to sort "around" them as you work to process your business. It also forces the customer to live with a really confusing order history.

This modification allows the Admin to delete a single or group of orders right from Admin screen using the "Update Selected Orders" feature.

How it works
This modification uses the same concept already built into the Update Selected Orders dropdown. Just click the checkboxes for the orders to delete, select the "Delete" dropdown option and click Go.

Modifications
First make a backup copy of your ~/Admin/Orders/default.aspx and default.aspx.cs files. These are the files we will be changing in this modification.

Edit ~/Admin/orders/Default.aspx file and look for the start of the dropdown list control - here is some of this code:
Code:
                                <asp:DropDownList ID="BatchAction" runat="server">
                                    <asp:ListItem Text=""></asp:ListItem>
                                    <asp:ListItem Text="Process Payment" Value="PAY"></asp:ListItem>
                                    <asp:ListItem Text="Mark Shipped" Value="SHIP"></asp:ListItem>
                                    <asp:ListItem Text="Mark Shipped with Options" Value="SHIPOPT"></asp:ListItem>
                                    <asp:ListItem Text="Cancel" Value="CANCEL"></asp:ListItem>
                                    <asp:ListItem Text="-----------"></asp:ListItem>


Directly below the first "------------" ListItem entry you see, add this code:

Code:
                                    <asp:ListItem Text="* DELETE *" Value="DELETE"></asp:ListItem>
                                    <asp:ListItem Text="-----------"></asp:ListItem>


Save it.

Now edit the ~/Admin/Orders/Default.aspx.cs file. Find the code located in the BatchButton_Click function that looks like this:

Code:
                    case "SHIPOPT":
                        Response.Redirect("Batch/Ship.aspx?orders=" + GetOrderList(orderIds));
                        break;


We need to Insert another CASE section of code like this directly below the "break;" line. So add the following code as described:

Code:
                    case "DELETE":
                        int DelCount = 0;
                        foreach (int orderId in orderIds)
                        {
                            Order order = OrderDataSource.Load(orderId);
                            if (order != null)
                            {
                                order.Delete();
                                messages.Add("Order #" + order.OrderId + " deleted.");
                                DelCount++;
                            }
                        }
                        messages.Add(DelCount + " orders deleted.");
                        break;



Save it.

Testing
It's critical you test this in your development environment first. There is no "Undo" feature - once an order is deleted, it's gone. Note how you can delete one order at a time, or delete multiple orders in a single command. Test both scenarios and confirm the properly selected orders were removed and no others.

Cascade Deletes
Deleting an order cascades through the other files automatically. Payment records, notes and history, shipments etc will also be automatically deleted. There should be no trace of the order left when the command is finished.

Conclusion
Order management is a key point in the business process where mistakes can be made. Clearing out unwanted orders helps the admin keep a clean running store with less potential for errors. It also gives the customer a good looking order history to review their purchases.

Tags: , ,

AC7 Articles

Add an Edit Basket Button on the Admin screen

by Joe Payne 13. Februarie 2008 00:05

Introduction
The purpose of this modification is to give you, the esteemed site admin, the ability to edit the shopping basket of a registered user. Why? Well, I don't really know. But I found a page written to do it and it looks really cool. You want to be a cool site admin, don't you?

Actually it makes a really nice impression with the customer when they are on the phone trying to order something. By handling their basket for them, you encourage them to continue their online experience. This motivates an online checkout instead of the dreaded "Can't I just pay you over the phone" response. It also quite possibly saves the sale.

But I can already do this
Yes, you can create a new order for a customer from the Admin screen. But you cannot edit their existing basket. This can potentially lead to confusion because the customer now has basket items for items they also just ordered. Customers are easily confused, so keeping things simple and painless encourages a return visit.

Gimme
The changes are actually very easy. First make a backup copy of the ~/Admin/People/Users/CurrentBasketDialog.ascx user control.

Now edit the file. Look for this line of code in the Page_Load section near the beginning:

Code:
EditBasketLink.NavigateUrl += _UserId;



Add another line directly below it that looks like this:

Code:
EditBasketLink0.NavigateUrl += _UserId;



So now you should have this:

Code:

EditBasketLink.NavigateUrl += _UserId;
EditBasketLink0.NavigateUrl += _UserId;



Now we need to edit the HTML part of the page, so scroll all the way to the bottom of the file. Find this line:

Code:
        <asp:HyperLink ID="EditBasketLink" runat="server" NavigateUrl="~/Admin/Orders/PlaceOrder1.aspx?UserId=" SkinID="Button" Text="Create Order"></asp:HyperLink>



Replace that line with this exact code:

Code:
        <asp:HyperLink ID="EditBasketLink" runat="server" NavigateUrl="~/Admin/Orders/PlaceOrder1.aspx?UserId=" SkinID="Button" Text="Create Order"></asp:HyperLink>
    &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:HyperLink ID="EditBasketLink0" runat="server" NavigateUrl="~/Admin/People/Users/EditBasket.aspx?UserId=" SkinID="Button" Text="Edit Basket"></asp:HyperLink>



Now save the file. Done!

Testing the changes
Ok, now the fun part. Let's make sure we haven't blown something (else) up. Log into your site and go to the store side. Add some items to your cart. Don't check out.
Click back to the Admin side and log in to the Admin side with the same account you just used to add basket items. Click on the People menu and choose Users.

Find the user account you used and click Edit. Scroll down on the Edit User page and you'll see the current basket contents, a Create Order button and....holy new buttons Batman! There is your new spiffy Edit Basket button. Click it.

Editing a basket
take a look at the edit basket screen. First, you'll notice there's no "Delete item" button. You don't need it. Just set a particular basket item to "0" quantity and hit the Recalculate button at the bottom. The item is then removed.
You can add new items to the basket with the Add Product button, and (insert that 2001 space movie theme) it even allows searching by SKU - how cool is that?!

Conclusion
Anything that improves the customer service experience is a good thing. Customers like instant gratification when it comes to their shopping experience. This modification puts one more tool in your belt when it comes to helping convert site visitors into store customers.

Tags: , ,

AC7 Articles

Month List