One more flat rate shipping tier

My client (in Sydney, Australia) is requesting a three-tiered flat rate shipping arrangement. Tier 1: Sydney Metro, Tier 2: Australia-wide, Tier 3: International. How can I go about modifying the flat rate shipping method to achieve this? The Sydney Metro postcode range is 1000-1920; 2000-2249; 2555-2574; 2740-2786. Australia-wide would be any other postcode with AU as the destination. Have there been similar requests for modification of flat rate shipping?

  • Timothy
    • Chief Pigeon

    Hey there.

    This isn’t possible by default and would take some custom code.

    Open up:

    /marketpress/marketpress-includes/plugins-shipping/mp-flat-rate.php

    Then line 145 you will see:

    break;

    default:

    You need to put this new case between them:

    break;

    case 'AU':
    ?>
    <tr>
    <th scope="row"><?php _e('Sydney Metro', 'mp') ?></th>
    <td>
    <?php echo $mp->format_currency(); ?><input type="text" name="mp[shipping][flat-rate][sydney_metro]" value="<?php echo esc_attr($mp->get_setting('shipping->flat-rate->sydney_metro')); ?>" size="5" maxlength="10" />
    </td>
    </tr>
    <tr>
    <th scope="row"><?php _e('Australia-wide', 'mp') ?></th>
    <td>
    <?php echo $mp->format_currency(); ?><input type="text" name="mp[shipping][flat-rate][australia-wide]" value="<?php echo esc_attr($mp->get_setting('shipping->flat-rate->australia-wide')); ?>" size="5" maxlength="10" />
    </td>
    </tr>
    <tr>
    <th scope="row"><?php _e('International', 'mp') ?></th>
    <td>
    <?php echo $mp->format_currency(); ?><input type="text" name="mp[shipping][flat-rate][international]" value="<?php echo esc_attr($mp->get_setting('shipping->flat-rate->international')); ?>" size="5" maxlength="10" />
    </td>
    </tr>
    <?php
    break;

    default:

    Save, reload the page and give it a try.

    Thanks.

  • drfingerless
    • Site Builder, Child of Zeus

    Timothy, this what I thought of doing myself but couldn’t get the page to stop breaking when I tried it. I’m pretty sure it must have just been a typo or something – I will try your code and see if I get a better result.

    But the problem still remains how to get Marketpress to understand that an order is going to a Sydney Metro address and apply that level of postage. Somehow the postcode needs to be assessed against the ranges that I mentioned in my opening post in order to determine if the address is inside or outside the Sydney Metro region.

  • Timothy
    • Chief Pigeon

    Hey again.

    But the problem still remains how to get Marketpress to understand that an order is going to a Sydney Metro address and apply that level of postage. Somehow the postcode needs to be assessed against the ranges that I mentioned in my opening post in order to determine if the address is inside or outside the Sydney Metro region.

    You would need to do something custom here and it’s getting a little more complex so it would generally be something out of the scope of support.

    You could have a database of postal codes or ranges of them, then you would have to compare them so if they ring true you only show metro, else if they equal another set then do Australia else do international.

    I don’t know about Australian postal codes but taking your first numbers it could be:

    if ($postalcode >= 1000 && $postalcode <= 1920) {
    DO THIS WHICH WOULD BE THE SHIPPIONG OPTION YOU WANT FOR THIS POSTAL AREA
    }

    Thats just a quick idea of how you might like to approach it.

    Hope this helps.

  • drfingerless
    • Site Builder, Child of Zeus

    Thanks Timothy. The coding required is beyond my abilities so I have engaged an affiliate of mine to see if he can do the coding. I think it should be possible. I’ll let you know via this thread if I can get the result I am looking for.

  • Timothy
    • Chief Pigeon

    It’s definitely possible, for an experienced DEV it wouldn’t take a great deal.

    Hopefully your affiliate will be able to help you get sorted :slight_smile:

    So these are the ranges right?

    1000-1920

    2000-2249

    2555-2574

    2740-2786

    If so then it shouldn’t be so hard.

    Anyway, let me know how you go.

    Thanks.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.