I use a cart in the sidebar of the one page checkout.
This display the products and the total price of the cart.
But I also use some additional cost for payment, so it needs to load dynamically, so that when selecting a payment method that does have additional costs, it updated the cart directly.
Currently the cart is only updated on reload of the entire checkout.
How can I achieve that?
Code xml:
<checkout_onepage_index>
<reference name="right">
<block type="checkout/cart_sidebar"
name="cart_sidebar_checkout"
template="checkout/cart/minicart/items.phtml"
after="checkout-progress-wrapper">
<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>
</reference>
</checkout_onepage_index>
Cart:
<?php
$_cartQty = $this->getSummaryCount();
if (empty($_cartQty)) {
$_cartQty = 0;
}
?>
<div class="block block-progress opc-block-progress minicart-wrapper">
<div class="block-title-cartsidebar">WINKELMAND</div>
<?php $_items = $this->getRecentItems() ?>
<?php $countItems = count($_items); ?>
<?php if ($countItems): ?>
<div class="block-items-cartsidebar">
<ul id="cart-sidebar" class="mini-products-list awesome">
<?php foreach ($_items as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach; ?>
<li class="subtotal-side-verzenden">
<span class="label-verzendkosten">Verzendkosten</span>
<span class="label-verzenkosten-price">Gratis</span>
</li>
<?php $cart = Mage::getModel('checkout/cart')->getQuote() ?>
<?php if ($cart->getFoomanSurchargeAmount() > 0) : ?>
<li class="subtotal-side-paymentcost">
<span
class="label-surcharge-description"><?php echo $cart->getFoomanSurchargeDescription() ?></span>
<span
class="label-verzenkosten-price"><?php echo Mage::helper('checkout')->formatPrice($cart->getFoomanSurchargeAmount()) ?></span>
</li>
<?php endif; ?>
<li class="subtotal-side">
<span class="label">
<?php echo $this->__('Totaal') ?><?php echo Mage::helper('checkout')->formatPrice($this->getQuote()->getGrandTotal()) ?>
<?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
<br/>(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?><?php echo Mage::helper('tax')->getIncExcText(true) ?>)
<?php endif; ?>
</li>
</ul>
</div>
<div class="block-wijzig-cartsidebar">
<a class="cart-link-head" href="<?php echo $this->getUrl('checkout/cart'); ?>">
<?php echo $this->__('Wijzig uw winkelmand'); ?>
</a>
</div>
<?php if ($_cartQty && $this->isPossibleOnepageCheckout()): ?>
<?php endif ?>
<?php else: ?>
<p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>
<?php endif ?>
</div>
Best Answer
If you make cart siderbar block as
child block of magento default processbar which is in rwd theme then it is be automatically update as each step of checkout Onepage.
So, you need to change the reference name right (
<reference name="right">
) to checkout.progress<reference name="checkout.progress">
Code:
And add
echo $this->getChildHtml('cart_sidebar_checkout')
code atcheckout/onepage/progress.phtml
.If process bar is working but cartsidebar is not render then you need to add xml code at
checkout.xml
as on right reference ofcheckout_onepage_index
handler, Magento was doing unset all child blocks using:And also call this checkout sidber at
checkout_onepage_progress
handler.