Hello! I just have a "how would you do this" question.

Here is a scenario:

Let's say that most of the time, UPS shipping is offered to the average customer in the United States.

Furthermore, a subset of products in the store are too heavy for UPS shipping. In the event that even one product in the cart is too heavy for UPS shipping, the entire order is affected by Rules that alter the checkout logic so that it does not offer a shipping method. In practice, the shop owner calls the customers later on and lets them know what the exact cost of shipping will be once they figure that out. If the customer is not agreeable to the shipping estimate at that time, they can tell the shop owner they changed their mind, and the shop owner will void the transaction for the products. Not fancy, but hey.

Now, because there are scenarios where there won't be a shipping method offered at all, the store configuration is set so that Shipping is not required.
However, this creates a problem 1 out of 100 times when a customer's order/checkout queries the UPS online tool, experiences a rare timeout (which doesn't return any UPS methods), and proceeds through checkout without ever selecting a UPS shipping method (which there would have been 2 or 3 offered, had it not timed out at UPS). Again, this is rare, but it happens.

To prevent this scenario, it would be nice to make shipping required. But currently, it can't be required because of the "too heavy to ship" scenario described above, where no shipping option is offered.

So... is there a way to make shipping required sometimes (when it's a valid UPS scenario) but not always (when it's a heavy freight item scenario)? And if so, how would you do this?

I should mention, that I originally had shipping required, and then had a Rule offer a $0.00 shipping option for the freight scenario. But the client thought it felt odd to make the customer select a $0.00 shipping method in that scenario, and had us change things to make shipping not required and to offer no shipping method in the freight scenario. But now, we run into the problem scenario every so often where a customer doesn't select a valid UPS shipping method.

Any advice on the best way to tackle this would be much appreciated.

Thanks for reading!

Comments

strings6 created an issue.

strings6’s picture

Anyone? :-)

strings6’s picture

Here's what I'm thinking for a possible solution:

Since the shipping method selection is on its own page during the checkout process, and it shows when there are shipping options, or doesn't show when there are none, I'm thinking I can do the following:

- Figure out the form id of the shipping method selection form on the shipping selection page
- Use hook_form_form_id_alter to make the shipping method selection field required

It seems like that would only affect the case when there is supposed to be shipping methods, and that the form field would be present even if the website rarely fails to pull back a shipping method from UPS. In that case, it might say it could not obtain any shipping methods, but since the hook code would make that field required, it would not allow them to proceed. Likewise, when there is no shipping in a scenario, the shipping page is not even presented, so the shipping method selection form would never be drawn, and thus the hook to make the field required would not fire.

Does anyone know the Drupal form id of the form on the shipping method selection screen?
Does the above plan sound like it would work?

strings6’s picture

Update: The above idea isn't working out. It seems I was wrong about it not showing the shipping selection form/screen when there are no shipping methods, so it's back to the drawing board. If anyone has tackled this before, please let me know what you did.

Thanks.

torgosPizza’s picture

Can you do something with Rules? Something like...

On event: after updating an existing order
Condition: current status is not the same as the unchanged status
Condition: order contains shippable products
Condition: NOT a shipping rate was applied to the order
(maybe additional Conditions to check a specific Checkout status, such as "Checkout : Shipping")

Event: Add a rate for a shipping service to an order
Event: Apply shipping rate to your order

I did something like this to make sure a physical order had a default shipping rate attached to it right at Checkout. I believe it should work, since when the order gets refreshed it should in theory recalculate the shipping rates for the order if none were found.

Not sure if any of this will work but I feel like it should get you part of the way there.