Skip to content

Commit d17e779

Browse files
author
Scott Anderson
committed
Added support to change opt-in location.
1 parent 8f4724f commit d17e779

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
@@ -76,6 +76,13 @@ class WooTab extends WC_Settings_Page implements Hookable {
7676
*/
7777
const EMAIL_FIELD = 'cc_woo_store_information_contact_email';
7878

79+
/**
80+
* Store checkbox location.
81+
*
82+
* @since 2021-07-26
83+
*/
84+
const CHECKBOX_LOCATION = 'cc_woo_store_information_checkbox_location';
85+
7986
/**
8087
* Settings section ID.
8188
*
@@ -474,6 +481,17 @@ private function get_store_information_settings() {
474481
'true' => esc_html__( 'Yes - check this box by default', 'cc-woo' ),
475482
],
476483
],
484+
[
485+
'title' => esc_html__( 'Checkbox Filter Location', 'cc-woo' ),
486+
'desc' => esc_html__( 'Change filter location where checkbox is rendered.', 'cc-woo' ),
487+
'type' => 'select',
488+
'id' => self::CHECKBOX_LOCATION,
489+
'default' => 'false',
490+
'options' => [
491+
'woocommerce_after_checkout_billing_form' => esc_html__( 'woocommerce_after_checkout_billing_form', 'cc-woo' ),
492+
'woocommerce_review_order_before_submit' => esc_html__( 'woocommerce_review_order_before_submit', 'cc-woo' ),
493+
],
494+
],
477495
[
478496
'type' => 'sectionend',
479497
'id' => 'cc_woo_store_information_settings',
@@ -643,7 +661,8 @@ private function meets_connect_requirements() {
643661
get_option( self::STORE_NAME_FIELD, '' ),
644662
get_option( self::CURRENCY_FIELD, '' ),
645663
get_option( self::COUNTRY_CODE_FIELD ),
646-
get_option( self::EMAIL_FIELD )
664+
get_option( self::EMAIL_FIELD ),
665+
get_option( self::CHECKBOX_LOCATION )
647666
);
648667

649668
$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)