2015-05-01 100 views
0

我試圖在結帳頁面上顯示更新購物車,有什麼方法可以顯示嗎?如何在Magento Checkout頁面上顯示更新購物車?

<?php echo $this->getChildHtml('form_before') ?> 
    <form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post"> 
    <?php echo $this->getBlockHtml('formkey'); ?> 
<button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update"><?php echo $this->__('Update Shopping Cart'); ?></button> 
</form> 

回答

0

首先,您需要爲模板中的購物車更新操作添加表單。請注意,您必須將其添加到任何其他表單之外。然後,您將需要添加自己的模塊與自己的前端控制器和操作,將等待表單提交,並將用戶重定向到結帳。 形式的作用應該是: <form action="<?php echo $this->getUrl('frontNameOfYourController'); ?>" method="post"> //Don't forget to add a session key to this form. <div><input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /></div> 在你等/ config.xml中添加此: <frontend> <routers> <modulename> <use>standard</use> <args> <module>Package_Modulename</module> <frontName>frontNameOfYourController</frontName> </args> </modulename> </routers> </frontend> 然後在你的控制器/文件夾添加IndexController.php: class Package_Modulename_IndexController extends Mage_Core_Controller_Front_Action { //Method for submitting the action public function indexAction() { //This action should receive the posted data from the form, please refer to the methods: public function updatePostAction(), protected function _updateShoppingCart() for updating the cart and protected function _emptyShoppingCart() for emptying the cart in code/core/Mage/Checkout/controllers/CheckoutController.php //The difference in your method should be that it should redirect to your checkout page once the form is submitted. } } 我認爲這會爲你做這項工作。如果你想更多的解釋如何寫方法留下評論。

0

添加在local.xml文件,

應用程序/設計/前端/ YOURPACKAGE/YOURTHEME /佈局/ local.xml中下面的代碼

<checkout_onepage_index translate="label"> 
    <reference name="right"> 
     <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-"> 
      <action method="addItemRender"> 
       <type>simple</type> 
       <block>checkout/cart_item_renderer</block> 
       <template>checkout/cart/sidebar/default.phtml</template> 
      </action> 

      <action method="addItemRender"> 
       <type>grouped</type> 
       <block>checkout/cart_item_renderer_grouped</block> 
       <template>checkout/cart/sidebar/default.phtml</template> 
      </action> 

      <action method="addItemRender"> 
       <type>configurable</type> 
       <block>checkout/cart_item_renderer_configurable</block> 
       <template>checkout/cart/sidebar/default.phtml</template> 
      </action> 

      <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout"> 
       <label>Shopping Cart Sidebar Extra Actions</label> 
      </block> 
     </block> 
    </reference> 
</checkout_onepage_index> 
相關問題