Magento结账步骤

时间:2012-08-31 10:08:38

标签: magento checkout

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

我尝试从结帐布局中删除发货区块,但它仍然保留在结帐步骤中。

提前致谢。

1 个答案:

答案 0 :(得分:3)

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

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

1。阻止(Method.php)

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

2。控制器(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