3

Folks:

All the products in the store I am working have only one shipping method (ground). It seems redundant to have people go through the shipping screen since there is only one shipping option. Is there a way to just apply the default shipping for the product(s) based on the address they enter rather than going through the shipping screen?

3

You can automatically set the shipping method on a cart (e.g. by an ajax call) at any point by POSTing to commerce/cart/updateCart - You just use an input with name shippingMethod and and the value you supply is the handle of your shipping method, e.g. `ground'.

Where you do this is entirely up to you, but note depending how you handle/implement this, changes in the cart contents & addresses can invalidate shipping methods, so you'd typically do this at some point after your cart index page...

4
  • Do you have an example for this? I have tried to add to add the input to the address form but it then breaks, stating that the amount does not add up although shipping has no cost. Apr 20 '17 at 12:37
  • Got it working. Shipping methods weren’t enabled on the front end. Apr 20 '17 at 12:48
  • @MarcusScheller Can you post an example of your solution here?
    – KSPR
    Sep 18 '19 at 8:26
  • @KSPR I just enabled the shipping methods. Sep 19 '19 at 9:53

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.