至于 a) 部分,您将需要覆盖控制器Mage_Checkout_OnepageController
。为此,请创建您自己的模块(我假设您知道如何执行此操作),并且在 app/code/local/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/code/local/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>
甚至更简单,您可以使用自定义设计文件夹覆盖 shipping.phtml 模板。为了评估您的自定义数据,模型Mage_Checkout_Model_Type_Onepage
会处理方法中的数据saveShipping()
,所以我想这将是寻找实现您的自定义逻辑的好点。