How to set discount amount with discount code when create order programmatically?
<p>I have created an order pragmatically and invoiced it forcefully to complete order when I check order under sales->order it shows the order completed but discount code always with zero amount.How to show given discount with discounted price on products.</p>

<p>below is my code working fine but need to add discount price with discount code.</p>

<pre><code>$customer = Mage::getModel('customer/customer');
    $customer-&gt;setStore($store);
    $quote = Mage::getModel('sales/quote');
    $quote-&gt;setStore($store);

     $quote-&gt;setCustomerEmail($_REQUEST['customerEmail']);
         $addressData = array(
        'firstname' =&gt; ' ',
        'lastname' =&gt; ' ',
        'street' =&gt; ' ',
        'city' =&gt; 'NULL',
        'postcode' =&gt; 'NULL',
        'telephone' =&gt; '123456',
        'country_id' =&gt; 'US',
        'region_id' =&gt; 12,  );
        $billingAddress = $quote-&gt;getBillingAddress()-&gt;addData($addressData);
        $shippingAddress = $quote-&gt;getShippingAddress()-&gt;addData($addressData);



    $productIds=array();
    $products=$_REQUEST['productIds'];
    $products=str_replace(array( '[', ']' ), '',$products);
    $productIds=explode(',',$products);
    $quant=$_REQUEST['quantity'];
    $quant=str_replace(array( '[', ']' ), '',$quant);
    $quantities=explode(',',$quant);
    $salesReport=array_combine($productIds,$quantities);

    foreach($salesReport as $ids=&gt;$qty)
    {
        $product1 = Mage::getModel('catalog/product')-&gt;load($ids); /* HTC Touch Diamond */
        $buyInfo1 = array('qty' =&gt; $qty);
        $quoteItem=$quote-&gt;addProduct($product1, new Varien_Object($buyInfo1));
     }
    $shippingAddress-&gt;setCollectShippingRates(true)-&gt;collectShippingRates()
        -&gt;setShippingMethod('freeshipping_freeshipping')
        -&gt;setPaymentMethod('ebs');

    $quote-&gt;getPayment()-&gt;importData(array('method' =&gt; 'ebs'));
    $quote-&gt;setDiscountAmount('5');
    $quote-&gt;setCouponCode("SALE");
    $quote-&gt;collectTotals()-&gt;save();
    $service = Mage::getModel('sales/service_quote', $quote);
    $service-&gt;submitAll();
    $order = $service-&gt;getOrder();
</code></pre>