gpt4 book ai didi

Magento 结帐步骤

转载 作者:行者123 更新时间:2023-12-01 19:37:08 25 4
gpt4 key购买 nike

我需要将发货地址链接到产品,而不是订单。有没有一种简单的方法可以从结帐过程中删除该步骤并将其包含到产品页面中?

我试图从结帐布局中删除装运 block ,但它仍保留在结帐步骤中。

提前致谢。

最佳答案

您必须为您的模块重写下一个文件:

  • 阻止/Checkout/Block/Onepage/Shipping/Method.php
  • Controller /Checkout/controllers/OnepageController.php
  • 模型/Checkout/Model/Type/Onepage.php
  • 配置/Checkout/etc/config.xml

1。 block (Method.php)

class Yourmodule_Checkout_Block_Onepage_Shipping_Method extends Mage_Checkout_Block_Onepage_Shipping_Method
{
public function isShow()
{
return false;
}
}

2。 Controller (OnepageController.php)

require_once 'Mage/Checkout/controllers/OnepageController.php';

class Yourmodule_Checkout_OnepageController extends Mage_Checkout_OnepageController
{
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->_getPaymentMethodsHtml()
);
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('billing', array());
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
$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'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
}
else {
$result['goto_section'] = 'shipping';
}
}

$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
}

3。模型(Onepage.php)

class Yourmodule_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
{
protected function validateOrder()
{
$helper = Mage::helper('checkout');
if ($this->getQuote()->getIsMultiShipping()) {
Mage::throwException($helper->__('Invalid checkout type.'));
}

$addressValidation = $this->getQuote()->getBillingAddress()->validate();
if ($addressValidation !== true) {
Mage::throwException($helper->__('Please check billing address information.'));
}

if (!($this->getQuote()->getPayment()->getMethod())) {
Mage::throwException($helper->__('Please select valid payment method.'));
}
}
}

4。配置(config.xml)

<?xml version="1.0" encoding="UTF-8"?>

<config>
<modules>
<Yourmodule_Checkout>
<version>0.0.2</version>
</Yourmodule_Checkout>
</modules>
<global>
<models>
<checkout>
<rewrite>
<type_onepage>Yourmodule_Checkout_Model_Type_Onepage</type_onepage>
</rewrite>
</checkout>
</models>

<blocks>
<checkout>
<rewrite>
<onepage_shipping_method>Yourmodule_Checkout_Block_Onepage_Shipping_Method</onepage_shipping_method>
</rewrite>
</checkout>
</blocks>
</global>

<frontend>
<routers>
<checkout>
<args>
<modules>
<yourmodule before="Mage_Checkout">Yourmodule_Checkout</yourmodule>
</modules>
</args>
</checkout>
</routers>
</frontend>

</config>

4。在 app/etc/modules/Yourmodule_All.xml 中注册你的模块

<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Yourmodule_Checkout>
<active>true</active>
<codePool>local</codePool>
</Yourmodule_Checkout>
</modules>
</config>

适合您的文章:

1 2 3 4

关于Magento 结帐步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12213225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com