autoship_create_update_autoship_customer (function)

(src/customers.php) Used to create and update users in QPilot when they are created / updated from the Wordpress site (checkout, My Account, etc.). It takes the $wc_customer and $customer_data (array) as its parameters.


* Updates an Existing Customer's information in QPilot or
* creates the customer if they don't exist.
* @param int|WC_Customer  $wc_customer    The WC User ID or WC Customer Object
* @param array            $customer_data  Optional Customer Data to user instead of Default
* @param stdClass|WP_Error|false The created / updated customer object from QPilot
*                                A WP_Error on failure, or false if the user is not valid.
function autoship_create_update_autoship_customer( $wc_customer, $customer_data = array() ) {

  // Do not attempt to add a empty-customer
  if ( empty( $wc_customer ) )
  return false;

  // try to update this customers info or create if doesn't exist.
  // Customer data can be added / filtered using the filter.
	return autoship_update_autoship_customer( $wc_customer, apply_filters(
  $customer_data, $wc_customer ) );

/** Fires on wc checkout when a users account is created / edited.*/
add_action( 'woocommerce_checkout_update_user_meta', 'autoship_create_update_autoship_customer', 100, 1 );
/** Fires when an update to the name, email or password is made in the account page.*/
add_action( 'woocommerce_save_account_details', 'autoship_create_update_autoship_customer', 10, 1 );
/** Fires when an update to a billing or shipping address form was submitted through the user wc account page.*/
add_action( 'woocommerce_customer_save_address', 'autoship_create_update_autoship_customer', 10, 1 );