Message with null return from shipping module
Permalink Browser Info Environment
At the moment, if a shipping type such as Zone Base Shipping cannot ship to a location or cannot ship a particular item, it can make a null return and eCommerce does not show the shipping type as an option (or if no options, eCommerce refuses to ship at all).
What I would like to do is to pass back a reason/explanation from ZBS, so that a shipping type can be refused with a message to the customer that would then be displayed by eCommerce. eg
null + 'You are outside our delivery area'
null + 'Minimum order required'
Is there already a way to do this?
If not, can you look into ways to add this to the next version. I wouldn't anticipate that it would be difficult to code.
What I would like to do is to pass back a reason/explanation from ZBS, so that a shipping type can be refused with a message to the customer that would then be displayed by eCommerce. eg
null + 'You are outside our delivery area'
null + 'Minimum order required'
Is there already a way to do this?
If not, can you look into ways to add this to the next version. I wouldn't anticipate that it would be difficult to code.
Type: | Discussion |
---|---|
Status: | New |
It is a small feature request for Core Commerce.
A shipping type normally returns an array of 1 or more CoreCommerceShippingMethod objects. Each such object has a price and a name. These are displayed in a radio set for the customer to select a shipping method.
If the shipping type returns null or an empty array, then Core Commerce does not show anything for that shipping type at the checkout. This is useful behaviour because a shipping type calculation may decide it is unable to ship a particular cart to a particular location, so can deliberately return null.
What I would like to be able to do in such situations is for my shipping method Zone Based Shipping to return (rather than just an empty array or null) a message explaining why the shipping method is unavailable that Core Commerce then displays. Thus providing better feedback to the customer.
This will require a change to ZBS (that I can make) and a change to Core Commerce (That the C5 team will need to make).
A shipping type normally returns an array of 1 or more CoreCommerceShippingMethod objects. Each such object has a price and a name. These are displayed in a radio set for the customer to select a shipping method.
If the shipping type returns null or an empty array, then Core Commerce does not show anything for that shipping type at the checkout. This is useful behaviour because a shipping type calculation may decide it is unable to ship a particular cart to a particular location, so can deliberately return null.
What I would like to be able to do in such situations is for my shipping method Zone Based Shipping to return (rather than just an empty array or null) a message explaining why the shipping method is unavailable that Core Commerce then displays. Thus providing better feedback to the customer.
This will require a change to ZBS (that I can make) and a change to Core Commerce (That the C5 team will need to make).
I see what you're saying. I'll get working on that.
This will be released with the next update, here's the syntax:
Using your ZBS,
creates what's shown in the attached image.
Using your ZBS,
$ecm = new CoreCommerceShippingMethod($this->getShippingType(), 'ZONEBASED'); $ecm->setError('This shipping method is unavailable to your area.'); $ecm->setPrice($cart_calc->get_cart_cost()); $ecm->setName('<span class="zone-tbd">'.$ship_name.'</span>');
creates what's shown in the attached image.
Looks good.
If an Error is set, am I correct in assuming that it will display in addition to the Name?
If an Error is set, am I correct in assuming that it will display in addition to the Name?
Yes it shows the name as well, that code block is exactly what rendered into that screenshot.
Hi Korvin
I am trying to get this working for a new version of ZBS. Having called $ecm->setError() the $ecm that ZBS is returning on my development setup looks like (dump):
ZBS is the only shipping method active, so at the checkout I get as far as checkout/payment/form/, but it continues to show a 'Next' button.
Am I missing something? Or is the change you implemented only effective if there is a choice of shipping methods?
I am trying to get this working for a new version of ZBS. Having called $ecm->setError() the $ecm that ZBS is returning on my development setup looks like (dump):
CoreCommerceShippingMethod Object ( [error] => 0.907kg is too heavy to ship. [shippingMethodID] => 8_ZONEBASED [shippingType] => CoreCommerceShippingType Object ( [error] => [shippingTypeID] => 8 [shippingTypeHandle] => zonebased [shippingTypeName] => Zone Based Shipping [shippingTypeIsEnabled] => 1 [shippingTypeHasCustomCountries] => 0 [pkgID] => 44 [controller] => CoreCommerceZonebasedShippingTypeController Object (
Viewing 15 lines of 67 lines. View entire code block.
ZBS is the only shipping method active, so at the checkout I get as far as checkout/payment/form/, but it continues to show a 'Next' button.
Am I missing something? Or is the change you implemented only effective if there is a choice of shipping methods?
Yeah, I only changed the multi option, silly me. I'll fix that right now =p
Hi Korvin,
What is the status on this? Will there be a 2.8.1 release soon?
What is the status on this? Will there be a 2.8.1 release soon?
This has not yet been implemented as a number of complications arose. It seems a bit awkward to deny shipping after inputting billing and shipping information.
Has there been any progress on this for the upcoming version?
There has been none, as a lot of refactoring has to occur before this is implementable, currently there is no solid way to prevent clicking next, there has to be an implemented way for both the front and back end to absolutely ensure that this is prevented. The amount of work this will require has bumped it down on the totem pole for obvious reasons, I'll bring it up tomorrow with Ryan and let you know what the plan is.
Thanks for looking at this. I am surprised it is so hard, because the Next button is already disabled if there are no shipping methods (null returned). So I had imagined it would be a variation on that. Obviously there is more going on that I was aware of.
The issue is mostly that if the option is null, it has no possible way to finish, if there is a error in the shipping method, it still has a shipping method, so it thinks it can go on.
I'm having a hard time understanding your issue and your intended result, can you give me some screenshots of both?
Best,
Korvin