Add snapshot tracking for Checkout additional fields. (#44310)

* add snapshot tracking

* add changelog

* address feedback

* Add changefile(s) from automation for the following project(s): woocommerce

* update changelog

* Add changefile(s) from automation for the following project(s): woocommerce

* remove the extra changelog

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Seghir Nadir 2024-03-15 15:43:05 +01:00 committed by GitHub
parent ed3aab14cc
commit 0000d754c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: add
Adds Checkout additional fields to the store weekly snapshot.

View File

@ -15,6 +15,8 @@ use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
use Automattic\WooCommerce\Utilities\{ FeaturesUtil, OrderUtil, PluginUtil };
use Automattic\WooCommerce\Internal\Utilities\BlocksUtil;
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Automattic\WooCommerce\Blocks\Package;
use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields;
defined( 'ABSPATH' ) || exit;
@ -1090,6 +1092,19 @@ class WC_Tracker {
);
}
/**
* Get tracker data for additional fields on the checkout page.
*
* @return array Array of fields count and names.
*/
public static function get_checkout_additional_fields_data() {
$additional_fields_controller = Package::container()->get( CheckoutFields::class );
return array(
'fields_count' => count( $additional_fields_controller->get_additional_fields() ),
'fields_names' => array_keys( $additional_fields_controller->get_additional_fields() ),
);
}
/**
* Get info about the cart & checkout pages.
*
@ -1104,6 +1119,8 @@ class WC_Tracker {
$pickup_location_data = self::get_pickup_location_data();
$additional_fields_data = self::get_checkout_additional_fields_data();
return array(
'cart_page_contains_cart_shortcode' => self::post_contains_text(
$cart_page_id,
@ -1119,6 +1136,7 @@ class WC_Tracker {
'checkout_page_contains_checkout_block' => $checkout_block_data['page_contains_block'],
'checkout_block_attributes' => $checkout_block_data['block_attributes'],
'pickup_location' => $pickup_location_data,
'additional_fields' => $additional_fields_data,
);
}