Automattic\WooCommerce\StoreApi\Utilities
LocalPickupUtils::get_local_pickup_settings
Gets the local pickup location settings.
Method of the class: LocalPickupUtils{}
No Hooks.
Returns
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() LocalPickupUtils::get local pickup settings code WC 10.7.0
public static function get_local_pickup_settings( $context = 'view' ) {
$pickup_location_settings = get_option(
'woocommerce_pickup_location_settings',
[
'enabled' => 'no',
'title' => __( 'Pickup', 'woocommerce' ),
'cost' => '',
'tax_status' => 'taxable',
]
);
if ( empty( $pickup_location_settings['title'] ) ) {
$pickup_location_settings['title'] = __( 'Pickup', 'woocommerce' );
}
if ( empty( $pickup_location_settings['enabled'] ) ) {
$pickup_location_settings['enabled'] = 'no';
}
if ( ! isset( $pickup_location_settings['cost'] ) ) {
$pickup_location_settings['cost'] = '';
}
// 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;
}