Code conversion issues

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
RickSilver
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Jun 22, 2009 5:49 pm

Code conversion issues

Post by RickSilver » Sat Dec 13, 2014 10:40 am

I'm working on a store that is on AC Gold. I'm coming from AC 7 of course.

1. Getting the order in CheckedOut()
Before I could do: Order order = OrderDataSource.Load(e.OrderId, false);
In Gold, it says OrderId is not valid for CheckedOutEventArgs

2. Getting an email template
So far I have this.. am I on the right track?

ICriteria criteria = NHibernateHelper.CreateCriteria<CommerceBuilder.Messaging.EmailTemplate>();
criteria.Add(Restrictions.Eq("name", "test"));

EmailTemplate emailTemplate = EmailTemplateDataSource.LoadForCriteria(criteria)[0];


But when run, I get "Error: Sys.WebForms.PageRequestManagerServerErrorException: could not resolve property: name of: CommerceBuilder.Messaging.EmailTemplate"



3. Changing a user setting. I am setting it with

UserSetting userSetting = new UserSetting();
userSetting.UserId = _UserId;
userSetting.FieldName = "DepartmentId";
userSetting.FieldValue = Department.SelectedValue;
_User.Settings.Add(userSetting);
_User.Save();


But cannot modify it. Re-adding it does not give an error but does not change the value.

Thanks for the help!

rmaweb
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Fri Sep 10, 2010 9:41 am

Re: Code conversion issues

Post by rmaweb » Sat Dec 13, 2014 11:40 am

Hello RickSilver,

1) Ablecommmerce deprecated the OrderId, ProductId, etc fields, based on the source code it looks like you would use e.Order instead of e.OrderId
http://wiki.ablecommerce.com/index.php/ ... Properties for more info

2) Not sure about since Im still learning NHibernate

3) I use this in my code:

Code: Select all

                // UPDATE USER COMMENTS
                if (_User.Settings.GetValueByKey("CustomerNotes") != null)
                    _User.Settings.SetValueByKey("CustomerNotes", CustomerNotes.Text);
                else
                {
                    UserSetting custnotes = new UserSetting();
                    custnotes.FieldName = "CustomerNotes";
                    custnotes.FieldValue = CustomerNotes.Text;
                    _User.Settings.Add(custnotes);
                }
                _User.Save();
Hope that helps.
Ryan A.
Scott's Bait and Tackle
http://store.scottsbt.com
Work In Progress
Able Gold R10
Bootstrap 3.3

RickSilver
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Jun 22, 2009 5:49 pm

Re: Code conversion issues

Post by RickSilver » Sun Dec 14, 2014 3:28 pm

Thanks for responding. I tried these in checkout and got a compile error for all of them similar to this:

Compiler Error Message: CS1061: 'AbleCommerce.Code.CheckedOutEventArgs' does not contain a definition for 'id' and no extension method 'id' accepting a first argument of type 'AbleCommerce.Code.CheckedOutEventArgs' could be found

OrderDataSource.Load(e.OrderId, false);
OrderDataSource.Load(e.Order, false);
OrderDataSource.Load(e.Id, false);
OrderDataSource.Load(e.id, false);

:(

Still having trouble with the Email Templates but I changing the user setting works!

Rick

RickSilver
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Jun 22, 2009 5:49 pm

Re: Code conversion issues

Post by RickSilver » Sun Dec 14, 2014 4:06 pm

I did figure out how to get the order in CheckedOut() in AC Gold :)

CommerceBuilder.Orders.Order order = e.CheckoutResponse.Order

rmaweb
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Fri Sep 10, 2010 9:41 am

Re: Code conversion issues

Post by rmaweb » Sun Dec 14, 2014 6:35 pm

Out of curiosity, what type of customization are you trying to do with checkedout? Never used it myself.
Ryan A.
Scott's Bait and Tackle
http://store.scottsbt.com
Work In Progress
Able Gold R10
Bootstrap 3.3

RickSilver
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Jun 22, 2009 5:49 pm

Re: Code conversion issues

Post by RickSilver » Mon Dec 15, 2014 6:12 pm

I'm implementing a budget feature. An admin can configure a department and set a max budget. Users register and select a department. User can pay by PO and that gets subtracted from the budget. Each department can be set up to either disallow going over budget or allow and send an email to someone.

RickSilver
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Jun 22, 2009 5:49 pm

Re: Code conversion issues

Post by RickSilver » Mon Dec 15, 2014 6:24 pm

How do I load a custom email template in AC Gold?

In AC7, I could do this:

EmailTemplateCollection emailTemplates = EmailTemplateDataSource.LoadForCriteria(" Name = 'My Template' ");

Does EmailTemplateCollection still exist? Gold doesn't like it and I can't find a namespace.

Thanks
Rick

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

Re: Code conversion issues

Post by jmestep » Tue Dec 16, 2014 4:06 am

Things that used to be collections in Able 7 are IList in Able Gold. If you are wanting to load one particular template, the easiest way is to do it by email template id

Code: Select all

 EmailTemplate template = EmailTemplateDataSource.Load(_EmailTemplateId);
Otherwise, you might need to do it like the following, taken from usProcessPayment in the admin

Code: Select all

ICriteria criteria = NHibernateHelper.CreateCriteria<PaymentMethod>();
            criteria.Add(Restrictions.Not(Restrictions.Eq("PaymentInstrumentId", (short)PaymentInstrumentType.GiftCertificate)));
            criteria.Add(Restrictions.Not(Restrictions.Eq("PaymentInstrumentId", (short)PaymentInstrumentType.GoogleCheckout)));
            IList<PaymentMethod> allMethods = PaymentMethodDataSource.LoadForCriteria(criteria);
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

RickSilver
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Mon Jun 22, 2009 5:49 pm

Re: Code conversion issues

Post by RickSilver » Tue Dec 16, 2014 6:29 pm

Thanks Judy. I'd like to be able to load by name but when I tried that using this:

ICriteria criteria = NHibernateHelper.CreateCriteria<CommerceBuilder.Messaging.EmailTemplate>();

I get this:

Error: Sys.WebForms.PageRequestManagerServerErrorException: could not resolve property: name of: CommerceBuilder.Messaging.EmailTemplate"

I'll have to go with the ID.

Thanks
Rick

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

Re: Code conversion issues

Post by mazhar » Mon Jan 05, 2015 8:02 am

I posted some tips about porting the codes to gold in this thread viewtopic.php?f=47&t=17108

Post Reply