GRAYBYTE WORDPRESS FILE MANAGER4325

Server IP : 198.54.121.189 / Your IP : 216.73.216.224
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/nioscentre.in/wp-content/plugins/woocommerce/includes/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/nioscentre.in/wp-content/plugins/woocommerce/includes//class-wc-customer.php
<?php
/**
 * The WooCommerce customer class handles storage of the current customer's data, such as location.
 *
 * @package WooCommerce\Classes
 * @version 3.0.0
 */

defined( 'ABSPATH' ) || exit;

require_once __DIR__ . '/legacy/class-wc-legacy-customer.php';

/**
 * Customer class.
 */
class WC_Customer extends WC_Legacy_Customer {

	/**
	 * Stores customer data.
	 *
	 * @var array
	 */
	protected $data = array(
		'date_created'       => null,
		'date_modified'      => null,
		'email'              => '',
		'first_name'         => '',
		'last_name'          => '',
		'display_name'       => '',
		'role'               => 'customer',
		'username'           => '',
		'billing'            => array(
			'first_name' => '',
			'last_name'  => '',
			'company'    => '',
			'address_1'  => '',
			'address_2'  => '',
			'city'       => '',
			'postcode'   => '',
			'country'    => '',
			'state'      => '',
			'email'      => '',
			'phone'      => '',
		),
		'shipping'           => array(
			'first_name' => '',
			'last_name'  => '',
			'company'    => '',
			'address_1'  => '',
			'address_2'  => '',
			'city'       => '',
			'postcode'   => '',
			'country'    => '',
			'state'      => '',
			'phone'      => '',
		),
		'is_paying_customer' => false,
	);

	/**
	 * Stores a password if this needs to be changed. Write-only and hidden from _data.
	 *
	 * @var string
	 */
	protected $password = '';

	/**
	 * Stores if user is VAT exempt for this session.
	 *
	 * @var string
	 */
	protected $is_vat_exempt = false;

	/**
	 * Stores if user has calculated shipping in this session.
	 *
	 * @var string
	 */
	protected $calculated_shipping = false;

	/**
	 * This is the name of this object type.
	 *
	 * @since 5.6.0
	 * @var string
	 */
	protected $object_type = 'customer';

	/**
	 * Load customer data based on how WC_Customer is called.
	 *
	 * If $customer is 'new', you can build a new WC_Customer object. If it's empty, some
	 * data will be pulled from the session for the current user/customer.
	 *
	 * @param WC_Customer|int $data       Customer ID or data.
	 * @param bool            $is_session True if this is the customer session.
	 * @throws Exception If customer cannot be read/found and $data is set.
	 */
	public function __construct( $data = 0, $is_session = false ) {
		parent::__construct( $data );

		if ( $data instanceof WC_Customer ) {
			$this->set_id( absint( $data->get_id() ) );
		} elseif ( is_numeric( $data ) ) {
			$this->set_id( $data );
		}

		$this->data_store = WC_Data_Store::load( 'customer' );

		// If we have an ID, load the user from the DB.
		if ( $this->get_id() ) {
			try {
				$this->data_store->read( $this );
			} catch ( Exception $e ) {
				$this->set_id( 0 );
				$this->set_object_read( true );
			}
		} else {
			$this->set_object_read( true );
		}

		// If this is a session, set or change the data store to sessions. Changes do not persist in the database.
		if ( $is_session && isset( WC()->session ) ) {
			$this->data_store = WC_Data_Store::load( 'customer-session' );
			$this->data_store->read( $this );
		}
	}

	/**
	 * Delete a customer and reassign posts..
	 *
	 * @param int $reassign Reassign posts and links to new User ID.
	 * @since 3.0.0
	 * @return bool
	 */
	public function delete_and_reassign( $reassign = null ) {
		if ( $this->data_store ) {
			$this->data_store->delete(
				$this,
				array(
					'force_delete' => true,
					'reassign'     => $reassign,
				)
			);
			$this->set_id( 0 );
			return true;
		}
		return false;
	}

	/**
	 * Is customer outside base country (for tax purposes)?
	 *
	 * @return bool
	 */
	public function is_customer_outside_base() {
		list( $country, $state ) = $this->get_taxable_address();
		if ( $country ) {
			$default = wc_get_base_location();
			if ( $default['country'] !== $country ) {
				return true;
			}
			if ( $default['state'] && $default['state'] !== $state ) {
				return true;
			}
		}
		return false;
	}

	/**
	 * Return this customer's avatar.
	 *
	 * @since 3.0.0
	 * @return string
	 */
	public function get_avatar_url() {
		return get_avatar_url( $this->get_email() );
	}

	/**
	 * Get taxable address.
	 *
	 * @return array
	 */
	public function get_taxable_address() {
		$tax_based_on = get_option( 'woocommerce_tax_based_on' );

		// Check shipping method at this point to see if we need special handling.
		if ( true === apply_filters( 'woocommerce_apply_base_tax_for_local_pickup', true ) && count( array_intersect( wc_get_chosen_shipping_method_ids(), apply_filters( 'woocommerce_local_pickup_methods', array( 'legacy_local_pickup', 'local_pickup' ) ) ) ) > 0 ) {
			$tax_based_on = 'base';
		}

		if ( 'base' === $tax_based_on ) {
			$country  = WC()->countries->get_base_country();
			$state    = WC()->countries->get_base_state();
			$postcode = WC()->countries->get_base_postcode();
			$city     = WC()->countries->get_base_city();
		} elseif ( 'billing' === $tax_based_on ) {
			$country  = $this->get_billing_country();
			$state    = $this->get_billing_state();
			$postcode = $this->get_billing_postcode();
			$city     = $this->get_billing_city();
		} else {
			$country  = $this->get_shipping_country();
			$state    = $this->get_shipping_state();
			$postcode = $this->get_shipping_postcode();
			$city     = $this->get_shipping_city();
		}

		/**
		 * Filters the taxable address for a given customer.
		 *
		 * @since 3.0.0
		 *
		 * @param array  $taxable_address An array of country, state, postcode, and city for the customer's taxable address.
		 * @param object $customer        The customer object for which the taxable address is being requested.
		 *
		 * @return array The filtered taxable address for the customer.
		 */
		return apply_filters( 'woocommerce_customer_taxable_address', array( $country, $state, $postcode, $city ), $this );
	}

	/**
	 * Gets a customer's downloadable products.
	 *
	 * @return array Array of downloadable products
	 */
	public function get_downloadable_products() {
		$downloads = array();
		if ( $this->get_id() ) {
			$downloads = wc_get_customer_available_downloads( $this->get_id() );
		}
		return apply_filters( 'woocommerce_customer_get_downloadable_products', $downloads );
	}

	/**
	 * Is customer VAT exempt?
	 *
	 * @return bool
	 */
	public function is_vat_exempt() {
		return $this->get_is_vat_exempt();
	}

	/**
	 * Has calculated shipping?
	 *
	 * @return bool
	 */
	public function has_calculated_shipping() {
		return $this->get_calculated_shipping();
	}

	/**
	 * Indicates if the customer has a non-empty shipping address.
	 *
	 * Note that this does not indicate if the customer's shipping address
	 * is complete, only that one or more fields are populated.
	 *
	 * @since 5.3.0
	 *
	 * @return bool
	 */
	public function has_shipping_address() {
		foreach ( $this->get_shipping() as $address_field ) {
			// Trim guards against a case where a subset of saved shipping address fields contain whitespace.
			if ( strlen( trim( $address_field ) ) > 0 ) {
				return true;
			}
		}
		return false;
	}

	/**
	 * Checks whether the address is "full" in the sense that it contains all required fields to calculate shipping rates.
	 * This method uses the current country's locale to determine if a field is required, or falls back to the default
	 * locale if there's no country-specific setting for that field.
	 *
	 * This method is only used internally by StoreAPI, and not by the classic/shortcode checkout.
	 *
	 * @since 9.8.0
	 * @return bool Whether the customer has a full shipping address (city, state, postcode, country).
	 * Only required fields are checked based on the country locale.
	 */
	public function has_full_shipping_address() {
		// These are the important fields required to get the shipping rates. Note that while we're respecting the filters
		// for the shipping calculator below (city, postcode, state), we're not respecting the filter for the country field.
		// The country field is always required as a bare minimum for shipping.
		$shipping_address = array(
			'country'  => $this->get_shipping_country(),
			'city'     => $this->get_shipping_city(),
			'state'    => $this->get_shipping_state(),
			'postcode' => $this->get_shipping_postcode(),
		);

		$address_fields = WC()->countries->get_country_locale();
		$locale_key     = ! empty( $shipping_address['country'] ) && array_key_exists( $shipping_address['country'], $address_fields ) ? $shipping_address['country'] : 'default';
		$default_locale = $address_fields['default'];
		$country_locale = $address_fields[ $locale_key ] ?? array();

		/**
		 * Checks all shipping address fields against the country's locale settings.
		 *
		 * If there's a `required` setting for the field in the country-specific locale, that setting is used, otherwise
		 * the default locale's setting is used. If the default locale doesn't have a setting either, the field is
		 * considered optional and therefore valid, even if empty.
		 */
		foreach ( $shipping_address as $key => $value ) {
			// Skip further checks if the field has a value. From this point on $value is empty.
			if ( ! empty( $value ) ) {
				continue;
			}

			$locale_to_check = isset( $country_locale[ $key ]['required'] ) ? $country_locale : $default_locale;

			// If the locale requires the field return false.
			if ( isset( $locale_to_check[ $key ]['required'] ) && true === wc_string_to_bool( $locale_to_check[ $key ]['required'] ) ) {
				return false;
			}
		}
		return true;
	}

	/**
	 * Get if customer is VAT exempt?
	 *
	 * @since 3.0.0
	 * @return bool
	 */
	public function get_is_vat_exempt() {
		return $this->is_vat_exempt;
	}

	/**
	 * Get password (only used when updating the user object).
	 *
	 * @return string
	 */
	public function get_password() {
		return $this->password;
	}

	/**
	 * Has customer calculated shipping?
	 *
	 * @return bool
	 */
	public function get_calculated_shipping() {
		return $this->calculated_shipping;
	}

	/**
	 * Set if customer has tax exemption.
	 *
	 * @param bool $is_vat_exempt If is vat exempt.
	 */
	public function set_is_vat_exempt( $is_vat_exempt ) {
		$this->is_vat_exempt = wc_string_to_bool( $is_vat_exempt );
	}

	/**
	 * Calculated shipping?
	 *
	 * @param bool $calculated If shipping is calculated.
	 */
	public function set_calculated_shipping( $calculated = true ) {
		$this->calculated_shipping = wc_string_to_bool( $calculated );
	}

	/**
	 * Set customer's password.
	 *
	 * @since 3.0.0
	 * @param string $password Password.
	 */
	public function set_password( $password ) {
		$this->password = $password;
	}

	/**
	 * Gets the customers last order.
	 *
	 * @return WC_Order|false
	 */
	public function get_last_order() {
		return $this->data_store->get_last_order( $this );
	}

	/**
	 * Return the number of orders this customer has.
	 *
	 * @return integer
	 */
	public function get_order_count() {
		return $this->data_store->get_order_count( $this );
	}

	/**
	 * Return how much money this customer has spent.
	 *
	 * @return float
	 */
	public function get_total_spent() {
		return $this->data_store->get_total_spent( $this );
	}

	/*
	|--------------------------------------------------------------------------
	| Getters
	|--------------------------------------------------------------------------
	*/

	/**
	 * Return the customer's username.
	 *
	 * @since  3.0.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_username( $context = 'view' ) {
		return $this->get_prop( 'username', $context );
	}

	/**
	 * Return the customer's email.
	 *
	 * @since  3.0.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_email( $context = 'view' ) {
		return $this->get_prop( 'email', $context );
	}

	/**
	 * Return customer's first name.
	 *
	 * @since  3.0.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_first_name( $context = 'view' ) {
		return $this->get_prop( 'first_name', $context );
	}

	/**
	 * Return customer's last name.
	 *
	 * @since  3.0.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_last_name( $context = 'view' ) {
		return $this->get_prop( 'last_name', $context );
	}

	/**
	 * Return customer's display name.
	 *
	 * @since  3.1.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_display_name( $context = 'view' ) {
		return $this->get_prop( 'display_name', $context );
	}

	/**
	 * Return customer's user role.
	 *
	 * @since  3.0.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_role( $context = 'view' ) {
		return $this->get_prop( 'role', $context );
	}

	/**
	 * Return the date this customer was created.
	 *
	 * @since  3.0.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return WC_DateTime|null object if the date is set or null if there is no date.
	 */
	public function get_date_created( $context = 'view' ) {
		return $this->get_prop( 'date_created', $context );
	}

	/**
	 * Return the date this customer was last updated.
	 *
	 * @since  3.0.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return WC_DateTime|null object if the date is set or null if there is no date.
	 */
	public function get_date_modified( $context = 'view' ) {
		return $this->get_prop( 'date_modified', $context );
	}

	/**
	 * Gets a prop for a getter method.
	 *
	 * @since  3.0.0
	 * @param  string $prop Name of prop to get.
	 * @param  string $address_type Type of address; 'billing' or 'shipping'.
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return mixed
	 */
	protected function get_address_prop( $prop, $address_type = 'billing', $context = 'view' ) {
		$value = null;

		if ( array_key_exists( $prop, $this->data[ $address_type ] ) ) {
			$value = isset( $this->changes[ $address_type ][ $prop ] ) ? $this->changes[ $address_type ][ $prop ] : $this->data[ $address_type ][ $prop ];

			if ( 'view' === $context ) {
				/**
				 * Filter: 'woocommerce_customer_get_[billing|shipping]_[prop]'
				 *
				 * Allow developers to change the returned value for any customer address property.
				 *
				 * @since 3.6.0
				 * @param string      $value    The address property value.
				 * @param WC_Customer $customer The customer object being read.
				 */
				$value = apply_filters( $this->get_hook_prefix() . $address_type . '_' . $prop, $value, $this );
			}
		}
		return $value;
	}

	/**
	 * Get billing.
	 *
	 * @since  3.2.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return array
	 */
	public function get_billing( $context = 'view' ) {
		$value = null;
		$prop  = 'billing';

		if ( array_key_exists( $prop, $this->data ) ) {
			$changes = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : array();
			$value   = array_merge( $this->data[ $prop ], $changes );

			if ( 'view' === $context ) {
				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
			}
		}

		return $value;
	}

	/**
	 * Get billing_first_name.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_first_name( $context = 'view' ) {
		return $this->get_address_prop( 'first_name', 'billing', $context );
	}

	/**
	 * Get billing_last_name.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_last_name( $context = 'view' ) {
		return $this->get_address_prop( 'last_name', 'billing', $context );
	}

	/**
	 * Get billing_company.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_company( $context = 'view' ) {
		return $this->get_address_prop( 'company', 'billing', $context );
	}

	/**
	 * Get billing_address_1.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_address( $context = 'view' ) {
		return $this->get_billing_address_1( $context );
	}

	/**
	 * Get billing_address_1.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_address_1( $context = 'view' ) {
		return $this->get_address_prop( 'address_1', 'billing', $context );
	}

	/**
	 * Get billing_address_2.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string $value
	 */
	public function get_billing_address_2( $context = 'view' ) {
		return $this->get_address_prop( 'address_2', 'billing', $context );
	}

	/**
	 * Get billing_city.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string $value
	 */
	public function get_billing_city( $context = 'view' ) {
		return $this->get_address_prop( 'city', 'billing', $context );
	}

	/**
	 * Get billing_state.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_state( $context = 'view' ) {
		return $this->get_address_prop( 'state', 'billing', $context );
	}

	/**
	 * Get billing_postcode.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_postcode( $context = 'view' ) {
		return $this->get_address_prop( 'postcode', 'billing', $context );
	}

	/**
	 * Get billing_country.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_country( $context = 'view' ) {
		return $this->get_address_prop( 'country', 'billing', $context );
	}

	/**
	 * Get billing_email.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_email( $context = 'view' ) {
		return $this->get_address_prop( 'email', 'billing', $context );
	}

	/**
	 * Get billing_phone.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_billing_phone( $context = 'view' ) {
		return $this->get_address_prop( 'phone', 'billing', $context );
	}

	/**
	 * Get shipping.
	 *
	 * @since  3.2.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return array
	 */
	public function get_shipping( $context = 'view' ) {
		$value = null;
		$prop  = 'shipping';

		if ( array_key_exists( $prop, $this->data ) ) {
			$changes = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : array();
			$value   = array_merge( $this->data[ $prop ], $changes );

			if ( 'view' === $context ) {
				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
			}
		}

		return $value;
	}

	/**
	 * Get shipping_first_name.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_first_name( $context = 'view' ) {
		return $this->get_address_prop( 'first_name', 'shipping', $context );
	}

	/**
	 * Get shipping_last_name.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_last_name( $context = 'view' ) {
		return $this->get_address_prop( 'last_name', 'shipping', $context );
	}

	/**
	 * Get shipping_company.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_company( $context = 'view' ) {
		return $this->get_address_prop( 'company', 'shipping', $context );
	}

	/**
	 * Get shipping_address_1.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_address( $context = 'view' ) {
		return $this->get_shipping_address_1( $context );
	}

	/**
	 * Get shipping_address_1.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_address_1( $context = 'view' ) {
		return $this->get_address_prop( 'address_1', 'shipping', $context );
	}

	/**
	 * Get shipping_address_2.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_address_2( $context = 'view' ) {
		return $this->get_address_prop( 'address_2', 'shipping', $context );
	}

	/**
	 * Get shipping_city.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_city( $context = 'view' ) {
		return $this->get_address_prop( 'city', 'shipping', $context );
	}

	/**
	 * Get shipping_state.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_state( $context = 'view' ) {
		return $this->get_address_prop( 'state', 'shipping', $context );
	}

	/**
	 * Get shipping_postcode.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_postcode( $context = 'view' ) {
		return $this->get_address_prop( 'postcode', 'shipping', $context );
	}

	/**
	 * Get shipping_country.
	 *
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_country( $context = 'view' ) {
		return $this->get_address_prop( 'country', 'shipping', $context );
	}

	/**
	 * Get shipping phone.
	 *
	 * @since 5.6.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return string
	 */
	public function get_shipping_phone( $context = 'view' ) {
		return $this->get_address_prop( 'phone', 'shipping', $context );
	}

	/**
	 * Is the user a paying customer?
	 *
	 * @since  3.0.0
	 * @param  string $context What the value is for. Valid values are 'view' and 'edit'.
	 * @return bool
	 */
	public function get_is_paying_customer( $context = 'view' ) {
		return $this->get_prop( 'is_paying_customer', $context );
	}

	/*
	|--------------------------------------------------------------------------
	| Setters
	|--------------------------------------------------------------------------
	*/

	/**
	 * Set customer's username.
	 *
	 * @since 3.0.0
	 * @param string $username Username.
	 */
	public function set_username( $username ) {
		$this->set_prop( 'username', $username );
	}

	/**
	 * Set customer's email.
	 *
	 * @since 3.0.0
	 * @param string $value Email.
	 */
	public function set_email( $value ) {
		if ( $value && ! is_email( $value ) ) {
			$this->error( 'customer_invalid_email', __( 'Invalid email address', 'woocommerce' ) );
		}
		$this->set_prop( 'email', sanitize_email( $value ) );
	}

	/**
	 * Set customer's first name.
	 *
	 * @since 3.0.0
	 * @param string $first_name First name.
	 */
	public function set_first_name( $first_name ) {
		$this->set_prop( 'first_name', $first_name );
	}

	/**
	 * Set customer's last name.
	 *
	 * @since 3.0.0
	 * @param string $last_name Last name.
	 */
	public function set_last_name( $last_name ) {
		$this->set_prop( 'last_name', $last_name );
	}

	/**
	 * Set customer's display name.
	 *
	 * @since 3.1.0
	 * @param string $display_name Display name.
	 */
	public function set_display_name( $display_name ) {
		/* translators: 1: first name 2: last name */
		$this->set_prop( 'display_name', is_email( $display_name ) ? sprintf( _x( '%1$s %2$s', 'display name', 'woocommerce' ), $this->get_first_name(), $this->get_last_name() ) : $display_name );
	}

	/**
	 * Set customer's user role(s).
	 *
	 * @since 3.0.0
	 * @param mixed $role User role.
	 */
	public function set_role( $role ) {
		global $wp_roles;

		if ( $role && ! empty( $wp_roles->roles ) && ! in_array( $role, array_keys( $wp_roles->roles ), true ) ) {
			$this->error( 'customer_invalid_role', __( 'Invalid role', 'woocommerce' ) );
		}
		$this->set_prop( 'role', $role );
	}

	/**
	 * Set the date this customer was last updated.
	 *
	 * @since  3.0.0
	 * @param  string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.
	 */
	public function set_date_created( $date = null ) {
		$this->set_date_prop( 'date_created', $date );
	}

	/**
	 * Set the date this customer was last updated.
	 *
	 * @since  3.0.0
	 * @param  string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.
	 */
	public function set_date_modified( $date = null ) {
		$this->set_date_prop( 'date_modified', $date );
	}

	/**
	 * Set customer address to match shop base address.
	 *
	 * @since 3.0.0
	 */
	public function set_billing_address_to_base() {
		$base = wc_get_customer_default_location();
		$this->set_billing_location( $base['country'], $base['state'], '', '' );
	}

	/**
	 * Set customer shipping address to base address.
	 *
	 * @since 3.0.0
	 */
	public function set_shipping_address_to_base() {
		$base = wc_get_customer_default_location();
		$this->set_shipping_location( $base['country'], $base['state'], '', '' );
	}

	/**
	 * Sets all address info at once.
	 *
	 * @param string $country  Country.
	 * @param string $state    State.
	 * @param string $postcode Postcode.
	 * @param string $city     City.
	 */
	public function set_billing_location( $country, $state = '', $postcode = '', $city = '' ) {
		$address_data = $this->get_prop( 'billing', 'edit' );

		$address_data['address_1'] = '';
		$address_data['address_2'] = '';
		$address_data['city']      = $city;
		$address_data['state']     = $state;
		$address_data['postcode']  = $postcode;
		$address_data['country']   = $country;

		$this->set_prop( 'billing', $address_data );
	}

	/**
	 * Sets all shipping info at once.
	 *
	 * @param string $country  Country.
	 * @param string $state    State.
	 * @param string $postcode Postcode.
	 * @param string $city     City.
	 */
	public function set_shipping_location( $country, $state = '', $postcode = '', $city = '' ) {
		$address_data = $this->get_prop( 'shipping', 'edit' );

		$address_data['address_1'] = '';
		$address_data['address_2'] = '';
		$address_data['city']      = $city;
		$address_data['state']     = $state;
		$address_data['postcode']  = $postcode;
		$address_data['country']   = $country;

		$this->set_prop( 'shipping', $address_data );
	}

	/**
	 * Sets a prop for a setter method.
	 *
	 * @since 3.0.0
	 * @param string $prop         Name of prop to set.
	 * @param string $address_type Type of address; 'billing' or 'shipping'.
	 * @param mixed  $value        Value of the prop.
	 */
	protected function set_address_prop( $prop, $address_type, $value ) {
		if ( array_key_exists( $prop, $this->data[ $address_type ] ) ) {
			if ( true === $this->object_read ) {
				if ( $value !== $this->data[ $address_type ][ $prop ] || ( isset( $this->changes[ $address_type ] ) && array_key_exists( $prop, $this->changes[ $address_type ] ) ) ) {
					$this->changes[ $address_type ][ $prop ] = $value;
				}
			} else {
				$this->data[ $address_type ][ $prop ] = $value;
			}
		}
	}

	/**
	 * Set billing_first_name.
	 *
	 * @param string $value Billing first name.
	 */
	public function set_billing_first_name( $value ) {
		$this->set_address_prop( 'first_name', 'billing', $value );
	}

	/**
	 * Set billing_last_name.
	 *
	 * @param string $value Billing last name.
	 */
	public function set_billing_last_name( $value ) {
		$this->set_address_prop( 'last_name', 'billing', $value );
	}

	/**
	 * Set billing_company.
	 *
	 * @param string $value Billing company.
	 */
	public function set_billing_company( $value ) {
		$this->set_address_prop( 'company', 'billing', $value );
	}

	/**
	 * Set billing_address_1.
	 *
	 * @param string $value Billing address line 1.
	 */
	public function set_billing_address( $value ) {
		$this->set_billing_address_1( $value );
	}

	/**
	 * Set billing_address_1.
	 *
	 * @param string $value Billing address line 1.
	 */
	public function set_billing_address_1( $value ) {
		$this->set_address_prop( 'address_1', 'billing', $value );
	}

	/**
	 * Set billing_address_2.
	 *
	 * @param string $value Billing address line 2.
	 */
	public function set_billing_address_2( $value ) {
		$this->set_address_prop( 'address_2', 'billing', $value );
	}

	/**
	 * Set billing_city.
	 *
	 * @param string $value Billing city.
	 */
	public function set_billing_city( $value ) {
		$this->set_address_prop( 'city', 'billing', $value );
	}

	/**
	 * Set billing_state.
	 *
	 * @param string $value Billing state.
	 */
	public function set_billing_state( $value ) {
		$this->set_address_prop( 'state', 'billing', $value );
	}

	/**
	 * Set billing_postcode.
	 *
	 * @param string $value Billing postcode.
	 */
	public function set_billing_postcode( $value ) {
		$this->set_address_prop( 'postcode', 'billing', $value );
	}

	/**
	 * Set billing_country.
	 *
	 * @param string $value Billing country.
	 */
	public function set_billing_country( $value ) {
		$this->set_address_prop( 'country', 'billing', $value );
	}

	/**
	 * Set billing_email.
	 *
	 * @param string $value Billing email.
	 */
	public function set_billing_email( $value ) {
		if ( $value && ! is_email( $value ) ) {
			$this->error( 'customer_invalid_billing_email', __( 'Invalid billing email address', 'woocommerce' ) );
		}
		$this->set_address_prop( 'email', 'billing', sanitize_email( $value ) );
	}

	/**
	 * Set billing_phone.
	 *
	 * @param string $value Billing phone.
	 */
	public function set_billing_phone( $value ) {
		$this->set_address_prop( 'phone', 'billing', $value );
	}

	/**
	 * Set shipping_first_name.
	 *
	 * @param string $value Shipping first name.
	 */
	public function set_shipping_first_name( $value ) {
		$this->set_address_prop( 'first_name', 'shipping', $value );
	}

	/**
	 * Set shipping_last_name.
	 *
	 * @param string $value Shipping last name.
	 */
	public function set_shipping_last_name( $value ) {
		$this->set_address_prop( 'last_name', 'shipping', $value );
	}

	/**
	 * Set shipping_company.
	 *
	 * @param string $value Shipping company.
	 */
	public function set_shipping_company( $value ) {
		$this->set_address_prop( 'company', 'shipping', $value );
	}

	/**
	 * Set shipping_address_1.
	 *
	 * @param string $value Shipping address line 1.
	 */
	public function set_shipping_address( $value ) {
		$this->set_shipping_address_1( $value );
	}

	/**
	 * Set shipping_address_1.
	 *
	 * @param string $value Shipping address line 1.
	 */
	public function set_shipping_address_1( $value ) {
		$this->set_address_prop( 'address_1', 'shipping', $value );
	}

	/**
	 * Set shipping_address_2.
	 *
	 * @param string $value Shipping address line 2.
	 */
	public function set_shipping_address_2( $value ) {
		$this->set_address_prop( 'address_2', 'shipping', $value );
	}

	/**
	 * Set shipping_city.
	 *
	 * @param string $value Shipping city.
	 */
	public function set_shipping_city( $value ) {
		$this->set_address_prop( 'city', 'shipping', $value );
	}

	/**
	 * Set shipping_state.
	 *
	 * @param string $value Shipping state.
	 */
	public function set_shipping_state( $value ) {
		$this->set_address_prop( 'state', 'shipping', $value );
	}

	/**
	 * Set shipping_postcode.
	 *
	 * @param string $value Shipping postcode.
	 */
	public function set_shipping_postcode( $value ) {
		$this->set_address_prop( 'postcode', 'shipping', $value );
	}

	/**
	 * Set shipping_country.
	 *
	 * @param string $value Shipping country.
	 */
	public function set_shipping_country( $value ) {
		$this->set_address_prop( 'country', 'shipping', $value );
	}

	/**
	 * Set shipping phone.
	 *
	 * @since 5.6.0
	 * @param string $value Shipping phone.
	 */
	public function set_shipping_phone( $value ) {
		$this->set_address_prop( 'phone', 'shipping', $value );
	}

	/**
	 * Set if the user a paying customer.
	 *
	 * @since 3.0.0
	 * @param bool $is_paying_customer If is a paying customer.
	 */
	public function set_is_paying_customer( $is_paying_customer ) {
		$this->set_prop( 'is_paying_customer', (bool) $is_paying_customer );
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
June 24 2025 08:34:23
giriqfky / giriqfky
0755
abstracts
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
admin
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
blocks
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
cli
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
customizer
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
data-stores
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
emails
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
export
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
gateways
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
import
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
integrations
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
interfaces
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
legacy
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
libraries
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
log-handlers
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
payment-tokens
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
product-usage
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
queue
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
react-admin
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
rest-api
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
shipping
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
shortcodes
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
theme-support
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
tracks
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
traits
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
walkers
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
wccom-site
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
widgets
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
class-wc-ajax.php
118.694 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-auth.php
12.69 KB
July 30 2024 19:31:16
giriqfky / giriqfky
0644
class-wc-autoloader.php
3.321 KB
September 23 2024 20:44:04
giriqfky / giriqfky
0644
class-wc-background-emailer.php
4.575 KB
August 20 2020 23:18:50
giriqfky / giriqfky
0644
class-wc-background-updater.php
3.452 KB
August 20 2020 23:18:50
giriqfky / giriqfky
0644
class-wc-brands-brand-settings-manager.php
1.783 KB
September 23 2024 20:44:04
giriqfky / giriqfky
0644
class-wc-brands-coupons.php
6.894 KB
January 21 2025 18:53:44
giriqfky / giriqfky
0644
class-wc-brands.php
33.975 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-breadcrumb.php
9.494 KB
October 21 2020 03:38:50
giriqfky / giriqfky
0644
class-wc-cache-helper.php
11.17 KB
August 27 2024 23:04:44
giriqfky / giriqfky
0644
class-wc-cart-fees.php
3.367 KB
September 26 2023 21:42:36
giriqfky / giriqfky
0644
class-wc-cart-session.php
18.921 KB
March 03 2025 22:28:12
giriqfky / giriqfky
0644
class-wc-cart-totals.php
28.399 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-cart.php
70.182 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-checkout.php
50.146 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-cli.php
2.866 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-comments.php
22.191 KB
June 02 2025 20:47:42
giriqfky / giriqfky
0644
class-wc-countries.php
49.162 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-coupon.php
39.642 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-customer-download-log.php
3.371 KB
August 20 2020 23:18:50
giriqfky / giriqfky
0644
class-wc-customer-download.php
10.339 KB
July 30 2024 19:31:16
giriqfky / giriqfky
0644
class-wc-customer.php
32.034 KB
May 12 2025 15:44:58
giriqfky / giriqfky
0644
class-wc-data-exception.php
1.29 KB
May 23 2018 19:30:10
giriqfky / giriqfky
0644
class-wc-data-store.php
6.594 KB
October 19 2022 00:34:38
giriqfky / giriqfky
0644
class-wc-datetime.php
2.256 KB
April 20 2022 06:50:54
giriqfky / giriqfky
0644
class-wc-deprecated-action-hooks.php
6.588 KB
February 27 2024 18:59:46
giriqfky / giriqfky
0644
class-wc-deprecated-filter-hooks.php
7.342 KB
February 22 2023 07:17:34
giriqfky / giriqfky
0644
class-wc-discounts.php
36.509 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-download-handler.php
28.372 KB
December 18 2024 22:19:16
giriqfky / giriqfky
0644
class-wc-emails.php
28.2 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-embed.php
4.24 KB
January 21 2025 18:53:44
giriqfky / giriqfky
0644
class-wc-form-handler.php
45.735 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-frontend-scripts.php
27.843 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-geo-ip.php
30.407 KB
September 23 2024 20:44:04
giriqfky / giriqfky
0644
class-wc-geolite-integration.php
1.988 KB
January 16 2020 06:10:02
giriqfky / giriqfky
0644
class-wc-geolocation.php
11.322 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-https.php
4.335 KB
June 20 2023 23:45:50
giriqfky / giriqfky
0644
class-wc-install.php
106.709 KB
June 02 2025 15:59:32
giriqfky / giriqfky
0644
class-wc-integrations.php
1.277 KB
August 20 2020 23:18:50
giriqfky / giriqfky
0644
class-wc-log-levels.php
3.898 KB
January 30 2024 23:24:56
giriqfky / giriqfky
0644
class-wc-logger.php
9.376 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-meta-data.php
2.207 KB
April 20 2022 06:50:54
giriqfky / giriqfky
0644
class-wc-order-factory.php
8.523 KB
April 30 2024 19:35:34
giriqfky / giriqfky
0644
class-wc-order-item-coupon.php
4.077 KB
December 22 2021 00:24:58
giriqfky / giriqfky
0644
class-wc-order-item-fee.php
9.21 KB
March 03 2025 22:28:12
giriqfky / giriqfky
0644
class-wc-order-item-meta.php
5.803 KB
December 22 2021 00:24:58
giriqfky / giriqfky
0644
class-wc-order-item-product.php
15.841 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-order-item-shipping.php
8.802 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-order-item-tax.php
6.488 KB
December 22 2021 00:24:58
giriqfky / giriqfky
0644
class-wc-order-item.php
18.545 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-order-query.php
2.554 KB
July 28 2021 04:11:34
giriqfky / giriqfky
0644
class-wc-order-refund.php
5.991 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-order.php
74.093 KB
June 02 2025 15:59:32
giriqfky / giriqfky
0644
class-wc-payment-gateways.php
11.897 KB
May 26 2025 19:11:58
giriqfky / giriqfky
0644
class-wc-payment-tokens.php
6.24 KB
November 23 2022 05:58:58
giriqfky / giriqfky
0644
class-wc-post-data.php
21.725 KB
March 03 2025 22:28:12
giriqfky / giriqfky
0644
class-wc-post-types.php
32.003 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-privacy-background-process.php
1.79 KB
March 03 2025 22:28:12
giriqfky / giriqfky
0644
class-wc-privacy-erasers.php
13.608 KB
September 23 2024 20:44:04
giriqfky / giriqfky
0644
class-wc-privacy-exporters.php
14.691 KB
July 28 2021 04:11:34
giriqfky / giriqfky
0644
class-wc-privacy.php
17.189 KB
March 03 2025 22:28:12
giriqfky / giriqfky
0644
class-wc-product-attribute.php
6.97 KB
January 19 2022 02:24:34
giriqfky / giriqfky
0644
class-wc-product-download.php
12.253 KB
April 10 2024 16:54:10
giriqfky / giriqfky
0644
class-wc-product-external.php
4.984 KB
March 03 2025 22:28:12
giriqfky / giriqfky
0644
class-wc-product-factory.php
3.881 KB
January 21 2025 18:53:44
giriqfky / giriqfky
0644
class-wc-product-grouped.php
5.603 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-product-query.php
2.277 KB
January 21 2025 18:53:44
giriqfky / giriqfky
0644
class-wc-product-simple.php
2.697 KB
January 21 2025 18:53:44
giriqfky / giriqfky
0644
class-wc-product-variable.php
24.576 KB
June 02 2025 15:59:32
giriqfky / giriqfky
0644
class-wc-product-variation.php
20.177 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-query.php
33.36 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-rate-limiter.php
4.004 KB
December 01 2021 04:23:30
giriqfky / giriqfky
0644
class-wc-regenerate-images-request.php
7.737 KB
January 25 2023 03:19:12
giriqfky / giriqfky
0644
class-wc-regenerate-images.php
15.436 KB
June 25 2024 21:17:40
giriqfky / giriqfky
0644
class-wc-register-wp-admin-settings.php
5.05 KB
June 22 2021 15:24:06
giriqfky / giriqfky
0644
class-wc-rest-authentication.php
21.551 KB
June 25 2024 21:17:40
giriqfky / giriqfky
0644
class-wc-rest-exception.php
0.27 KB
September 23 2020 01:16:50
giriqfky / giriqfky
0644
class-wc-session-handler.php
15.611 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-shipping-rate.php
8.065 KB
March 03 2025 22:28:12
giriqfky / giriqfky
0644
class-wc-shipping-zone.php
13.078 KB
September 23 2020 01:16:50
giriqfky / giriqfky
0644
class-wc-shipping-zones.php
4.01 KB
August 20 2020 23:18:50
giriqfky / giriqfky
0644
class-wc-shipping.php
12.852 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
class-wc-shortcodes.php
18.822 KB
January 21 2025 18:53:44
giriqfky / giriqfky
0644
class-wc-structured-data.php
23.796 KB
March 03 2025 22:28:12
giriqfky / giriqfky
0644
class-wc-tax.php
37.079 KB
June 20 2023 23:45:50
giriqfky / giriqfky
0644
class-wc-template-loader.php
21.38 KB
June 09 2025 15:55:46
giriqfky / giriqfky
0644
class-wc-tracker.php
48.207 KB
June 02 2025 15:59:32
giriqfky / giriqfky
0644
class-wc-validation.php
5.79 KB
May 28 2024 14:28:20
giriqfky / giriqfky
0644
class-wc-webhook.php
29.405 KB
December 18 2024 22:19:16
giriqfky / giriqfky
0644
class-woocommerce.php
49.085 KB
June 23 2025 15:50:22
giriqfky / giriqfky
0644
wc-account-functions.php
14.014 KB
December 18 2024 22:19:16
giriqfky / giriqfky
0644
wc-attribute-functions.php
21.179 KB
January 21 2025 18:53:44
giriqfky / giriqfky
0644
wc-brands-functions.php
4.17 KB
September 23 2024 20:44:04
giriqfky / giriqfky
0644
wc-cart-functions.php
20.049 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-conditional-functions.php
14.199 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-core-functions.php
86.207 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-coupon-functions.php
3.095 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-deprecated-functions.php
38.115 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-formatting-functions.php
47.764 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-notice-functions.php
8.057 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-order-functions.php
40.503 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-order-item-functions.php
5.032 KB
January 25 2023 03:19:12
giriqfky / giriqfky
0644
wc-order-step-logger-functions.php
5.015 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-page-functions.php
9.431 KB
September 23 2024 20:44:04
giriqfky / giriqfky
0644
wc-product-functions.php
58.515 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-rest-functions.php
12.951 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-stock-functions.php
17.133 KB
January 21 2025 18:53:44
giriqfky / giriqfky
0644
wc-template-functions.php
132.676 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-template-hooks.php
12.653 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-term-functions.php
23.81 KB
June 16 2025 19:21:28
giriqfky / giriqfky
0644
wc-update-functions.php
91.822 KB
June 02 2025 15:59:32
giriqfky / giriqfky
0644
wc-user-functions.php
33.352 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
wc-webhook-functions.php
5.767 KB
June 25 2024 21:17:40
giriqfky / giriqfky
0644
wc-widget-functions.php
2.015 KB
August 20 2020 23:18:50
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF