function _commerce_kickstart_example_user in Commerce Kickstart 7.2
BatchAPI callback.
See also
commerce_kickstart_import_content()
1 string reference to '_commerce_kickstart_example_user'
- commerce_kickstart_import_content in ./
commerce_kickstart.install - Task callback: return a batch API array with the products to be imported.
File
- ./
commerce_kickstart.install_callbacks.inc, line 215 - Contains Batch API callbacks used during installation.
Code
function _commerce_kickstart_example_user($operation, &$context) {
$context['message'] = t('@operation', array(
'@operation' => $operation,
));
// Create a sample user.
$user = array(
'name' => 'Sample Customer',
'mail' => 'customer@example.com',
'pass' => 'customer',
'status' => 1,
);
$user = user_save(NULL, $user);
// Create a bIlling customer profile.
$billing_profile = commerce_customer_profile_new('billing', $user->uid);
$billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'] = 'Sample Customer';
$billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['country'] = 'US';
$billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['thoroughfare'] = '16 Hampton Ct';
$billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['locality'] = 'Visalia';
$billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['administrative_area'] = 'CA';
$billing_profile->commerce_customer_address[LANGUAGE_NONE][0]['postal_code'] = '93277-8329';
commerce_customer_profile_save($billing_profile);
commerce_addressbook_set_default_profile($billing_profile);
// Create two shipping customer profile samples.
$shipping_profile = commerce_customer_profile_new('shipping', $user->uid);
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'] = 'Sample Customer';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['country'] = 'US';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['thoroughfare'] = '2843 Sherman Ave';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['locality'] = 'Camden';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['administrative_area'] = 'NJ';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['postal_code'] = '08105-442';
commerce_customer_profile_save($shipping_profile);
commerce_addressbook_set_default_profile($shipping_profile);
$shipping_profile = commerce_customer_profile_new('shipping', $user->uid);
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'] = 'Sample Customer';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['country'] = 'FR';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['thoroughfare'] = '27 rue des sapins';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['locality'] = 'Paris';
$shipping_profile->commerce_customer_address[LANGUAGE_NONE][0]['postal_code'] = '75004';
commerce_customer_profile_save($shipping_profile);
// Create 3 order samples.
_commerce_kickstart_create_order($user->uid, 2, TRUE);
_commerce_kickstart_create_order($user->uid, 5);
_commerce_kickstart_create_order($user->uid, 3);
}