Create order in drupal commerce programmically with product cost change in order I have a shop with one product, I want have a feature that user only determine how much he/she want to pay and then pay it.after complement payment manager of site according of amount money he/she paid, create a custom product and sent it.
My idea is create custom porduct with 1$ cost and then create a form and get the  amount value from user,then I want create an order programmically and in order update the price with the value that user entered.
How can Implement this?   

I want something like this enter link description here
finally this is my solution for do this job

before I create a product, save it product id,  in my custom function I change it's cost and add to order

global $user;

  // Sanitize just in case
  //862 create by myself as custom porduct
  $product_id = 862;
  $price=  floatval($form_state['values']['field_suggest_your_price']['und'][0]['value'])*100;
  // Load product
  $product = commerce_product_load((int)$product_id);
  $product-&gt;commerce_price_usd["und"][0]["amount"]=$price;
  commerce_product_save($product);       
  if((empty($product-&gt;product_id)) || (!$product-&gt;status)){
    drupal_set_message(t('Invalid product id'));
    drupal_goto(); // frontpage
    return FALSE;
  }
//$product-&gt;commerce_price["und"][0]["amount"]=$price;
//$product-&gt;commerce_price_usd["und"][0]["amount"]=$price;
//dsm($product);

  // Attempt to load existing order for user from session
  $order = commerce_cart_order_load();
  if(!$order){
    $order = commerce_cart_order_new($user-&gt;uid);
  }

  // Save new order to get order id
  if(empty($order-&gt;order_id)){
    $order-&gt;revision = FALSE;
    commerce_order_save($order);
  }
  $order_id = $order-&gt;order_id;

  // Wrapper for easy field access and adding line items, order passed by reference
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  // Create new line item based on selected product
  $line_item = commerce_product_line_item_new($product, 1, $order-&gt;order_id);
  // Save new line item to get line item id
  commerce_line_item_save($line_item);
  // Add line item to order wrapper
  $order_wrapper-&gt;commerce_line_items[] = $line_item;

  // Save order with new order number and line item added
  $order-&gt;revision = FALSE;
  $order_wrapper-&gt;save();

  if(!empty($order-&gt;order_id)){
    drupal_set_message(t('Thank you, your %product is ready for checkout.',
                         array('%product' =&gt; $product-&gt;title)));
    drupal_goto('checkout/'.$order-&gt;order_id);
  }else{
    drupal_set_message(t('Sorry, there was a problem building your order. Please try again later.'), 'error');
    drupal_goto(); // frontpage
  }