1

I have created a shipping method in the CP but when I output cart.availableShippingMethods a null value is returned. I've checked my database and the shipping method is there.

Is there something I'm missing?

1

Does your shipping method have any conditions set? Like a country or region? I think getAvailableShippingMethods() takes into account your shipping address (if any) and only shows shipping methods that apply to the current shipping details.

Second thing to check: does your shipping method have at least one shipping rule? Commerce needs a shipping rule to be checked against your order.

  • I thought that might be the case so I deleted everything and started again. I just have one Shipping Method setup with no rules or zones and I'm using the general category. Thanks for your help – NixonAnt Feb 20 at 13:33
  • Stupid question: does your shipping method have shipping rules? A shipping rules has to match the order for the shipping method to be available. Look at github.com/craftcms/commerce/blob/master/src/models/… to see how the matching is done, it might help you figure out what's wrong? – Paul Feb 20 at 13:38
  • I added a rule just to see and it now works. Seems that the method requires at least one rule. Thanks again for your help – NixonAnt Feb 20 at 14:06
  • Yes, the method always requires at least one shipping rule to be matched to your order! I will add that to my answer, for future reference :) – Paul Feb 20 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.