Automattic\WooCommerce\Blocks\Shipping

PickupLocationsRestController::record_save_event │ private │ WC 1.0

Record a Tracks event summarising a Local Pickup settings save.

Method of the class: PickupLocationsRestController{}

No Hooks.

Returns

void. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->record_save_event( $settings, $locations ): void;
$settings(array) (required)
Sanitized method settings.
$locations(array) (required)
Sanitized list of pickup locations.

PickupLocationsRestController::record_save_event() code WC 11.2.1

private function record_save_event( array $settings, array $locations ): void {
	$cost = $settings['cost'] ?? '';

	\WC_Tracks::record_event(
		'local_pickup_save_changes',
		array(
			'local_pickup_enabled'     => 'yes' === ( $settings['enabled'] ?? '' ),
			'title'                    => __( 'Pickup', 'woocommerce' ) === ( $settings['title'] ?? '' ),
			'price'                    => '' === $cost,
			'cost'                     => '' === $cost ? 0 : $cost,
			'taxes'                    => $settings['tax_status'] ?? '',
			'total_pickup_locations'   => count( $locations ),
			'pickup_locations_enabled' => count(
				array_filter(
					$locations,
					function ( $location ) {
						return ! empty( $location['enabled'] );
					}
				)
			),
		)
	);
}