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.

Type: Discussion
Status: New
JohntheFish
View Replies: View Best Answer
Korvin replied on at Permalink Reply
Korvin
Hey there,
I'm having a hard time understanding your issue and your intended result, can you give me some screenshots of both?

Best,
Korvin
JohntheFish replied on at Permalink Reply
JohntheFish
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).
Korvin replied on at Permalink Reply
Korvin
I see what you're saying. I'll get working on that.
Korvin replied on at Permalink Best Answer Reply 1 Attachment
Korvin
This will be released with the next update, here's the syntax:
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.
JohntheFish replied on at Permalink Reply
JohntheFish
Looks good.

If an Error is set, am I correct in assuming that it will display in addition to the Name?
Korvin replied on at Permalink Reply
Korvin
Yes it shows the name as well, that code block is exactly what rendered into that screenshot.
JohntheFish replied on at Permalink Reply 1 Attachment
JohntheFish
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):

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
      (


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?
Korvin replied on at Permalink Reply
Korvin
Yeah, I only changed the multi option, silly me. I'll fix that right now =p
JohntheFish replied on at Permalink Reply
JohntheFish
Hi Korvin,

What is the status on this? Will there be a 2.8.1 release soon?
Korvin replied on at Permalink Reply
Korvin
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.
JohntheFish replied on at Permalink Reply
JohntheFish
Has there been any progress on this for the upcoming version?
Korvin replied on at Permalink Reply
Korvin
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.
JohntheFish replied on at Permalink Reply
JohntheFish
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.
Korvin replied on at Permalink Reply
Korvin
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.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.