Page 1 of 1
Code conversion issues
Posted: Sat Dec 13, 2014 10:40 am
by RickSilver
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!
Re: Code conversion issues
Posted: Sat Dec 13, 2014 11:40 am
by rmaweb
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.
Re: Code conversion issues
Posted: Sun Dec 14, 2014 3:28 pm
by RickSilver
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
Re: Code conversion issues
Posted: Sun Dec 14, 2014 4:06 pm
by RickSilver
I did figure out how to get the order in CheckedOut() in AC Gold
CommerceBuilder.Orders.Order order = e.CheckoutResponse.Order
Re: Code conversion issues
Posted: Sun Dec 14, 2014 6:35 pm
by rmaweb
Out of curiosity, what type of customization are you trying to do with checkedout? Never used it myself.
Re: Code conversion issues
Posted: Mon Dec 15, 2014 6:12 pm
by RickSilver
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.
Re: Code conversion issues
Posted: Mon Dec 15, 2014 6:24 pm
by RickSilver
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
Re: Code conversion issues
Posted: Tue Dec 16, 2014 4:06 am
by jmestep
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);
Re: Code conversion issues
Posted: Tue Dec 16, 2014 6:29 pm
by RickSilver
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
Re: Code conversion issues
Posted: Mon Jan 05, 2015 8:02 am
by mazhar
I posted some tips about porting the codes to gold in this thread
viewtopic.php?f=47&t=17108