Automattic\WooCommerce\StoreApi\Utilities

LocalPickupUtils::get_local_pickup_settings()public staticWC 1.0

Gets the local pickup location settings.

Method of the class: LocalPickupUtils{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = LocalPickupUtils::get_local_pickup_settings( $context );
$context(string)
The context for the settings.
Default: 'view'

LocalPickupUtils::get_local_pickup_settings() code WC 9.0.1

public static function get_local_pickup_settings( $context = 'view' ) {
	$pickup_location_settings = get_option(
		'woocommerce_pickup_location_settings',
		[
			'enabled' => 'no',
			'title'   => __( 'Pickup', 'woocommerce' ),
		]
	);

	if ( empty( $pickup_location_settings['title'] ) ) {
		$pickup_location_settings['title'] = __( 'Pickup', 'woocommerce' );
	}

	if ( empty( $pickup_location_settings['enabled'] ) ) {
		$pickup_location_settings['enabled'] = 'no';
	}

	// Return settings as is if we're editing them.
	if ( 'edit' === $context ) {
		return $pickup_location_settings;
	}

	// All consumers of this turn it into a bool eventually. Doing it here removes the need for that.
	$pickup_location_settings['enabled'] = wc_string_to_bool( $pickup_location_settings['enabled'] );
	$pickup_location_settings['title']   = wc_clean( $pickup_location_settings['title'] );

	return $pickup_location_settings;
}