0
votes

Recently I have added attributes to the product color and size. (configurable products) When we add to cart, and go to view cart then we see the products with attributes color and size.

enter image description here

I added shopping cart block in onepage checkout in app/design/frontend/smartwave/porto/layout/iwd_opc.xml

<reference name="content">
        <block type="checkout/cart" name="checkout.cart" template="checkout/cart.phtml">
            <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
            <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
            <block type="checkout/cart_sidebar" name="checkout.cart.sidebar" as="sidebar" template="checkout/cart/sidebar.phtml"/>
        </block>
    </reference>

I get the following page after adding shopping cart layout to onepage cart

enter image description here

Now I am stuck here, how should I get the attributes name here? I have set attributes to be visible on frontend from backend as well.

Code to display products in the cart is on app/design/frontend/smartwave/porto/template/checkout/cart.phtml

<?php foreach($this->getItems() as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach ?>

Logic of the code is written over here: app/code/core/Mage/Checkout/Block

public function getItems()
{
    if ($this->getCustomItems()) {
        return $this->getCustomItems();
    }

    return parent::getItems();
}

Another way of displaying the products to the cart is: But I dont want to use this code to display the list in the cart:

$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
$productName = $item->getProduct()->getName();
$productPrice = $item->getProduct()->getPrice();

echo "Name: ".$productName." Price: ".$productPrice;
}

I have also tried to add attributes in xml file app/code/core/Mage/Sales/etc/config.xml

            <item>
                <product_attributes>
                    <color/>
                    <size/> 
                    <condition/>
                    <sku/>
                    <type_id/>
                    <name/>
                    <status/>
                    <visibility/>
                    <price/>
                    <weight/>
                    <url_path/>
                    <url_key/>
                    <thumbnail/>
                    <small_image/>
                    <tax_class_id/>
                    <special_from_date/>
                    <special_to_date/>
                    <special_price/>
                    <cost/>
                    <is_recurring/>
                    <recurring_profile/>
                    <gift_message_available/>
                    <msrp_enabled/>
                    <msrp/>
                    <msrp_display_actual_price_type/>
                </product_attributes>
            </item>

So I have just copied the block to the onepage checkout page, but I am not able to understand that why the onepage checkout page is not showing product's size and color ("/onepage/") and it is strange that color and sizes can be seen on checkout page ("checkout/cart/") Thanks in advance

2

2 Answers

1
votes

I believe you have not added itemrendere in your layout. Basically cart items are listed using checkout/cart/item/default.phtml.

I will suggest to look over checkout.xml layout file and copy the whole layout <reference name="content"> node into your iwd and then start removing the template includes which you do not require.

Another method is using layout updates which will extend your iwd layout to checkout_cart. Which will do same thing above. You need to use <remove name=""> tag to remove extra cart includes from your iwd handle.

0
votes

Finally I found the solution with the help of Blastfreak Include following lines in app/design/frontend/smartwave/porto/layout/iwd_opc.xml

<reference name="content">
        <block type="checkout/cart" name="checkout.cart" template="checkout/cart.phtml">
            <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
            <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
            <block type="checkout/cart_sidebar" name="checkout.cart.sidebar" as="sidebar" template="checkout/cart/sidebar.phtml"/>
            <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>
    </reference>

Output page:

enter image description here