Add WC Tracker data for Local Pickup (#36847)
This commit is contained in:
commit
87f385e72c
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: tweak
|
||||
|
||||
Add tracking for local pickup method in Checkout
|
|
@ -790,6 +790,31 @@ class WC_Tracker {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tracker data for a pickup location method.
|
||||
*
|
||||
* @return array Associative array of tracker data with keys:
|
||||
* - pickup_location_enabled
|
||||
* - pickup_locations_count
|
||||
*/
|
||||
public static function get_pickup_location_data() {
|
||||
$pickup_location_enabled = false;
|
||||
$pickup_locations_count = count( get_option( 'pickup_location_pickup_locations', array() ) );
|
||||
|
||||
// Get the available shipping methods.
|
||||
$shipping_methods = WC()->shipping()->get_shipping_methods();
|
||||
|
||||
// Check if the desired shipping method is enabled.
|
||||
if ( isset( $shipping_methods['pickup_location'] ) && $shipping_methods['pickup_location']->is_enabled() ) {
|
||||
$pickup_location_enabled = true;
|
||||
}
|
||||
|
||||
return array(
|
||||
'pickup_location_enabled' => $pickup_location_enabled,
|
||||
'pickup_locations_count' => $pickup_locations_count,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info about the cart & checkout pages.
|
||||
*
|
||||
|
@ -802,6 +827,8 @@ class WC_Tracker {
|
|||
$cart_block_data = self::get_block_tracker_data( 'woocommerce/cart', 'cart' );
|
||||
$checkout_block_data = self::get_block_tracker_data( 'woocommerce/checkout', 'checkout' );
|
||||
|
||||
$pickup_location_data = self::get_pickup_location_data();
|
||||
|
||||
return array(
|
||||
'cart_page_contains_cart_shortcode' => self::post_contains_text(
|
||||
$cart_page_id,
|
||||
|
@ -816,6 +843,7 @@ class WC_Tracker {
|
|||
'cart_block_attributes' => $cart_block_data['block_attributes'],
|
||||
'checkout_page_contains_checkout_block' => $checkout_block_data['page_contains_block'],
|
||||
'checkout_block_attributes' => $checkout_block_data['block_attributes'],
|
||||
'pickup_location' => $pickup_location_data,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue