Esempio n. 1
0
 function testPackageExpansion()
 {
     $lib = new ShippingLib();
     $lib->addProvider($this);
     $lib->getRates(array('zip' => '12345678900X'), array('zip' => 'A1B 2C3'), array(array('weight' => 5, 'count' => 2), array('weight' => 10)));
     $this->assertEquals(array(array('weight' => 5), array('weight' => 5), array('weight' => 10)), $this->packages);
 }
Esempio n. 2
0
            }
        }
        return $out;
    }
    static function getCustomShippingProvider($name)
    {
        $file = dirname(__FILE__) . '/custom/' . $name . '.php';
        $className = 'CustomShippingProvider_' . ucfirst($name);
        if (is_readable($file)) {
            require_once $file;
            if (class_exists($className) && method_exists($className, 'getName')) {
                $provider = new $className();
                return $provider;
            }
        }
        TikiLib::lib('errorreport')->report(tr('Problem reading custom shipping provider "%0"', $name));
    }
}
global $shippinglib, $prefs;
$shippinglib = new ShippingLib();
if (!empty($prefs['shipping_fedex_enable']) && $prefs['shipping_fedex_enable'] === 'y') {
    require_once 'lib/shipping/provider_fedex.php';
    $shippinglib->addProvider(new ShippingProvider_FedEx(array('key' => $prefs['shipping_fedex_key'], 'password' => $prefs['shipping_fedex_password'], 'meter' => $prefs['shipping_fedex_meter'])));
}
if (!empty($prefs['shipping_ups_enable']) && $prefs['shipping_ups_enable'] === 'y') {
    require_once 'lib/shipping/provider_ups.php';
    $shippinglib->addProvider(new ShippingProvider_Ups(array('username' => $prefs['shipping_ups_username'], 'password' => $prefs['shipping_ups_password'], 'license' => $prefs['shipping_ups_license'])));
}
if (!empty($prefs['shipping_custom_provider'])) {
    $shippinglib->addProvider(ShippingLib::getCustomShippingProvider($prefs['shipping_custom_provider']));
}