filters the ShippingPackager object for the shipping module.

add_filter( 'shopp_{addonclassname}_packager', [callback] )

@param ShippingPackager $packager the ShippingPackager object for the shipping module.


filters the ShippingPackager object for the shipping module.

Each shipping module that inherits from the ShippingFramework class will instantiate a ShippingPackager object in the ShippingFramework constructor. This filter will allow a programmer to substitute their own packaging class.

If this filter replaces the default ShippingPackager object, it must replace it with a class that implements the ShippingPackagingInterface interface. Each package object your packager class returns may also be a custom object, but must at a minimum implement the ShippingPackageInterface interface. Failing to do so may break functionality in the online shipping module.


// prototype
// add_filter('shopp_{addonclassname}_packager', 'my_fltr');

// For the FedExRates module, for instance
add_filter('shopp_fedexrates_packager', 'my_fedex_packager');

// create filter function
function my_fedex_packager( $ShippingPackager ) {
    $ShippingPackager = new MyCustomPackager();
    return $ShippingPackager;

// Example stub classes
class MyCustomPackager extends ShippingPackager {
    private $packages = array();

    // required by interface

    // add an item to some package
    public function add_item ( Item $Item) {
        // implement your own logic to create appropriate number of packages
        $this->packages[] = $pkg = new MyCustomPackage();

    // packages iterator function
    public function packages () {
        if (!$this->packages) return false;
        if (!isset($this->_loop)) {
            $this->_loop = true;
        } else next($this->packages);

        if ( false !== current($this->packages) ) return true;
        else {
            return false;

    // the current package getter
    public function package () {
        return current($this->packages);

class MyCustomPackage extends ShippingPackage {
    private $contents = array(); // Items in the package

    // not required by interface
    // up to you how you want to do something like this
    public function add_item ( $Item ) {
        $contents[] = $Item;

    // getters required by interface
    public function weight() {}
    public function height() {}
    public function length() {}
    public function width() {}
    public function value() {}
    public function contents() { return $this->contents; }


See Also

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.