MarketPress custom shipping plugin in theme not showing all admin options

Howdy,

I modified the flat-rate shipping plugin and want to include it in the theme I’m developing, rather than dropping it into the plugins directory in MP where it’ll get wiped out every time the plugin gets updated.

I include_once’d the php file with the class and the appropriate mp_register_shipping_plugin from within my theme’s functions.php and I get the shipping option in the drop down in the admin area, but the shipping_settings_box and shipping_metabox aren’t showing up.

I even tried moving the mp-flat-rate.php to my theme directory (from the MP plugins dir) and it is doing the same thing — shows in the list, no meta boxes when selected. Any hints what’s going on with this?

What is the proper way to include shipping/gateway plugins from my theme to keep them from getting wiped out by MP upgrades?

Or should I make it another plugin rather than include it in my theme?

Thanks.

  • Philip John
    • DEV MAN’s Apprentice

    Hiya!

    First up I’d say that anything that isn’t actual themeing shouldn’t be included in your theme – it should be a separate plugin.

    Secondly, it’s not advisable to edit the core code of MarketPress so instead of editing the shipping options, you should create a new shipping gateway.

    You could place this as a separate plugin but it’s advisable to keep it in the MarketPress plugin folder. I know this would remove it every time but that’s unavoidable and is simply a case of re-uploading.

    As for your issue, I believe that may be a result of simply editing the existing gateway and using a new gateway should help to address that.

    Phil

  • WayneBuckhanan
    • WPMU DEV Initiate

    Hi Phil,

    As I said, I used the existing flat-rate plugin code to create a new shipping plugin.

    I understand your suggestion of creating a separate plugin rather than including it in my theme, but I’m wanting to simplify upgrading for my client. I attempted to make the shipping plugin its own WP plugin for that reason, but WP hadn’t loaded the MP classes to extend them when it was activated.

    I see that there are hooks to load shipping “gateway” plugins from a location other than the MP directory, but don’t see where it is documented *how*. I will not rely on my client uploading the shipping gateway every time MP updates in order for their site to function properly. That is just a bad idea all the way around for maintainability and I’ll get angry calls if that happens.

    So, back to the question of how to include a shipping plugin from outside of the MP directories.

    Thanks.

  • Aaron
    • CTO

    Hmm, I just tried a quick test plugin and it worked fine. Here is a quick example:

    <?php
    /*
    Plugin Name: MarketPress Test Shipping Plugin
    Author: Aaron Edwards (Incsub)
    */

    //register plugin
    function load_test_shipping_plugin() {
    include(dirname(__file__).'/test.php');
    }
    add_action('mp_load_shipping_plugins', 'load_test_shipping_plugin');
    ?>

    The actual shipping class and register call are in test.php

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.