Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Trouble setting prices in customer orders. 
 
CVinson86
Member
 
Avatar
Total Posts:  40
Joined:  2008-06-18
 

Hey everyone,
I’m working on a custom purchase order page in the backend.  I can successfully create an order and place it, but I’m having a hard time setting a custom price.  I have the following code.

$customerObj Mage::getModel('customer/customer')->load($customerId);
        
$quoteObj Mage::getModel('sales/quote')->assignCustomer($customerObj);
        
$quoteObj->reserveOrderId();

        
$productModel Mage::getModel('catalog/product');
        foreach(
$orderList as $item{
            
foreach($item as $k=>$v$$k=$v}
            $productObj 
$productModel->loadByAttribute('sku',$sku);
            if(
$qty>0){
                $quoteItem
=Mage::getModel('sales/quote_item')->setProduct($productObj);
                
$quoteItem->setQuote($quoteObj);
                
$quoteItem->setPrice($price);
                
$quoteItem->setQty($qty);
                
$quoteObj->addItem($quoteItem);
            
}
        }
        
...

Within the for loops, a call to $quoteItem->getPrice() returns the value I set.  But later in the code, after I call $quoteObj->collectTotals(), this code:

foreach ($quoteObj->getAllItems() as $item{
            Mage
::getModel('adminhtml/session')->addNotice(DEBUG_SEPARATOR."PRICE:"$item->getPrice());
        
}

will return the price of the object as set in the store.  So, does anyone know how I can make the price stick?
Thanks for reading,
-Colin

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top