Changeset 3437406
- Timestamp:
- 01/12/2026 07:08:28 AM (3 months ago)
- Location:
- vuelve/trunk
- Files:
-
- 9 edited
-
readme.txt (modified) (2 diffs)
-
src/Admin/VuelveAdmin.php (modified) (4 diffs)
-
src/Admin/assets/admin.css (modified) (1 diff)
-
src/Admin/assets/admin.js (modified) (1 diff)
-
src/Cart/CartCapture.php (modified) (3 diffs)
-
src/Cart/CartRestore.php (modified) (1 diff)
-
src/ConsentCheckbox/ConsentCheckbox.php (modified) (14 diffs)
-
src/Event/VuelveEvent.php (modified) (3 diffs)
-
vuelve.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
vuelve/trunk/readme.txt
r3435705 r3437406 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 17 Stable tag: 1.0.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 90 90 = 1.0.1 = 91 91 * Added new controller over marketing consent checkbox. 92 93 = 1.0.2 = 94 * Fixing default pre-checked settings value. 95 96 = 1.0.3 = 97 * Small fix to pre-checked settings. -
vuelve/trunk/src/Admin/VuelveAdmin.php
r3431340 r3437406 50 50 public function vuelve_render_admin_page() { 51 51 $nonce = wp_create_nonce('vuelve_save_managers'); 52 $prechecked = get_option('vuelve_consent_ default_checked', '1');52 $prechecked = get_option('vuelve_consent_v2_default_checked', '1'); 53 53 ?> 54 54 <div class="vlv-admin"> … … 148 148 </div> 149 149 <div class="field field-row"> 150 <label for="vuelve_consent_ default_checked">151 <input name="vuelve_consent_ default_checked" type="checkbox" id="vuelve_consent_default_checked" value="1" <?php checked('1', $prechecked); ?> />150 <label for="vuelve_consent_v2_default_checked"> 151 <input name="vuelve_consent_v2_default_checked" type="checkbox" id="vuelve_consent_v2_default_checked" value="1" <?php checked('1', $prechecked); ?> /> 152 152 Pre-check the consent box at checkout 153 153 </label> … … 221 221 add_action( 'admin_enqueue_scripts', [$this, 'vuelve_admin_assets'] ); 222 222 add_action('admin_init', function() { 223 register_setting('vuelve_settings_group', 'vuelve_consent_ default_checked');223 register_setting('vuelve_settings_group', 'vuelve_consent_v2_default_checked'); 224 224 }); 225 225 … … 246 246 247 247 update_option( 'vuelve_marketing_consent_label', $raw_label ); 248 update_option( 'vuelve_consent_ default_checked', $consent_default_val );248 update_option( 'vuelve_consent_v2_default_checked', $consent_default_val ); 249 249 250 250 wp_send_json_success(); -
vuelve/trunk/src/Admin/assets/admin.css
r3431172 r3437406 507 507 } 508 508 509 .vlv-admin input#vuelve_consent_ default_checked {509 .vlv-admin input#vuelve_consent_v2_default_checked { 510 510 width: 17px; 511 511 height: 16px; -
vuelve/trunk/src/Admin/assets/admin.js
r3431172 r3437406 127 127 function submitVuelveSettings() { 128 128 const marketingConsentLabelInput = document.querySelector('#marketing-consent-label'); 129 const marketingConsentDefaultChecked = document.querySelector('#vuelve_consent_ default_checked');129 const marketingConsentDefaultChecked = document.querySelector('#vuelve_consent_v2_default_checked'); 130 130 const marketingConsentLabel = marketingConsentLabelInput?.value; 131 131 const marketingConsentDefault = marketingConsentDefaultChecked.checked; -
vuelve/trunk/src/Cart/CartCapture.php
r3431081 r3437406 104 104 // error_log("in update_cart_image 4"); 105 105 // error_log("update_cart_image 3"); 106 $consent = WC()->session->get('vuelve_marketing_consent ');106 $consent = WC()->session->get('vuelve_marketing_consent_v2'); 107 107 // error_log("update cart image 4: ".$consent); 108 108 $cart = WC()->session->get('vuelve_cart_snapshot'); … … 499 499 500 500 if($session) { 501 $consent = $session->get('vuelve_marketing_consent ');501 $consent = $session->get('vuelve_marketing_consent_v2'); 502 502 // error_log("consent of classic order: ".$consent); 503 503 $cart = $session->get('vuelve_cart_snapshot'); … … 522 522 523 523 VuelveAuth::sendWebhook($payload); 524 $order->update_meta_data( '_vuelve_marketing_consent ', $consent );524 $order->update_meta_data( '_vuelve_marketing_consent_v2', $consent ); 525 525 $order->update_meta_data('_vuelve_order_payload', json_encode($payload)); 526 526 } -
vuelve/trunk/src/Cart/CartRestore.php
r3431081 r3437406 332 332 } 333 333 if ($k === 'marketing_consent') { 334 $wc->session->set('vuelve_marketing_consent ', $v);334 $wc->session->set('vuelve_marketing_consent_v2', $v); 335 335 } 336 336 } -
vuelve/trunk/src/ConsentCheckbox/ConsentCheckbox.php
r3435705 r3437406 12 12 13 13 private function get_merchant_default() { 14 return get_option('vuelve_consent_default_checked', '1'); // Defaults to 0 (unchecked) 14 // Standardizing to '1' (Checked) for version 1.0.2 15 return get_option('vuelve_consent_v2_default_checked', '1'); 15 16 } 16 17 … … 31 32 32 33 add_filter('woocommerce_form_field', function ($field, $key, $args, $value) { 33 if ($key === 'vuelve_marketing_consent ') { // <-- use your field key/id here34 if ($key === 'vuelve_marketing_consent_v2') { // <-- use your field key/id here 34 35 // Strip the <span class="optional">…</span> 35 36 $field = preg_replace('/<span class="optional">.*?<\/span>/i', '', $field); … … 71 72 if ( function_exists('WC') && WC()->session ) { 72 73 // error_log('marketing consent change 2: '.$consent); 73 WC()->session->set('vuelve_marketing_consent ', $consent);74 WC()->session->set('vuelve_marketing_consent_v2', $consent); 74 75 Vuelve_CartCapture::update_cart_image(); 75 76 } … … 78 79 $uid = get_current_user_id(); 79 80 // error_log('marketing consent userMeta change 1'. $consent); 80 update_user_meta($uid, 'vuelve_marketing_consent ', $consent);81 update_user_meta($uid, 'vuelve_marketing_consent_v2', $consent); 81 82 update_user_meta($uid, 'vuelve_marketing_consent_ts', $now); 82 83 } … … 108 109 // error_log("update_consent_classic 1"); 109 110 if ( function_exists('WC') && WC()->session ) { 110 $isNull = is_null( WC()->session->get('vuelve_marketing_consent ', null) );111 $isNull = is_null( WC()->session->get('vuelve_marketing_consent_v2', null) ); 111 112 if($isNull) { 112 WC()->session->set('vuelve_marketing_consent ', $this->get_merchant_default());113 WC()->session->set('vuelve_marketing_consent_v2', $this->get_merchant_default()); 113 114 } else { 114 115 // error_log("marketing consent change 3"); 115 if (array_key_exists('vuelve_marketing_consent ', $form)) {116 if (array_key_exists('vuelve_marketing_consent_v2', $form)) { 116 117 // error_log("update_consent_classic 3"); 117 $consentRaw = sanitize_text_field( $form['vuelve_marketing_consent '] );118 $consentRaw = sanitize_text_field( $form['vuelve_marketing_consent_v2'] ); 118 119 $consent = absint( ! empty( $consentRaw ) ); 119 120 // error_log("marketing consent change 4: " . $consent); 120 121 // error_log("marketing consent change 4: ".$consent); 121 WC()->session->set('vuelve_marketing_consent ', $consent);122 WC()->session->set('vuelve_marketing_consent_v2', $consent); 122 123 123 124 if ( is_user_logged_in() ) { … … 125 126 $now = time(); 126 127 $uid = get_current_user_id(); 127 update_user_meta($uid, 'vuelve_marketing_consent ', $consent);128 update_user_meta($uid, 'vuelve_marketing_consent_v2', $consent); 128 129 update_user_meta($uid, 'vuelve_marketing_consent_ts', $now); 129 130 } … … 132 133 // error_log("marketing consent change 6: 0"); 133 134 // error_log("marketing consent change 5: 0"); 134 WC()->session->set('vuelve_marketing_consent ', 0);135 WC()->session->set('vuelve_marketing_consent_v2', 0); 135 136 136 137 if ( is_user_logged_in() ) { … … 138 139 $now = time(); 139 140 $uid = get_current_user_id(); 140 update_user_meta($uid, 'vuelve_marketing_consent ', 0);141 update_user_meta($uid, 'vuelve_marketing_consent_v2', 0); 141 142 update_user_meta($uid, 'vuelve_marketing_consent_ts', $now); 142 143 } … … 151 152 /** Classic checkout: native field that triggers totals refresh */ 152 153 public function add_classic_field( $fields ) { 153 if ( isset($fields['billing']['vuelve_marketing_consent ']) ) return $fields;154 if ( isset($fields['billing']['vuelve_marketing_consent_v2']) ) return $fields; 154 155 155 156 $stored = 0; 156 157 if ( function_exists('WC') && WC()->session ) { 157 $isNull = is_null( WC()->session->get('vuelve_marketing_consent ', null) );158 $isNull = is_null( WC()->session->get('vuelve_marketing_consent_v2', null) ); 158 159 if($isNull) { 159 160 $stored = $this->get_merchant_default(); 160 161 } else { 161 $stored = WC()->session->get('vuelve_marketing_consent ');162 } 163 } 164 165 $fields['billing']['vuelve_marketing_consent '] = [162 $stored = WC()->session->get('vuelve_marketing_consent_v2'); 163 } 164 } 165 166 $fields['billing']['vuelve_marketing_consent_v2'] = [ 166 167 'type' => 'checkbox', 167 168 'label' => $this->consentText, … … 176 177 177 178 public function force_consent_value( $value, $input ) { 178 if ( $input !== 'vuelve_marketing_consent ' ) {179 if ( $input !== 'vuelve_marketing_consent_v2' ) { 179 180 return $value; 180 181 } … … 183 184 $stored = null; 184 185 if ( function_exists('WC') && WC()->session ) { 185 $stored = WC()->session->get('vuelve_marketing_consent ', null);186 $stored = WC()->session->get('vuelve_marketing_consent_v2', null); 186 187 } 187 188 … … 216 217 $init = 1; 217 218 if ( function_exists('WC') && WC()->session ) { 218 // $init = (int) WC()->session->get('vuelve_marketing_consent ', 1);219 $init = WC()->session->get('vuelve_marketing_consent ', null);219 // $init = (int) WC()->session->get('vuelve_marketing_consent_v2', 1); 220 $init = WC()->session->get('vuelve_marketing_consent_v2', null); 220 221 221 222 if ($init === null) { 222 223 $default = $this->get_merchant_default(); 223 WC()->session->set('vuelve_marketing_consent ', $default);224 WC()->session->set('vuelve_marketing_consent_v2', $default); 224 225 $init = $default; 225 226 } … … 246 247 public function render_cart_checkbox() { 247 248 if ( ! function_exists('WC') || ! WC()->session ) return; 248 $checked = (int) WC()->session->get('vuelve_marketing_consent ', $this->get_merchant_default());249 $checked = (int) WC()->session->get('vuelve_marketing_consent_v2', $this->get_merchant_default()); 249 250 ?> 250 251 <div class="vuelve-consent-cart"> … … 264 265 265 266 // public function admin_show_consent( $order ) { 266 // $cons = (int) $order->get_meta('_vuelve_marketing_consent ');267 // $cons = (int) $order->get_meta('_vuelve_marketing_consent_v2'); 267 268 // echo '<p><strong>'.esc_html__('Marketing consent','vuelve').':</strong> '.($cons?'Yes':'No').'</p>'; 268 269 // } -
vuelve/trunk/src/Event/VuelveEvent.php
r3431081 r3437406 122 122 123 123 // Your custom consent checkbox (saved in user meta) 124 $marketing_consent = (bool) get_user_meta($customer_id, 'vuelve_marketing_consent ', true);124 $marketing_consent = (bool) get_user_meta($customer_id, 'vuelve_marketing_consent_v2', true); 125 125 126 126 $country_iso = $this->vuelve_get_customer_country_code($customer_id); … … 172 172 173 173 // Your custom consent checkbox (saved in user meta) 174 $marketing_consent = (bool) get_user_meta($customer_id, 'vuelve_marketing_consent ', true);174 $marketing_consent = (bool) get_user_meta($customer_id, 'vuelve_marketing_consent_v2', true); 175 175 176 176 $country_iso = $this->vuelve_get_customer_country_code($customer_id); … … 226 226 // error_log("woocommerce_after_order_object_save 4"); 227 227 228 $marketing_consent = (bool) get_user_meta($customer_id, 'vuelve_marketing_consent ', true);228 $marketing_consent = (bool) get_user_meta($customer_id, 'vuelve_marketing_consent_v2', true); 229 229 // error_log("woocommerce_after_order_object_save 5"); 230 230 -
vuelve/trunk/vuelve.php
r3435705 r3437406 3 3 * Plugin Name: Vuelve 4 4 * Description: Adds Vuelve abandoned cart recovery and WhatsApp cart restoration to WooCommerce. 5 * Version: 1.0. 15 * Version: 1.0.3 6 6 * Author: Vuelve 7 7 * Author URI: https://vuelve.co
Note: See TracChangeset
for help on using the changeset viewer.