Skip to content

Commit a0b8670

Browse files
authored
Tracking Optimized Checkout enablement (from the Promotional Banner) (#4544)
* Tracking Optimized Checkout enablement * Readme and changelog entries * Tracking the checkbox as well * Readme and changelog updates * Revert unnecessary frontend changes * Changelog and readme updates * Including source identifier
1 parent b5fadd4 commit a0b8670

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.8.0 - xxxx-xx-xx =
4+
* Add - Tracks the toggle of the Optimized Checkout feature in the promotional banner
45
* Fix - Force the card payment method to be enabled when the Optimized Checkout is enabled in the merchant's Payment Method Configuration
56
* Update - Deactivates Affirm or Klarna when other official plugins are active in merchant's Payment Method Configuration
67
* Fix - Fixes issues related to booking multiple slots with express checkout payment methods enabled

includes/admin/class-wc-rest-stripe-settings-controller.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,10 @@ private function update_oc_settings( WP_REST_Request $request ) {
558558
if ( 'is_oc_enabled' === $request_key && $value !== $current_value ) {
559559
wc_admin_record_tracks_event(
560560
$value ? 'wcstripe_oc_enabled' : 'wcstripe_oc_disabled',
561-
[ 'test_mode' => WC_Stripe_Mode::is_test() ? 1 : 0 ]
561+
[
562+
'test_mode' => WC_Stripe_Mode::is_test() ? 1 : 0,
563+
'source' => 'settings_rest_api',
564+
]
562565
);
563566
}
564567
}

includes/admin/class-wc-stripe-rest-oc-setting-toggle-controller.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,23 @@ public function set_setting( WP_REST_Request $request ) {
8888
return new WP_REST_Response( [ 'result' => 'bad_request' ], 400 );
8989
}
9090

91+
$current_value = $this->gateway->is_oc_enabled();
9192
$settings = WC_Stripe_Helper::get_stripe_settings();
92-
$settings['optimized_checkout_element'] = $is_oc_enabled ? 'yes' : 'no';
93+
$value = $is_oc_enabled ? 'yes' : 'no';
94+
$settings['optimized_checkout_element'] = $value;
9395

9496
WC_Stripe_Helper::update_main_stripe_settings( $settings );
9597

98+
if ( $value !== $current_value ) {
99+
wc_admin_record_tracks_event(
100+
$is_oc_enabled ? 'wcstripe_oc_enabled' : 'wcstripe_oc_disabled',
101+
[
102+
'test_mode' => WC_Stripe_Mode::is_test() ? 1 : 0,
103+
'source' => 'oc_setting_toggle_rest_api',
104+
]
105+
);
106+
}
107+
96108
return new WP_REST_Response( [ 'result' => 'success' ], 200 );
97109
}
98110
}

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.8.0 - xxxx-xx-xx =
114+
* Add - Tracks the toggle of the Optimized Checkout feature in the promotional banner
114115
* Fix - Force the card payment method to be enabled when the Optimized Checkout is enabled in the merchant's Payment Method Configuration
115116
* Update - Deactivates Affirm or Klarna when other official plugins are active in merchant's Payment Method Configuration
116117
* Fix - Fixes issues related to booking multiple slots with express checkout payment methods enabled

0 commit comments

Comments
 (0)