Customer::get_profile()

Summary

Get customer profile data


Return

(array|mixed|void)


Source

File: src/BigCommerce/Accounts/Customer.php

	public function get_profile() {
		$customer_id = $this->get_customer_id();
		if ( ! $customer_id ) {
			return [];
		}
		/**
		 * Filter the base fields found in a customer profile
		 *
		 * @param array $fields
		 */
		$empty_profile = apply_filters( 'bigcommerce/customer/empty_profile', [
			'first_name'        => '',
			'last_name'         => '',
			'company'           => '',
			'email'             => '',
			'phone'             => '',
			'customer_group_id' => 0,
		] );
		try {
			$profile = Client::getCustomer( $customer_id );
			if ( ! $profile ) {
				return $empty_profile;
			}

			return array_filter( get_object_vars( $profile->getCreateFields() ), function ( $key ) use ( $empty_profile ) {
				return array_key_exists( $key, $empty_profile );
			}, ARRAY_FILTER_USE_KEY );
		} catch ( \Exception $e ) {
			return $empty_profile;
		}
	}


User Contributed Notes

You must log in before being able to contribute a note or feedback.