Как изменить название способа доставки на странице оформления заказа magento
Я хочу изменить название способа доставки на странице оформления заказа, как показано на рисунке ниже -
Я пытался выполнить следующие ссылки ниже, но не знаю, какой класс блока перезаписать.
Http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/
Вот что я попробовал -
<blocks>
<methods>
<rewrite>
<shipping_method>Emizentech_Restricteway_Checkout_Block_Onepage_Shipping_Method</shipping_method>
</rewrite>
</methods>
</blocks>
И создал этот файл в моем модуль --
Emizentech/Restricteway/Checkout/Block/Onepage/Shipping/Method.php
РЕДАКТИРОВАТЬ:- Я хочу изменить название "Способ доставки" на "Способ разгрузки" только в том случае, если общая сумма моих предложений превышает $1100.
Вот мои обновленные файлы- config.xml-
<config>
<modules>
<Emizentech_Restricteway>
<version>1.0</version>
</Emizentech_Restricteway>
</modules>
<global>
<blocks>
<restricteway>
<class>Emizentech_Restricteway_Block</class>
</restricteway>
<checkout>
<rewrite>
<onepage_shipping_method>Emizentech_Restricteway_Block_Checkout_Onepage_Shipping_Method
</onepage_shipping_method>
</rewrite>
</checkout>
</blocks>
<helpers>
<restricteway>
<class>Emizentech_Restricteway_Helper</class>
</restricteway>
</helpers>
</global>
</config>
Emizentech/Restricteway/Block/Checkout/Onepage/Shipping/Method.php-
class Emizentech_Restricteway_Block_Checkout_Onepage_Shipping_Method extends Mage_Checkout_Block_Onepage_Shipping_Method
{
protected function _construct()
{
$cartGrandTotal = Mage::helper('checkout')->getQuote()->getGrandTotal();
$conditionOrderAmount = Mage::getStoreConfig('setting/setorder/order_amount');
if($cartGrandTotal > $conditionOrderAmount)
{
$this->getCheckout()->setStepData('shipping_method', array(
'label' => Mage::helper('checkout')->__('Unloading Method'),
'is_show' => $this->isShow()
));
}
else
{
$this->getCheckout()->setStepData('shipping_method', array(
'label' => Mage::helper('checkout')->__('Shipping Method 456'),
'is_show' => $this->isShow()
));
parent::_construct();
}
}
/**
* Retrieve is allow and show block
*
* @return bool
*/
public function isShow()
{
return !$this->getQuote()->isVirtual();
}
}
2 answers
Во-первых, вам необходимо обновить для config.xml как показано ниже, измените
<blocks>
<methods>
<rewrite>
<shipping_method>Emizentech_Restricteway_Checkout_Block_Onepage_Shipping_Method</shipping_method>
</rewrite>
</methods>
</blocks>
До
<blocks>
<restricteway>
<class>Emizentech_Restricteway_Block</class>
</restricteway>
<checkout>
<rewrite>
<onepage_shipping_method>Emizentech_Restricteway_Block_Checkout_Onepage_Shipping_Method</onepage_shipping_method>
</rewrite>
</checkout>
</blocks>
Файл блока Emizentech/Restricteway/Checkout/Block/Onepage/Shipping/Method.php вы создали тоже неправильно, вам нужно создать Emizentech/Restricteway/Block/Checkout/Onepage/Shipping/Method.php файл Теперь в вашем файле добавьте ниже код.
class Emizentech_Restricteway_Block_Checkout_Onepage_Shipping_Method extends Mage_Checkout_Block_Onepage_Shipping_Method
{
protected function _construct()
{
if(Mage::getModel('checkout/cart')->getQuote()->getGrandTotal() > 1100){
$this->getCheckout()->setStepData('shipping_method', array(
'label' => Mage::helper('checkout')->__('Unloading Method'),
'is_show' => $this->isShow()
));
}else{
$this->getCheckout()->setStepData('shipping_method', array(
'label' => Mage::helper('checkout')->__('Shipping Method'),
'is_show' => $this->isShow()
));
parent::_construct();
}
}
}
ПРАВКИ:
app\etc\modules\Emizentech_Restricteway.xml
<?xml version="1.0"?>
<config>
<modules>
<Emizentech_Restricteway>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Emizentech_Restricteway>
</modules>
</config>
App\code\local\Emizentech\Restricteway\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<Emizentech_Restricteway>
<version>0.1.0</version>
</Emizentech_Restricteway>
</modules>
<global>
<helpers>
<restricteway>
<class>Emizentech_Restricteway_Helper</class>
</restricteway>
</helpers>
<blocks>
<restricteway>
<class>Emizentech_Restricteway_Block</class>
</restricteway>
<checkout>
<rewrite>
<onepage_shipping_method>Emizentech_Restricteway_Block_Checkout_Onepage_Shipping_Method</onepage_shipping_method>
</rewrite>
</checkout>
</blocks>
</global>
</config>
App\code\local\Emizentech\Restricteway\Block\Checkout\Onepage\Shipping\Method.php
<?php
class Emizentech_Restricteway_Block_Checkout_Onepage_Shipping_Method extends Mage_Checkout_Block_Onepage_Shipping_Method
{
protected function _construct()
{
$cartGrandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();
$conditionOrderAmount = Mage::getStoreConfig('setting/setorder/order_amount');
if($cartGrandTotal > $conditionOrderAmount)
{
$this->getCheckout()->setStepData('shipping_method', array(
'label' => Mage::helper('checkout')->__('Unloading Method'),
'is_show' => $this->isShow()
));
}
else
{
$this->getCheckout()->setStepData('shipping_method', array(
'label' => Mage::helper('checkout')->__('Shipping Method 456'),
'is_show' => $this->isShow()
));
parent::_construct();
}
}
}
Этот код работает для меня. Пожалуйста, сверьтесь со своим кодом.
Измените файл ниже, если ваш магазин на английском языке
app/locale/en_US/Mage_Checkout.csv
Изменение
"Shipping Method","Shipping Method"
До
"Shipping Method","<Your Title>"