Changing admin order payment type

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
evanb@firefold.com
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 36
Joined: Mon Jul 21, 2008 3:45 pm

Changing admin order payment type

Post by evanb@firefold.com » Wed Oct 15, 2008 1:44 pm

I believe this has been addressed before but let me discuss the concept which we would like to try and do:

Image

In the picture above you see what I'm talking about.

What we need to do is separate purchase orders from the normal order types to display a different message than the others. Each purchase order that is placed must display "Net 30" beside "Payment:" instead of "paid" or "unpaid" etc.

If anyone can help with relevant information to allow us an entry point to start this modification we would be greatful!

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Changing admin order payment type

Post by jmestep » Wed Oct 15, 2008 2:46 pm

It looks like you would have to put some coditional code on this in the vieworder.aspx.cs

CurrentPaymentStatus.Text = _Order.PaymentStatus.ToString();
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Changing admin order payment type

Post by William_firefold » Thu Oct 16, 2008 1:47 pm

OK this seems pretty simple to me now but I need an IF statement that will do a comparison on the users group name.

If the person who placed the order is in user group "Net Terms"{
label="whatever"
}

I just need to know how to get the user and group from that page.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Changing admin order payment type

Post by jmestep » Thu Oct 16, 2008 4:02 pm

Wouldn't you want to run it off the payment method for that one order? What if the customer changes groups? or is in two groups?
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Changing admin order payment type

Post by William_firefold » Fri Oct 17, 2008 8:43 am

No, the real purpose of this is simply to let our employees know that the person has terms with us.
We dont even need to change their payment type to anything.
What I need is just the syntax for getting the user's group while on that page so I can set the label based on their group.

If the user has multiple groups I can code for that but it would just need to see if they are in the Net Terms group.

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

Re: Changing admin order payment type

Post by mazhar » Fri Oct 17, 2008 9:08 am

You can access the user groups as below on the ViewOrder page.

Code: Select all

string groups = "";
        foreach (CommerceBuilder.Users.UserGroup userGroup in _Order.User.UserGroups)
        {
            groups += userGroup.Group.Name;
        }
In the above example i just created a list of all groups the user belongs to.
Last edited by mazhar on Mon Oct 20, 2008 10:40 am, edited 1 time in total.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Changing admin order payment type

Post by AbleMods » Fri Oct 17, 2008 9:46 am

Here's an example page (C-Sharp) of how to test for a specific group membership with the group name. Just unzip these files in the root of your store. Comments included in the code-behind file.
Test-UserGroups.zip
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Changing admin order payment type

Post by William_firefold » Fri Oct 17, 2008 11:44 am

Great code, this helps a lot.

foreach (CommerceBuilder.Users.UserGroup _UserGroup in _Order.User.UserGroups)

It works pretty well, but there is a little problem with it.
I decided to use the same code for the columns on
Admin/orders/default.aspx

It works except on certain pages of orders I get a popup
"Object reference not set to an instance of an object."

I have found this is due to the state of a particular order on whatever page gives the error.
It wouldnt even matter that it pops up but it makes it impossible to get to that page of orders.
It is on page 11 for us now but it changes as we get orders so I know the cause is an order.

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Changing admin order payment type

Post by William_firefold » Fri Oct 17, 2008 12:13 pm

I removed my column code and visited the order on the page that threw the popup. The order page uses pretty much exactly what you uploaded. This is the error it threw:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 112: bool _Found = false;
Line 113: // Loop through each group assigned to the user that placed this order
Line 114: foreach (CommerceBuilder.Users.UserGroup _UserGroup in _Order.User.UserGroups)
Line 115: {
Line 116: if (_UserGroup.Group.Name == _MyGroup)


Source File: d:\FireFold\Admin\Orders\ViewOrder.aspx.cs Line: 114

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Changing admin order payment type

Post by AbleMods » Fri Oct 17, 2008 1:31 pm

The code I posted was merely an example, it wasn't meant for production use inside another routine or page. There's all sorts of error checking that should occur so that everything exists as expected.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Changing admin order payment type

Post by William_firefold » Fri Oct 17, 2008 1:36 pm

I modified your code to catch the error. Thanks for all of your help.

Code: Select all

         string _MyGroup = "Net Terms";
try{
        foreach (CommerceBuilder.Users.UserGroup _UserGroup in order.User.UserGroups)
        {
        if (_UserGroup.Group.Name == _MyGroup && order.PaymentStatus.ToString()=="Unpaid")
       {                
       return _MyGroup ;
       }else if(_UserGroup.Group.Name == _MyGroup && order.PaymentStatus.ToString()=="Paid"){
       return "Paid";             
       }
        }
}catch{
		return "PO No Acct";  		
}

Post Reply