Пример #1
0
 * @category  X-Cart 5
 * @author    Qualiteam software Ltd <*****@*****.**>
 * @copyright Copyright (c) 2011-2015 Qualiteam software Ltd <*****@*****.**>. All rights reserved
 * @license   http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement
 * @link      http://www.x-cart.com/
 */
return function () {
    // Search for USPS shipping methods
    $methods = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->findBy(array('processor' => 'usps'));
    // Run-time cach of shipping method codes
    $codes = array();
    foreach ($methods as $method) {
        $name = $method->getTranslation('en')->getName();
        if ($name) {
            $name = preg_replace('/^(U\\.S\\.P\\.S\\. )/', '', $name);
            // Get code prefix (e.g. D-23-...)
            $codePrefix = preg_replace('/^([DI]-\\d+-).*$/', '\\1', $method->getCode());
            // Generate new code from method name
            $code = \XLite\Module\CDev\USPS\Model\Shipping\Processor\USPS::getUniqueMethodID($name);
            if (isset($codes[$code])) {
                // Remove duplicate shipping method
                \XLite\Core\Database::getEM()->remove($method);
            } else {
                // Set new method code
                $method->setCode($codePrefix . $code);
                $codes[$code] = 1;
            }
        }
    }
    \XLite\Core\Database::getEM()->flush();
};
Пример #2
0
 /**
  * Check if 'Cash on delivery (FedEx)' payment method enabled
  *
  * @return boolean
  */
 protected function isUSPSCODPaymentEnabled()
 {
     return \XLite\Module\CDev\USPS\Model\Shipping\Processor\USPS::isCODPaymentEnabled();
 }