7

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>
  • can you please show your code. – Amit Bera Jun 29 '15 at 7:05
  • @AmitBera Edit my question – Henk Z Jun 29 '15 at 7:12
1

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:

<checkout_onepage_index>
    <reference name="checkout.progress"> <!--change the right to checkout.progress -->
        .....
        </block>
    </reference>
</checkout_onepage_index>

And add echo $this->getChildHtml('cart_sidebar_checkout') code at checkout/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 of checkout_onepage_index handler, Magento was doing unset all child blocks using:

 <action method="unsetChildren"></action>

And also call this checkout sidber at checkout_onepage_progress handler.

<checkout_onepage_progress>
    <reference name="root">
        <block type="checkout/cart_sidebar" name="cart_sidebar_checkout" template="checkout/cart/minicart/items.phtml" >
            <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_progress>
  • Thanks! Edit the code as you described. Process bar is working and cart is displayed in the process bar. But the cart is not updating on each step. It is still only updating on refresh. I also set action method to unsetChilderen. – Henk Z Jun 29 '15 at 9:54
  • answer update.. no need to add <action method="unsetChildren"></action> – Amit Bera Jun 29 '15 at 9:59
  • I removed the action method unsetChilderen, but it still does not update. – Henk Z Jun 29 '15 at 10:12
  • Inside the rwd theme I also do not see any <reference name="checkout.progress"> in the checkout.xml file – Henk Z Jun 29 '15 at 10:23
  • let me check... – Amit Bera Jun 29 '15 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.