Automattic\WooCommerce\Blocks\Shipping
ShippingController::track_local_pickup()
Track local pickup settings changes via Store API
Method of the class: ShippingController{}
No Hooks.
Return
true|false
.
Usage
$ShippingController = new ShippingController(); $ShippingController->track_local_pickup( $served, $result, $request );
- $served(true|false) (required)
- Whether the request has already been served.
- $result(\WP_REST_Response) (required)
- The response object.
- $request(\WP_REST_Request) (required)
- The request object.
ShippingController::track_local_pickup() ShippingController::track local pickup code WC 9.2.3
public function track_local_pickup( $served, $result, $request ) { if ( '/wp/v2/settings' !== $request->get_route() ) { return $served; } // Param name here comes from the show_in_rest['name'] value when registering the setting. if ( ! $request->get_param( 'pickup_location_settings' ) && ! $request->get_param( 'pickup_locations' ) ) { return $served; } $event_name = 'local_pickup_save_changes'; $settings = $request->get_param( 'pickup_location_settings' ); $locations = $request->get_param( 'pickup_locations' ); $data = array( 'local_pickup_enabled' => 'yes' === $settings['enabled'] ? true : false, 'title' => __( 'Pickup', 'woocommerce' ) === $settings['title'], 'price' => '' === $settings['cost'] ? true : false, 'cost' => '' === $settings['cost'] ? 0 : $settings['cost'], 'taxes' => $settings['tax_status'], 'total_pickup_locations' => count( $locations ), 'pickup_locations_enabled' => count( array_filter( $locations, function ( $location ) { return $location['enabled']; } ) ), ); WC_Tracks::record_event( $event_name, $data ); return $served; }