Save cart in Backoffice - Set shipping method gets cleared
Hi Matt,
I am trying to think of a solution for our customer to add a shipping method for the ordering customer. This way a customer can get a quotation for shippingcosts before ordering.
When I open the cart in the Backoffice, i can set the shipping method (while the method is empty). I see the shipping method being selected. But when i save the cart, the shippingmethod gets cleared.
I don't get any errors in the devtools.
I am talking about this field right here.
Do you have an idea where to look, or what might be the problem?
Vendr Checkout will clear the billing / shipping details when an order is updated. It does this to ensure shipping / billing prices are not included in the initial cart total, but it will just apply this rule whenver the cart is updated, regardless of it being front end or back end update.
If you'd prefer not to have these event handlers enabled you can disable them by removing them at startup after Vendr Checkout has done it's initialization.
Hmmm can't seem to get it working. Probably my own fault.
I tried adding this to my Composer, but it didn't work. The shipping method is still being cleared.
// an order change
builder.WithNotificationEvent<OrderLineChangingNotification>().RemoveHandler<OrderLineChangingHandler>();
builder.WithNotificationEvent<OrderLineRemovingNotification>().RemoveHandler<OrderLineRemovingHandler>();
builder.WithNotificationEvent<OrderPaymentCountryRegionChangingNotification>().RemoveHandler<OrderPaymentCountryRegionChangingHandler>();
builder.WithNotificationEvent<OrderShippingCountryRegionChangingNotification>().RemoveHandler<OrderShippingCountryRegionChangingHandler>();
builder.WithNotificationEvent<OrderShippingMethodChangingNotification>().RemoveHandler<OrderShippingMethodChangingHandler>();
After this i tried making an extension for the VendrBuilder. But it also doesn't work.
Startup + extension:
I also tried it as it's own composer which should be run after the VendrCheckoutComposer, but also no luck.
So these would have to be via a composer and they would have to be configured to run after the VendrCheckoutComposer so the latter approach should really work.
It does say that it is deprecated, might be an issue?
I am using Vendr 3.0.5 and Checkout 3.0.0 by the way
When debugging my project it does hit my breakpoint, which means it gets in my composer. But when I want to set the shipping method for the cart in the backoffice, it keeps clearing it.
Yea, it is depricated, but Vendr Checkout supports a lot of back versions so it uses the older API for it.
Hmm, this should be working.
The only other thing I could suggest atm is to pull the source code for the Vendr Checkout plugin and compile a version with those event handler disabled 🤔
I found the last version of that extension and noticed an extra line of code. Added the removehandler for that one and also added the using IBuilder, and now its working!
This is the complete Composer right now:
using Umbraco.Cms.Core.Composing;
using Vendr.Checkout.Composing;
using Vendr.Checkout.Events;
using Vendr.Core;
using Vendr.Core.Events.Notification;
using Vendr.Extensions;
using Vendr.Umbraco;
using IBuilder = Umbraco.Cms.Core.DependencyInjection.IUmbracoBuilder;
namespace Project.Repository.Composers {
[ComposeAfter(typeof(VendrCheckoutComposer))]
public class StoreExtraComposer : IComposer {
public void Compose(IBuilder builder)
{
// Remove reset shipping / payment methods when certain elements of
// an order change
builder.WithNotificationEvent<OrderProductAddingNotification>().RemoveHandler<OrderProductAddingHandler>();
builder.WithNotificationEvent<OrderLineChangingNotification>().RemoveHandler<OrderLineChangingHandler>();
builder.WithNotificationEvent<OrderLineRemovingNotification>().RemoveHandler<OrderLineRemovingHandler>();
builder.WithNotificationEvent<OrderPaymentCountryRegionChangingNotification>().RemoveHandler<OrderPaymentCountryRegionChangingHandler>();
builder.WithNotificationEvent<OrderShippingCountryRegionChangingNotification>().RemoveHandler<OrderShippingCountryRegionChangingHandler>();
builder.WithNotificationEvent<OrderShippingMethodChangingNotification>().RemoveHandler<OrderShippingMethodChangingHandler>();
}
}
}
Save cart in Backoffice - Set shipping method gets cleared
Hi Matt,
I am trying to think of a solution for our customer to add a shipping method for the ordering customer. This way a customer can get a quotation for shippingcosts before ordering.
When I open the cart in the Backoffice, i can set the shipping method (while the method is empty). I see the shipping method being selected. But when i save the cart, the shippingmethod gets cleared.
I don't get any errors in the devtools.
I am talking about this field right here.
Do you have an idea where to look, or what might be the problem?
Thanks!
Kind regards,
//Puck
Are you using Vendr Checkout?
yes!
So that will be why.
Vendr Checkout will clear the billing / shipping details when an order is updated. It does this to ensure shipping / billing prices are not included in the initial cart total, but it will just apply this rule whenver the cart is updated, regardless of it being front end or back end update.
If you'd prefer not to have these event handlers enabled you can disable them by removing them at startup after Vendr Checkout has done it's initialization.
You can see the list of events Vendr Checkout adds here https://github.com/vendrhub/vendr-checkout/blob/b9922ca5e02e45352aa87be3448643da0d99d8b0/src/Vendr.Checkout/Extensions/CompositionExtensions.cs#L23-L39 you'll basically need to create a composer that does the same, but calls Remove for each of those event handlers.
Hope this helps
Matt
Alright! I will give it a try.
Thanks
Puck
Hmmm can't seem to get it working. Probably my own fault.
I tried adding this to my Composer, but it didn't work. The shipping method is still being cleared.
After this i tried making an extension for the VendrBuilder. But it also doesn't work.
Startup + extension:
I also tried it as it's own composer which should be run after the VendrCheckoutComposer, but also no luck.
//Puck
So these would have to be via a composer and they would have to be configured to run after the
VendrCheckoutComposer
so the latter approach should really work.It does say that it is deprecated, might be an issue?
I am using Vendr 3.0.5 and Checkout 3.0.0 by the way
When debugging my project it does hit my breakpoint, which means it gets in my composer. But when I want to set the shipping method for the cart in the backoffice, it keeps clearing it.
Yea, it is depricated, but Vendr Checkout supports a lot of back versions so it uses the older API for it.
Hmm, this should be working.
The only other thing I could suggest atm is to pull the source code for the Vendr Checkout plugin and compile a version with those event handler disabled 🤔
Alright, got it working!
I found the last version of that extension and noticed an extra line of code. Added the removehandler for that one and also added the using IBuilder, and now its working!
This is the complete Composer right now:
Thanks again for everything!
//Puck
is working on a reply...