Php Magento自定义签出模块以删除发货地址和方法
我正在尝试为MAGENTO签出创建一个自定义模块,在该模块中,我要删除配送地址和配送方法步骤 因此,我的代码如下所示: app/etc/Mona_Test.xmlPhp Magento自定义签出模块以删除发货地址和方法,php,magento,module,Php,Magento,Module,我正在尝试为MAGENTO签出创建一个自定义模块,在该模块中,我要删除配送地址和配送方法步骤 因此,我的代码如下所示: app/etc/Mona_Test.xml <?xml version="1.0"?> <config> <modules> <Mona_Test> <active>true</active> <codePool>local</codePool>
<?xml version="1.0"?>
<config>
<modules>
<Mona_Test>
<active>true</active>
<codePool>local</codePool>
</Mona_Test>
</modules>
</config>
真的
地方的
app/code/local/Mona/Test/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mona_Test>
<version>1.0</version>
</Mona_Test>
</modules>
<global>
<frontend>
<routers>
<checkout>
<args>
<modules>
<Mona_Test before="Mage_Checkout">Mona_Test</Mona_Test>
</modules>
</args>
</checkout>
</routers>
</frontend>
<blocks>
<test>
<class>Mona_Test_Block</class>
</test>
<checkout>
<rewrite>
<onepage_abstract>Mona_Test_Block_Onepage_Abstract</onepage_abstract>
</rewrite>
</checkout>
</blocks>
<models>
<test>
<class>Mona_Test_Model</class>
</test>
<checkout>
<rewrite>
<type_onepage>Mona_Test_Model_Type_Onepage</type_onepage>
</rewrite>
</checkout>
</models>
</global>
</config>
1
莫纳试验
Mona_测试块
Mona\u测试块\u一页\u摘要
Mona_测试_模型
Mona\u测试\u模型\u类型\u一页
app/code/local/Mona/Test/Blocks/Onepage/Abstract.php
<?php
class Mona_Test_Block_Onepage_Abstract extends Mage_Checkout_Block_Onepage_Abstract {
protected function _getStepCodes()
{
return array('login', 'billing', 'payment', 'review');
}
}
app/code/local/Mona/Test/controllers/OnepageController.php
<?php
require_once 'Mage/Checkout/controllers/OnepageController.php';
class Mona_Test_OnepageController extends Mage_Checkout_OnepageController
{
protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
'review' => '_getReviewHtml',
);
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
$data = $this->getRequest()->getPost('billing', array());
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
if (!isset($result['error'])) {
/* check quote for virtual */
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} else {
$result['goto_section'] = 'payment';
}
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
public function saveShippingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('shipping', array());
$customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
$result = $this->getOnepage()->saveShipping($data, $customerAddressId);
if (!isset($result['error'])) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getShippingMethodsHtml()
);
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
它不起作用。我还应该做什么?任何解决方案都将是巨大的
Go to:
**app\code\core\Mage\Checkout\Block \Onepage.php**
Change the code :
public function getSteps(){
$steps = array();
if (!$this->isCustomerLoggedIn()) {
$steps['login'] = $this->getCheckout()->getStepData('login');
}
//$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
$stepCodes = array('billing', 'payment', 'review');
foreach ($stepCodes as $step) {
$steps[$step] = $this->getCheckout()->getStepData($step);
}
return $steps;
}
Go to:
app\code\core\Mage\Checkout\controllers\ OnepageController.php
Edit:
protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
// 'shipping-method' => '_getShippingMethodsHtml',
'review' => '_getReviewHtml',
);
Also edit saveBillingAction() function
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
//$postData = $this->getRequest()->getPost('billing', array());
//$data = $this->_filterPostData($postData);
$data = $this->getRequest()->getPost('billing', array());
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
if (!isset($result['error'])) {
/* check quote for virtual */
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
}
/*elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
$result['goto_section'] = 'shipping_method';
$result['update_section'] = array(
'name' => 'shipping-method',
'html' => $this->_getShippingMethodsHtml()
);
$result['allow_sections'] = array('shipping');
$result['duplicateBillingInfo'] = 'true';
}*/
//End of Comment by Amit Bera
else {
//$result['goto_section'] = 'shipping';
$result['goto_section'] = 'payment';
}
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
Go to:
\app\code\core\Mage\Sales\Model\Service\ Quote.php
Edit:
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
// if ($addressValidation !== true) {
// Mage::throwException(
//$helper->__('Please check shipping address information. %s', implode(' ', $addressValidation))
//);
//}
// $method= $address->getShippingMethod();
//$rate = $address->getShippingRateByCode($method);
//if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
//Mage::throwException($helper->__('Please specify a shipping method.'));
//}
}
在“帐单信息”选项卡中,您会看到发货地址单选按钮作为帐单地址,只需将其隐藏或删除即可。文件位于
–app\design\frontend\default\your template\your template\
持久\签出\一页\计费,phtml
或
app\design\frontend\default\your template\template\checkout\onepage\billing.phtml
In app\locale\en_US\template\email\sales\ order_new.html
From
{{var order.getShippingAddress().format('html')}}
To
{{var order.getBillingAddress().format('html')}}
And
{{var order.getShippingDescription()}}
Remove it.
你也可以参考下面的链接
你所说的它不工作到底是什么意思。
它意味着默认的签出正在工作,但不是我的自定义模块。@SearchAndResQ明白我想说的吗?我不想更改任何核心文件。我只想通过自定义模块执行此操作。您可以覆盖本地模块中的文件
In app\locale\en_US\template\email\sales\ order_new.html
From
{{var order.getShippingAddress().format('html')}}
To
{{var order.getBillingAddress().format('html')}}
And
{{var order.getShippingDescription()}}
Remove it.