Code conversion issues
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Code conversion issues
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!
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
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:
Hope that helps.
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();
Ryan A.
Scott's Bait and Tackle
http://store.scottsbt.com
Work In Progress
Able Gold R10
Bootstrap 3.3
Scott's Bait and Tackle
http://store.scottsbt.com
Work In Progress
Able Gold R10
Bootstrap 3.3
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: Code conversion issues
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
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
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: Code conversion issues
I did figure out how to get the order in CheckedOut() in AC Gold
CommerceBuilder.Orders.Order order = e.CheckoutResponse.Order
CommerceBuilder.Orders.Order order = e.CheckoutResponse.Order
Re: Code conversion issues
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
Scott's Bait and Tackle
http://store.scottsbt.com
Work In Progress
Able Gold R10
Bootstrap 3.3
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: Code conversion issues
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.
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: Code conversion issues
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
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
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Code conversion issues
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
Otherwise, you might need to do it like the following, taken from usProcessPayment in the admin
Code: Select all
EmailTemplate template = EmailTemplateDataSource.Load(_EmailTemplateId);
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
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
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: Code conversion issues
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
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
I posted some tips about porting the codes to gold in this thread viewtopic.php?f=47&t=17108