Hi, I try to add new textArea in the ShipRateQuoteForm. This textArea will let the user enter some custom additional shipping information.
I manage to add my ShippingInfo field in the StoreShipRateQuoteModel, then read it in the SaveShipRateQuote action.
But Where I can save it? I add a function in the CheckoutManager.Shipping.SaveShipmentInfo(string info) but now I am stuck. I can't find some documentation on the data model behind merchello. Ideally I need to store this information in the order to be able to display it in the back end section.
Thanks for your help. All is working now!
Last question, Now I got a Merchello.web.dll and Merchello.web.store.dll with custom code. How I can set it by default in my production project. Normally when compiling, theses dll, are copied back from the Nuget local package. I try to remove the reference and add reference to my custom dll, but the package keep overwriting them.
Normally you would not recompile the Merchello dlls - but add your code to your own library that references them via NuGet. Most of the classes allow you to either sub-class the Merchello class (inherit from) and override the methods you need to ...
Have you found places where this was not possible - ex. something was internal that you needed to access?
Then in the ShipRateQuoteForm.cshtml I change the inherits and the form controller for:
umbLVC2.Custom.LVCShipRateQuoteModel
using (Html.BeginUmbracoForm
First question:
After compiling, no error, but after hitting the save button in the ShipRateQuoteForm, my Save function inside my Custom controller is not called. DO I miss something?
Second Question:
In the LVCCheckoutShipRateQuoteController, I need to add a save function fot the ShipmentInfo. See this commented line: CheckoutManager.Shipping.SaveShipmentInfo(model.ShipmentInfo);
How to overrideing the BasketCheckoutShippingManager to add my function:
public void SaveShipmentInfo(string info)
{
var items = this.Context.ItemCache.Items.Where(x => x.LineItemType == LineItemType.Shipping).ToArray();
foreach (var item in items)
{
item.ExtendedData.SetValue("ShipmentInfo", info);
}
this.Context.Services.ItemCacheService.Save(this.Context.ItemCache);
}
You can create your own CheckoutShippingManager and either inherit from the base class in the core (CheckoutShippingManagerBase) or, in your case probably easier to inherit from
Merchello.Web.CheckoutManagers.BasketCheckoutShippingManager and add your method.
You can replace the existing CheckoutShippingManager with your version by updating the reference in the merchello.config.
Failed to create Type due to null Type or null constructor args
trace stack:
at Merchello.Web.Pluggable.PluggableObjectHelper.GetInstance[T](String configurationAlias, Object[] ctrArgValues)
at Merchello.Web.CheckoutManagers.BasketCheckoutManager.
I'd have to step through it, but looking at it now, the BasketCheckoutShippingManager itself is internal so you will have to inherit from CheckoutShippingManagerBase which should force you to include the constructor (which is probably where the issue is originating - at least that is my guess without being able to see or test it directly).
but outside the BasketShippingManager. In this case I can save it inside my custom view controler instead of overriding ShippingManager.
IF NOT:
I can't see where the internet class is defined. If inherit from CheckoutShippingManageBase, How I can call a custom inherited BasketCheckoutShippingManage? I will make som trace with source code, but I suspect this line to be in cause:
his._shippingManager = new Lazy<ICheckoutShippingManager>(() => PluggableObjectHelper.GetInstance<BasketCheckoutShippingManager>("BasketCheckoutShippingManager", this.Context));
inside the Initialize function of the BasketCheckoutManager
Yes with tracing, I think the problem is located in the PluggableObjectHelper called several times in the checkout process. But my god! How I can override this. Too many internal class! ;-)
I can't figure how to solve that. Normally i wil need to inherit and override the Initialize function to change the pluggableObject of the _shippingManager (BasketCheckoutManager line 119).
But for that I will need to change the static class in CheckoutExtensions.cs that instantiate the BasketCheckoutManager but in this file we got several links to other internal class...
All is working now. I can save and display my information backend in the SaleOverview view.
Question: When I copy my backend modification from dev server to prod server all is working for the checkout process, but the fields are empty in the backend section. I think the prod server use the old merchello.controllers.js file instead of the new custom one.
I try to breakpoint in chrome or IE but I can't see any file merchello.controllers.js in the list. Some lazyloading.js file that it.
What do I miss there? For now I overwrite all the App_plugings folders from Dev to prod.
Adding ShipmentInfo
Hi, I try to add new textArea in the ShipRateQuoteForm. This textArea will let the user enter some custom additional shipping information.
I manage to add my ShippingInfo field in the StoreShipRateQuoteModel, then read it in the SaveShipRateQuote action. But Where I can save it? I add a function in the CheckoutManager.Shipping.SaveShipmentInfo(string info) but now I am stuck. I can't find some documentation on the data model behind merchello. Ideally I need to store this information in the order to be able to display it in the back end section.
Any suggestion?
Would it work to add it to the ExtendedDataCollection of the shipping line item created when the rate quote is saved?
Thanks for your help. All is working now! Last question, Now I got a Merchello.web.dll and Merchello.web.store.dll with custom code. How I can set it by default in my production project. Normally when compiling, theses dll, are copied back from the Nuget local package. I try to remove the reference and add reference to my custom dll, but the package keep overwriting them.
Thanks
Normally you would not recompile the Merchello dlls - but add your code to your own library that references them via NuGet. Most of the classes allow you to either sub-class the Merchello class (inherit from) and override the methods you need to ...
Have you found places where this was not possible - ex. something was internal that you needed to access?
Thank for you help Rusty. All this process is quite new for me! ;-)
I start doing like you said and starting overriding class.
So for now I override the CheckoutShipRateQuoteController in fastTrak:
then the ShipRateQuoteModel
Then in the ShipRateQuoteForm.cshtml I change the inherits and the form controller for:
umbLVC2.Custom.LVCShipRateQuoteModel
using (Html.BeginUmbracoForm
First question: After compiling, no error, but after hitting the save button in the ShipRateQuoteForm, my Save function inside my Custom controller is not called. DO I miss something?
Second Question: In the LVCCheckoutShipRateQuoteController, I need to add a save function fot the ShipmentInfo. See this commented line: CheckoutManager.Shipping.SaveShipmentInfo(model.ShipmentInfo);
How to overrideing the BasketCheckoutShippingManager to add my function:
thanks
I think you may be missing the controller reference in your form:
have you tried:
rather than:
shame on me! lol... Thanks.
What about adding my function SaveShipmentInfo in the CheckoutManager.Shipping ?
You can create your own
CheckoutShippingManager
and either inherit from the base class in the core (CheckoutShippingManagerBase
) or, in your case probably easier to inherit fromMerchello.Web.CheckoutManagers.BasketCheckoutShippingManager
and add your method.You can replace the existing CheckoutShippingManager with your version by updating the reference in the merchello.config.
Note: in order to use your method, you will have to implicitly call that method (since it isn't defined on the interface) - so something like
I create a new LVCBasketCheckoutShippingManager and change the Merchello.config file like you said.
Now I got an exception in my custon LVCCheckoutShipRateQuoteController.SaveShipRateQuote function at the line:
Exception:
Failed to create Type due to null Type or null constructor args
trace stack:
at Merchello.Web.Pluggable.PluggableObjectHelper.GetInstance[T](String configurationAlias, Object[] ctrArgValues) at Merchello.Web.CheckoutManagers.BasketCheckoutManager.
I'd have to step through it, but looking at it now, the
BasketCheckoutShippingManager
itself is internal so you will have to inherit fromCheckoutShippingManagerBase
which should force you to include the constructor (which is probably where the issue is originating - at least that is my guess without being able to see or test it directly).Here is the code implementation for the
BasketCheckoutShippingManager
https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.Web/CheckoutManagers/BasketCheckoutShippingManager.csOUf! Complex! ;-)
PlanB: de we have a way to get the shippingline like this
but outside the BasketShippingManager. In this case I can save it inside my custom view controler instead of overriding ShippingManager.
IF NOT: I can't see where the internet class is defined. If inherit from CheckoutShippingManageBase, How I can call a custom inherited BasketCheckoutShippingManage? I will make som trace with source code, but I suspect this line to be in cause:
inside the Initialize function of the BasketCheckoutManager
Yes with tracing, I think the problem is located in the PluggableObjectHelper called several times in the checkout process. But my god! How I can override this. Too many internal class! ;-)
I can't figure how to solve that. Normally i wil need to inherit and override the Initialize function to change the pluggableObject of the _shippingManager (BasketCheckoutManager line 119).
But for that I will need to change the static class in CheckoutExtensions.cs that instantiate the BasketCheckoutManager but in this file we got several links to other internal class...
I am stuck there. ;-)
Finnaly I choose to not add the function into the BasketShippingController. I way to complicated for me.
I just add the code dirrectly in the CheckoutShipRateController because we have access to the Shiping Controler context
All is working now. I can save and display my information backend in the SaleOverview view.
Question: When I copy my backend modification from dev server to prod server all is working for the checkout process, but the fields are empty in the backend section. I think the prod server use the old merchello.controllers.js file instead of the new custom one. I try to breakpoint in chrome or IE but I can't see any file merchello.controllers.js in the list. Some lazyloading.js file that it.
What do I miss there? For now I overwrite all the App_plugings folders from Dev to prod.
Thanks
Hi Pierre,
You can step through your JS code if you disable client dependency (compilation debug="Fasle")
EDIT:
When I put debug=true in the
But If I change it to debug=false, the problem return.
I missing something?
Sounds like something is gummed up in ClientDependency. Can you tick the ClientDependency version and see if that clears things up?
mmm sory how I can do that?
It's the version number in the ClientDependency.config file.
version 219938318
After flushing all file on the server, upgraded to Merchello 2.4 the problem is gone. Thanks
is working on a reply...