Overridding a Shipping Method - What am I missing(覆盖运输方式 - 我错过了什么)
问题描述
我以前写过很多模块,但由于某种原因,我的运输模块不会覆盖现有的万磁王运输方式.允许吗?我在这里错过了什么?模块名称显示在配置区域的高级选项卡中,因此它正在加载,但什么也没有发生.任何提示?
I've written many many modules before but for some reason my shipping module won't override an exsiting Magneto shipping method. Is that allowed? What am I missing here? The module name shows up in the advanced tab of the configuration area, so it's getting loaded, but nothing is happening. Any hints?
代码
etc/modules/Ssi_Shipping.xml
etc/modules/Ssi_Shipping.xml
<?xml version="1.0"?>
<config>
<modules>
<Ssi_Shipping>
<active>true</active>
<codepool>local</codepool>
</Ssi_Shipping>
</modules>
</config>
local/Ssi/Shipping/etc.xml
local/Ssi/Shipping/etc.xml
<?xml version="1.0"?>
<config>
<modules>
<Ssi_Shipping>
<version>0.1.0</version>
</Ssi_Shipping>
</modules>
<global>
<models>
<shipping>
<rewrite>
<carrier_tablerate>Ssi_Shipping_Model_Carrier_Tablerate</carrier_tablerate>
</rewrite>
</shipping>
</models>
</global>
</config>
local/Ssi/Shipping/Model/Carrier/Tablerate.php
local/Ssi/Shipping/Model/Carrier/Tablerate.php
<?php
class Ssi_Shipping_Model_Carrier_Tablerate
extends Mage_Shipping_Model_Carrier_Tablerate {
public function isActive()
{
Mage::log("here! Ssi_Shipping_Model_Carrier_Tablerate");
// check to see if it's disabled
if (parent::isActive() == false)
return false;
// check in the shopping cart
foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ){
if ($item->getDeliveryFlag() == "test")
return true;
}
// if nothing is found then disable this option.
return false;
}
}
推荐答案
在仔细研究这个之后,我发现覆盖传送控制器的唯一方法是在本地代码文件夹.然后我基本上可以调整代码.
After working through this one a bit, I found that the only way to override the shipping controller was to make a duplicate of the file (and directory structure) in the local code folder. Then I could basically tweak the code.
不知道为什么 Magento 似乎不允许标准覆盖这些传送功能,但至少有一个解决方法.
Not sure why Magento doesn't seem to allow the standard overriding of these shipping functions, but a least there is a work around.
这篇关于覆盖运输方式 - 我错过了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:覆盖运输方式 - 我错过了什么


- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01