You are here

function commerce_wishlist_order_new in Commerce Wishlist 7.3

Creates a new wishlist order.

Parameters

int $uid: The UID of the owner of the new wish list.

string $type: The order type to create. Defaults to 'commerce_order'.

Return value

object The new commerce order. It's visibility will be set to private.

4 calls to commerce_wishlist_order_new()
CommerceWishlistTest::testCommerceWishlistSharing in ./commerce_wishlist.test
commerce_wishlist_product_add in ./commerce_wishlist.module
Add a product to a wish list.
commerce_wishlist_upgrade_from_1x_to_3x in ./commerce_wishlist.install
Upgrade from 1.x to 3.x.
commerce_wishlist_upgrade_from_2x_to_3x in ./commerce_wishlist.install
Upgrades from Commerce Wishlist 2.x to 3.x

File

./commerce_wishlist.module, line 1002
Provides a wish list for use in Drupal Commerce.

Code

function commerce_wishlist_order_new($uid, $type = 'commerce_order') {

  // Create the new order with the customer's uid and the cart order status.
  $order = commerce_order_new($uid, 'wishlist', $type);
  $order->log = t('Created a new wishlist order.');

  // Save all wishlist as private by default.
  $order->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'] = COMMERCE_WISHLIST_VISIBILITY_PRIVATE;

  // Save it so it gets an order ID and return the full object.
  commerce_order_save($order);
  return $order;
}