Showing results for 
Search instead for 
Did you mean: 

Create Order Programmatically. cant use variables in function

Create Order Programmatically. cant use variables in function


I´ve got the plessure to take over the magento shop from some one else Smiley Very Happy:/

And i have a problem. 

the guy before my have made a form for on every produkt and when the costumer use this. we get an mail with the information, and the costumer get sendt to an success page. NOTE! No order in magento order page, only on emal

The problem is. Sometimes the emails doesent get sendt, and we dont get an order. 

SO, i want to program a order creat function when the costumer get to the success page. 

I can get the function to work when I use plan text in the function, but when i want to use my variables i get from the from, i get blank in the order! 


$details = $this->getDetails();
$conferance_name = $details['product_name'];
$hotel = $details['hotelval'];
$date = $details['dateval'];
$ogtitel = $details['navn_title'];
$virksomhed = $details['virksomhed'];
$adresse = $details['adresse'];
$postnr = $details['postnr'];
$by = $details['by'];
$telefon = $details['telefon'];
$email = $details['email'];
$kommentarer = $details['kommentarer'];

require_once 'app/Mage.php';

$order = create();
echo $order;

function create()

        $storeId = 1;
        if (!$storeId) {
            $storeIds = Mage::app()->getWebsite($customer->getWebsiteId())->getStoreIds();
            $storeId = current($storeIds);

        $order = Mage::getModel('sales/order')

        $orderPayment = Mage::getModel('sales/order_payment')
              ->setPo_number(' - ');

        $billingAddress = Mage::getModel('sales/order_address');
        $shippingAddress = Mage::getModel('sales/order_address');


              // set Customer data

              // set Billing Address



              ->setShippingDescription('Free Shipping - Free');

                $orderItem = Mage::getModel('sales/order_item')
                    ->setName('custom product name')




    return $order;


<?php /*?><p> Conference Name : <?php echo $this->__($conferance_name) ?></p>
<p> Name : <?php echo $this->__($ogtitel) ?></p>
<p> Email : <?php echo $this->__($email) ?></p>
<p> Hotel : <?php echo $this->__($hotel) ?></p>
<p> Date : <?php echo $this->__($date) ?></p>
<p> adresse : <?php echo $this->__($adresse) ?></p>
<p> postnr : <?php echo $this->__($postnr) ?></p>
<p> by : <?php echo $this->__($by) ?></p>
<p> telefon : <?php echo $this->__($telefon) ?></p>
<p> Kommentarer : <?php echo $this->__($kommentarer) ?></p><?php */?>

<h1>Tak for din tilmelding</h1>
<p>Du er nu tilmeldt konferencen <strong><?php echo $this->__($conferance_name) ?></strong> d. <?php echo $this->__($date) ?> i <?php echo $this->__($hotel) ?></p>
<br />
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('form-success')->toHtml(); ?>

NOTE i can use the variable to echo on the success page.

Hope you can help! Smiley Very Happy