至於部分a),您將需要覆蓋控制器Mage_Checkout_OnepageController
。爲此創建自己的模塊(我假設你知道如何做到這一點),並在應用程序/代碼/本地/ YourModule的/ etc/config.xml中你應該有這樣的一部分:
<config>
...
<frontend>
<routers>
<checkout>
<args>
<modules>
<YourModule_Checkout before="Mage_Checkout">YourModule_Checkout</YourModule_Checkout>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>
然後在app /代碼/本地/ YourModule/controllers/OnepageController.php你想覆蓋的行爲,所以當你點擊保存帳單按鈕,你將永遠降落在發貨頁面。
include_once("Mage/Checkout/controllers/OnepageController.php");
class YourModule_Checkout_OnepageController extends Mage_Checkout_OnepageController
{
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);
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 { // Removed elseif block here which usually skips over shipping if you selected to use the same address as in billing
$result['goto_section'] = 'shipping';
}
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
}
然後對於b)部分,你有兩個選擇。不管是你指出你使用XML佈局系統設置不同的模板爲shipping.phtml:
<checkout_onepage_index>
<reference name="checkout.onepage.shipping">
<action method="setTemplate">
<new>my_shipping.phtml</new>
</action>
</reference>
</checkout_onepage_index>
或更容易,你overwritte使用自定義的設計文件夾中的shipping.phtml模板。 若要評估您的自定義數據,模型Mage_Checkout_Model_Type_Onepage
處理saveShipping()
方法中的數據,所以我想這是尋找實現您的自定義邏輯的好點。