Skip to content

Commit b568ae2

Browse files
authored
Merge pull request #130 from WebDevStudios/feature/cc-223-checkout-configuration
Added support to change opt-in location.
2 parents 777a844 + f1aeadc commit b568ae2

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/View/Admin/WooTab.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ class WooTab extends WC_Settings_Page implements Hookable {
8383
*/
8484
const ALT_LOGIN_URL = 'cc_woo_store_information_alt_login_url';
8585

86+
/**
87+
* Store checkbox location.
88+
*
89+
* @since 2021-07-26
90+
*/
91+
const CHECKBOX_LOCATION = 'cc_woo_store_information_checkbox_location';
92+
8693
/**
8794
* Settings section ID.
8895
*
@@ -493,6 +500,17 @@ private function get_store_information_settings() {
493500
'id' => self::ALT_LOGIN_URL,
494501
'type' => 'text',
495502
],
503+
[
504+
'title' => esc_html__( 'Checkbox Filter Location', 'cc-woo' ),
505+
'desc' => esc_html__( 'Change filter location where checkbox is rendered.', 'cc-woo' ),
506+
'type' => 'select',
507+
'id' => self::CHECKBOX_LOCATION,
508+
'default' => 'false',
509+
'options' => [
510+
'woocommerce_after_checkout_billing_form' => esc_html__( 'After checkout billing form', 'cc-woo' ),
511+
'woocommerce_review_order_before_submit' => esc_html__( 'Before order submit button', 'cc-woo' ),
512+
],
513+
],
496514
[
497515
'type' => 'sectionend',
498516
'id' => 'cc_woo_store_information_settings',
@@ -662,7 +680,8 @@ private function meets_connect_requirements() {
662680
get_option( self::STORE_NAME_FIELD, '' ),
663681
get_option( self::CURRENCY_FIELD, '' ),
664682
get_option( self::COUNTRY_CODE_FIELD ),
665-
get_option( self::EMAIL_FIELD )
683+
get_option( self::EMAIL_FIELD ),
684+
get_option( self::CHECKBOX_LOCATION, 'woocommerce_after_checkout_billing_form' )
666685
);
667686

668687
$validator = new SettingsValidator( $model );

src/View/Checkout/NewsletterPreferenceCheckbox.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public function __construct() {
6161
* @since 2019-03-13
6262
*/
6363
public function register_hooks() {
64-
add_action( 'woocommerce_after_checkout_billing_form', [ $this, 'add_field_to_billing_form' ] );
64+
65+
$checkbox_location = get_option( 'cc_woo_store_information_checkbox_location', 'woocommerce_after_checkout_billing_form' );
66+
add_action( $checkbox_location, [ $this, 'add_field_to_billing_form' ] );
6567
add_action( 'woocommerce_checkout_update_user_meta', [ $this, 'save_user_preference' ] );
6668
add_action( 'woocommerce_created_customer', [ $this, 'save_user_preference' ] );
6769
add_action( 'woocommerce_checkout_create_order', [ $this, 'save_user_preference_to_order' ] );

0 commit comments

Comments
 (0)