function commerce_order_new in Commerce Core 7
Returns an initialized order object.
Parameters
$uid: The uid of the owner of the order.
$status: Optionally the order status of the new order.
$type: The type of the order; defaults to the standard 'commerce_order' type.
Return value
An order object with all default fields initialized.
9 calls to commerce_order_new()
- CommerceOrderCRUDTestCase::testCommerceOrderCrud in modules/
order/ tests/ commerce_order.test - Test the order CRUD functions.
- CommerceOrderCRUDTestCase::testCommerceOrderTokens in modules/
order/ tests/ commerce_order.test - Test order Token replacement.
- commerce_cart_get_properties in modules/
cart/ commerce_cart.module - Entity metadata callback: returns the current user's shopping cart order.
- commerce_cart_order_new in modules/
cart/ commerce_cart.module - Creates a new shopping cart order for the specified user.
- commerce_line_item_get_properties in modules/
line_item/ commerce_line_item.module - Callback for getting line item properties.
File
- modules/
order/ commerce_order.module, line 724 - Defines the core Commerce order entity and API functions to manage orders and interact with them.
Code
function commerce_order_new($uid = 0, $status = NULL, $type = 'commerce_order') {
// If no status was specified, use the default Pending status.
if (!isset($status)) {
$order_state = commerce_order_state_load('pending');
$status = $order_state['default_status'];
}
return entity_get_controller('commerce_order')
->create(array(
'uid' => $uid,
'status' => $status,
'type' => $type,
));
}