Discussions

Calculate shipping rate based on postal code (Shipping 2.x)

Hi!

I would like to add a rule that will change the shipping fee for a specific amount based on the postal code field the user gave.

For example:

If you want your stuff to be shipped to Smalltown, you will to pay $10 for shipping and if you want it to Awesometown, you have to pay $5. And of course I would like Commerce to decide what amount to charge based on the postal code.

I know I need to set up a rule to check the postal code field's content and if it's equal to something, then calculate the shipping fee, but I can't bring the postal code field into scope.

Anyone know how to do that?

I've posted this problem before, but did not get any answers, I hope it's appropriate to post again.

Update:

Doing the comparison solved, I just needed to use Order address component comparison instead of Data comparison...

But how can I set the shipping fee to a specific amount? I tried Set a data value action but the way I could do it, all the shipping services got the amount.

Posted: Jan 19, 2012

Comments

balintd on January 20, 2012

Thanks, I got that figured out as I wrote in the update, but after solving this I got a new problem.

Now I just need to create an action that will set one of the shipping services' fee to a specific amount.

I tried Set the unit price to a specific amount but this way the action will set all two shipping services' fee to that amount and I just need that one service's fee to change.

rfay Randy Fay on January 20, 2012

I suspect you'll have to use a component. You'll create a loop that calls an action which is a component. The component will check to see that the line item is of the correct type and take an action if that's the case.