Magento新的基本运输方式没有显示在前端

时间:2012-05-22 09:08:23

标签: magento module shipping

我正在尝试创建一种新的送货方式。此方法允许用户从特定仓库中收集项目。所以参与的确不多。

我已经在线跟踪了几个,并且已经构建并安装了我的模块。它正在后端工作,我可以启用它,并设置各种值。

当我使用前端结帐时....甚至使用以下代码:

法师:: getSingleton( '发货/配置') - > getAllCarriers();

我没有获得新的送货方法名称输出。

我在前端结账时收到的消息是:

很抱歉,目前此订单没有报价。

即使我启用了其他送货方式。


我有另一个使用的扩展(关于位于几个仓库的库存)。作为此扩展的一部分,它列出了可用的运输选项......以便我可以为特定仓库分配特定选项。我的新送货方式未列出送货选项列表。


我似乎已经拥有了所有必需品。我的另一个扩展是没有采用这种方法......所以必须遗漏一些东西。 另外,鉴于我在前端没有运输选项......令人困惑。 在这一段时间......调试:(

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我正在创建一种复杂的送货方式......而不是免费送货方式的副本。事实证明我实际上需要一份免费送货方法,所以让我的生活更轻松...... 这比我想象的要容易。

不想发布我的所有代码(您还需要一个config.xml和system.xml文件)但是我的运营商模型逻辑文件是:

class Myco_Clickcollectshipping_Model_Carrier_Mymethod extends Mage_Shipping_Model_Carrier_Abstract {

protected $_code = 'mymethod ';

public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{

    if (!$this->getConfigFlag('active')) {
        return false;
    }

    $freeBoxes = 0;
    if ($request->getAllItems()) {
        foreach ($request->getAllItems() as $item) {
            if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) {
                $freeBoxes+=$item->getQty();
            }
        }
    }

    $this->setFreeBoxes($freeBoxes);

    $result = Mage::getModel('shipping/rate_result');
    if ($this->getConfigData('type') == 'O') { // per order
        $shippingPrice = $this->getConfigData('price');
    } elseif ($this->getConfigData('type') == 'I') { // per item
        $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
    } else {
        $shippingPrice = false;
    }

    $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);

    if ($shippingPrice !== false) {
        $method = Mage::getModel('shipping/rate_result_method');

        $method->setCarrier('mymethod ');
        $method->setCarrierTitle($this->getConfigData('title'));

        $method->setMethod('mymethod ');
        $method->setMethodTitle($this->getConfigData('name'));

        if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
            $shippingPrice = '0.00';
        }

        $method->setPrice($shippingPrice);
        $method->setCost($shippingPrice);

        $result->append($method);

    }

    return $result;
}

public function getAllowedMethods()
{
    return array('mymethod ' => $this->getConfigData('name'));
}
}