We can achieve it using the two carts for one customer at the same time. When customer will choose the items then remaining items move to the temporary cart. And after place the order or for edit the selected items we can get the un-selected items from the temporary cart against the customer. I have implemented it using the described way. I hope it will help some one else.
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Namespace_CustomOrder>
<version>0.1.0</version>
</Namespace_CustomOrder>
</modules>
<global>
<models>
<Namespace_customorder>
<class>Namespace_CustomOrder_Model</class>
</Namespace_customorder>
</models>
<blocks>
<!-- <customorder>
<class>Namespace_CustomOrder_Block</class>
</customorder>-->
<checkout><!-- alias of the block group you are rewriting -->
<rewrite><!-- reserved tag: specify that you are rewriting something -->
<cart>Namespace_CustomOrder_Block_Checkout_Cart</cart> <!-- tag: the rest of the alias of the class you are rewriting. value: the name of your class that rewrites the core class -->
</rewrite>
</checkout>
</blocks>
<resources>
<Namespace_customorder_setup>
<setup>
<module>Namespace_CustomOrder</module>
</setup>
</Namespace_customorder_setup>
</resources>
<helpers>
<Namespace_customorder>
<class>Namespace_CustomOrder_Helper</class>
</Namespace_customorder>
</helpers>
<events>
<sales_order_place_after>
<observers>
<Namespace_customorder>
<type>singleton</type>
<class>Namespace_customorder/observer</class>
<method>handleOrderComplete</method>
</Namespace_customorder>
</observers>
</sales_order_place_after>
</events>
</global>
<frontend>
<routers>
<!-- <Namespace_customorder>
<use>standard</use>
<args>
<module>Namespace_CustomOrder</module>
<frontName>customorder</frontName>
</args>
</Namespace_customorder>-->
<!-- Overriding the checkout controller for custom order checkout -->
<checkout>
<args>
<modules>
<Namespace_CustomOrder before="Mage_Checkout">Namespace_CustomOrder</Namespace_CustomOrder>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>
Block/Checkout/Cart.php
class Namespace_CustomOrder_Block_Checkout_Cart extends Mage_Checkout_Block_Cart
{
/**
* Return customer quote items
*
* @return array
*/
public function getItems()
{
$currentQuoteItems = parent::getItems();
foreach ($currentQuoteItems as $currentQuoteItem){
$currentQuoteItem->setSelected(true);
}
$temporaryQuoteItems = Mage::helper('Namespace_customorder')->getTemporaryQuote()->getAllVisibleItems();
return array_merge($temporaryQuoteItems,$currentQuoteItems);
}
}
controllers/CartController.php
<?php
require_once 'Mage/Checkout/controllers/CartController.php';
class Namespace_CustomOrder_CartController extends Mage_Checkout_CartController
{
public function updatePostAction()
{
if (!$this->_validateFormKey()) {
$this->_redirect('*/*/');
return;
}
$updateAction = (string)$this->getRequest()->getParam('update_cart_action');
if($updateAction == 'custom_checkout'){
$temporaryQuote = Mage::helper('Namespace_customorder')->getTemporaryQuote();
$currentQuote = $this->_getCart()->getQuote();
// $temporaryQuote->removeAllItems();
// $temporaryQuote->collectTotals()->save();
$selectedItems = $this->getRequest()->getParam('selected_items');
$currentCartVisibleItems = $this->_getCart()->getQuote()->getAllVisibleItems();
foreach ($currentCartVisibleItems as $visibleItem){
if(!in_array($visibleItem->getId(), $selectedItems)){
$this->moveItem($visibleItem, $temporaryQuote);
$currentQuote->removeItem($visibleItem->getId());
}
}
// $currentQuote->collectTotals()->save();
$temporaryCartVisibleItems = $temporaryQuote->getAllVisibleItems();
foreach ($temporaryCartVisibleItems as $visibleItem){
if(in_array($visibleItem->getId(), $selectedItems)){
$this->moveItem($visibleItem, $currentQuote);
$temporaryQuote->removeItem($visibleItem->getId());
}
}
$currentQuote->collectTotals()->save();
$temporaryQuote->collectTotals()->save();
$this->_goBack();
}else {
return parent::updatePostAction(); // TODO: Change the autogenerated stub
}
}
private function moveItem($item, $quote){
$found = false;
foreach ($quote->getAllVisibleItems() as $quoteItem) {
if ($quoteItem->compare($item)) {
$quoteItem->setQty($quoteItem->getQty() + $item->getQty());
$found = true;
break;
}
}
if (!$found) {
$newItem = clone $item;
$quote->addItem($newItem);
if ($item->getHasChildren()) {
foreach ($item->getChildren() as $child) {
$newChild = clone $child;
$newChild->setParentItem($newItem);
$quote->addItem($newChild);
}
}
}
$quote->collectTotals()->save();
}
}
Helper/Data.php
class Namespace_CustomOrder_Helper_Data extends Mage_Core_Helper_Abstract {
public function getTemporaryQuote(){
$temporaryQuote = null;
$customerSession = Mage::getSingleton('customer/session');
if(!($temporaryQuote = $customerSession->getTemporaryQuote()))
{
$customer = $customerSession->getCustomer();
$temporaryQuote = Mage::getModel('sales/quote')
->getCollection('sales/quote')
->addFieldToFilter('customer_id', $customer->getId())
->addFieldToFilter('is_temporary', TRUE)
->getFirstItem();
if (!$temporaryQuote->getId()) {
$temporaryQuote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId())
->setIsActive(0)
->setCustomer($customer)
->setCustomerId($customer->getId())
->setIsTemporary(TRUE)
->save();
}
$customerSession->setTemporaryQuote($temporaryQuote);
}
return $temporaryQuote;
}
public function setTemporaryAsCurrentQuote(){
if($temporaryQuote = Mage::helper('Namespace_customorder')->getTemporaryQuote()) {
$temporaryQuote->setIsActive(1)->setIsTemporary(0)->save();
Mage::getSingleton('customer/session')->setTemporaryQuote(null);
}
}
}
Model/Observer.php
class Namespace_CustomOrder_Helper_Data extends Mage_Core_Helper_Abstract {
public function getTemporaryQuote(){
$temporaryQuote = null;
$customerSession = Mage::getSingleton('customer/session');
if(!($temporaryQuote = $customerSession->getTemporaryQuote()))
{
$customer = $customerSession->getCustomer();
$temporaryQuote = Mage::getModel('sales/quote')
->getCollection('sales/quote')
->addFieldToFilter('customer_id', $customer->getId())
->addFieldToFilter('is_temporary', TRUE)
->getFirstItem();
if (!$temporaryQuote->getId()) {
$temporaryQuote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId())
->setIsActive(0)
->setCustomer($customer)
->setCustomerId($customer->getId())
->setIsTemporary(TRUE)
->save();
}
$customerSession->setTemporaryQuote($temporaryQuote);
}
return $temporaryQuote;
}
public function setTemporaryAsCurrentQuote(){
if($temporaryQuote = Mage::helper('Namespace_customorder')->getTemporaryQuote()) {
$temporaryQuote->setIsActive(1)->setIsTemporary(0)->save();
Mage::getSingleton('customer/session')->setTemporaryQuote(null);
}
}
}
sql/namespace_customorder_setup/install-0.1.0.php
$installer = Mage::getResourceModel('sales/setup', 'default_setup');
$installer->startSetup();
//$installer->getConnection()->dropColumn($installer->getTable('sales_flat_quote_item'), 'selected');
//$installer->getConnection()->dropColumn($installer->getTable('sales_flat_order_item'), 'selected');
/*$installer->addAttribute('quote_item', 'selected', array(
'type' => Varien_Db_Ddl_Table::TYPE_BOOLEAN,
'required' => false,
'default' => true
));
$installer->addAttribute('order_item', 'selected', array(
'type' => Varien_Db_Ddl_Table::TYPE_BOOLEAN,
'required' => false,
'default' => true
));*/
$installer->addAttribute('quote', 'is_temporary', array(
'type' => Varien_Db_Ddl_Table::TYPE_BOOLEAN,
'required' => false,
'default' => false
));
$installer->endSetup();
To call my controller i have also edited the checkout/cart.phtml and for selection checkout/cart/item/default.phtml