I am new in Magento. I am scratching my head for 2 days for a issue. I have built a custom page using which I can pass some static data to Paypal for make a payment. It is working. But now I am wanting that from magento when user add some products to cart and click proceed button then it will redirect my custom page and pass to paypal for payment. I want to know how can I pass the data of products which are added to cart and pass it to my custom page?and also want to to how to retrieve the data to show on the products details on my custom page and pass the data to paypal for payment?

2 Answers 2


You can use below code to get all products which are added in shopping cart:

$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
    $productId = $item->getProduct()->getId();

In the above code I have shown only product id. You can get cart's rest data also.

Please let me know if you have any query.

  • Thanks for your answer. I will try it man. Currently I am facing a problem. After adding product to cart and click on Proceed it go to default checkout page . How can I change the redirection to my custom page? Commented Aug 1, 2016 at 11:39
  • $productId = $item->getProduct()->getId(); this code is not showing anything. But $cart->getAllItems() is showing all added cart items. Commented Aug 2, 2016 at 8:21

you can use the below code to show cart in cms page

follow below steps:

admin->CMS->Pages->open the page you want to show cart -> Open design tab

In page layout section add below code:

    <reference name="content">
        <block type="checkout/cart" name="checkout.cart">
            <action method="setCartTemplate"><value>checkout/cart.phtml</value></action>
            <action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
            <action method="chooseTemplate"/>
            <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/item/default.phtml</template></action>
            <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/item/default.phtml</template></action>
            <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/item/default.phtml</template></action>

            <block type="core/text_list" name="checkout.cart.top_methods" as="top_methods" translate="label">
                <label>Payment Methods Before Checkout Button</label>
                <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>

            <block type="page/html_wrapper" name="checkout.cart.form.before" as="form_before" translate="label">
                <label>Shopping Cart Form Before</label>

            <block type="core/text_list" name="checkout.cart.methods" as="methods" translate="label">
                <label>Payment Methods After Checkout Button</label>
                <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
                <block type="checkout/multishipping_link" name="checkout.cart.methods.multishipping" template="checkout/multishipping/link.phtml"/>

            <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
            <block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/>
            <block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>

            <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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