Skip to content

Instantly share code, notes, and snippets.

@clifgriffin
Last active August 28, 2023 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clifgriffin/55698eca1956bd14fe1a673a91d7da76 to your computer and use it in GitHub Desktop.
Save clifgriffin/55698eca1956bd14fe1a673a91d7da76 to your computer and use it in GitHub Desktop.
CheckoutWC AB testing example
<?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