woocommerce_generate_order_key

Method to create a new order in the database.

Description

apply_filters( 'woocommerce_generate_order_key', (WC_Order) $uniqid ); 

Parameters (1)

0. $uniqid (WC_Order) => uniqid( 'order_' )
The uniqid.

Usage

To run the hook, copy the example below.
  1. $uniqid = apply_filters( 'woocommerce_generate_order_key', $uniqid ); 
  2.  
  3. if ( !empty( $uniqid ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_generate_order_key callback 
  2. function filter_woocommerce_generate_order_key( $uniqid ) { 
  3. // make filter magic happen here... 
  4. return $uniqid
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_generate_order_key', 'filter_woocommerce_generate_order_key', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_generate_order_key', 'filter_woocommerce_generate_order_key', 10, 1 ); 

Defined (2)

The filter is defined in the following location(s).

/includes/data-stores/class-wc-order-data-store-cpt.php  
  1. $order->set_order_key( 'wc_' . apply_filters( 'woocommerce_generate_order_key', uniqid( 'order_' ) ) ); 
/includes/admin/meta-boxes/class-wc-meta-box-order-data.php  
  1. $props['order_key'] = 'wc_' . apply_filters( 'woocommerce_generate_order_key', uniqid( 'order_' ) );