add tracking for local pickup
This commit is contained in:
parent
993f1f4879
commit
2efe0a0f6a
|
@ -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:
|
||||
* - page_contains_block
|
||||
* - block_attributes
|
||||
*/
|
||||
public static function get_pickup_location_data( $block_name, $woo_page_name ) {
|
||||
$pickup_location_enabled = false;
|
||||
$pickup_locations_count = count( get_option( 'pickup_location_pickup_locations', [] ) );
|
||||
|
||||
// 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