Last active
August 28, 2023 14:57
-
-
Save clifgriffin/55698eca1956bd14fe1a673a91d7da76 to your computer and use it in GitHub Desktop.
CheckoutWC AB testing example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The following code MUST be deployed in an MU plugin to work | |
*/ | |
add_action( 'cfw_init_ab_tests', function() { | |
cfw_register_ab_test( 'cfw_disabled', 'example_set_cfw_disabled' ); | |
// To enable the test progamatically, you would use this call: | |
cfw_activate_ab_test( 'cfw_disabled' ); | |
// Note: This would activate it for all visitors. To selectively activate, see the URL loading option below | |
} ); | |
function example_set_cfw_disabled() { | |
cfw_add_setting_value_override( 'enabled', 'no' ); | |
// cfw_add_setting_value_override( 'anothersetting', 'anothervalue' ); | |
} | |
/** | |
* URL loading example | |
* | |
* Load a test with a special URL parameter | |
*/ | |
// https://example.com/checkout/?cfw_ab_test=cfw_disabled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment