I'm trying to create a plugin to allow shipping cost based on ranges of post codes. The post codes are hard-coded into the plugin. Due to my lack of experience developing for ExpressionEngine I'm unable to get the plugin to do anything.

Note that the cart only has one shipping option; the user shouldn't need to or be able to select a shipping option; this should be applied automatically based on their shipping post code.

Plugin: https://gist.github.com/anonymous/86838c02028faabfb404

1 Answer 1


The problem is that you are trying to edit the order directly.

Instead, your extension should implement the store_order_shipping_methods hook to return your custom shipping rate, as the official Store shipping extensions do.

Inside the extension file, your hook method should look something like this:

public function shipping_methods($order, array $methods)
    if (ee()->extensions->last_call !== false) {
        $methods = ee()->extensions->last_call;

    // implement your own shipping logic here
    if ($order->shipping_postcode == '12345') {

        // add a custom shipping method
        $option = new Store\Model\OrderShippingMethod;
        $option->id = 'custom';
        $option->name = 'My Custom Shipping Method';
        $option->amount = 10.00;
        $option->class = __CLASS__;

        $methods[$option->id] = $option;

    return $methods;
  • I'm doing something similar. Is it okay to override an existing shipping method amount, by specifying an existing $option->id as per your example above?
    – user2596
    Aug 25, 2014 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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