Changeset 3479083
- Timestamp:
- 03/10/2026 12:56:23 PM (3 weeks ago)
- Location:
- sendpulse-subscription-for-woocommerce
- Files:
-
- 18 added
- 3 edited
-
tags/1.1.7 (added)
-
tags/1.1.7/COPYRIGHT.txt (added)
-
tags/1.1.7/LICENSE.txt (added)
-
tags/1.1.7/classes (added)
-
tags/1.1.7/classes/api (added)
-
tags/1.1.7/classes/api/sendpulseClient.php (added)
-
tags/1.1.7/classes/api/sendpulseClientInterface.php (added)
-
tags/1.1.7/classes/class-sendpulse-blocks.php (added)
-
tags/1.1.7/classes/class-wc-integration-sendpulse.php (added)
-
tags/1.1.7/languages (added)
-
tags/1.1.7/languages/sendpulse-subscription-for-woocommerce-ru_RU.mo (added)
-
tags/1.1.7/languages/sendpulse-subscription-for-woocommerce-ru_RU.po (added)
-
tags/1.1.7/languages/sendpulse-subscription-for-woocommerce-uk.mo (added)
-
tags/1.1.7/languages/sendpulse-subscription-for-woocommerce-uk.po (added)
-
tags/1.1.7/languages/sendpulse-subscription-for-woocommerce.pot (added)
-
tags/1.1.7/readme.txt (added)
-
tags/1.1.7/sendpulse-subscription-for-woocommerce.php (added)
-
trunk/classes/class-sendpulse-blocks.php (added)
-
trunk/classes/class-wc-integration-sendpulse.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/sendpulse-subscription-for-woocommerce.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sendpulse-subscription-for-woocommerce/trunk/classes/class-wc-integration-sendpulse.php
r3346815 r3479083 21 21 private $confirm_opt_checkbox_default_status; 22 22 private $confirm_opt_checkbox_display_location; 23 private $client = null; 23 24 24 25 /** … … 77 78 }); 78 79 79 add_action('woocommerce_checkout_update_order_meta', array($this, 'order_status_changed'), 1000, 1);80 //add_action('woocommerce_checkout_update_order_meta', array($this, 'order_status_changed'), 1000, 1); 80 81 add_action('woocommerce_order_status_changed', array($this, 'order_status_changed'), 10, 3); 81 82 add_filter('woocommerce_checkout_fields', array($this, 'add_checkout_fields')); … … 209 210 } 210 211 211 // public function process_admin_options() {212 // // Verify nonce213 // if (214 // !isset($_POST['_wpnonce']) ||215 // !wp_verify_nonce(216 // sanitize_text_field(wp_unslash($_POST['_wpnonce'])),217 // 'woocommerce-settings'218 // )219 // ) {220 // wp_die(esc_html__('Invalid request. Please refresh the page and try again.', 'sendpulse-subscription-for-woocommerce'));221 // }222 //223 // $this->api_id = !empty($_POST['woocommerce_sendpulse_api_id'])224 // ? sanitize_text_field(wp_unslash($_POST['woocommerce_sendpulse_api_id']))225 // : $this->get_option('api_id');226 //227 // $this->api_secret = !empty($_POST['woocommerce_sendpulse_api_secret'])228 // ? sanitize_text_field(wp_unslash($_POST['woocommerce_sendpulse_api_secret']))229 // : $this->get_option('api_secret');230 //231 // $this->storageType = !empty($_POST['woocommerce_sendpulse_keep_token'])232 // ? sanitize_text_field(wp_unslash($_POST['woocommerce_sendpulse_keep_token']))233 // : $this->get_option('keep_token');234 //235 // $previous_keep_token = $this->get_option('keep_token', 'wp_options');236 //237 // // Capture parent result238 // $result = parent::process_admin_options();239 //240 // if (isset($_POST['woocommerce_sendpulse_keep_token'])) {241 // $new_keep_token = sanitize_text_field(wp_unslash($_POST['woocommerce_sendpulse_keep_token']));242 // update_option('woocommerce_sendpulse_keep_token', $new_keep_token);243 //244 // if ($previous_keep_token !== $new_keep_token) {245 // $this->deleteTokenFromStorage($previous_keep_token);246 // }247 //248 // $this->storageType = $new_keep_token;249 // } else {250 // $this->storageType = $previous_keep_token;251 // }252 //253 // return $result;254 // }255 256 // public function process_admin_options() {257 // // Verify nonce258 // if (259 // !isset($_POST['_wpnonce']) ||260 // !wp_verify_nonce(261 // sanitize_text_field(wp_unslash($_POST['_wpnonce'])),262 // 'woocommerce-settings'263 // )264 // ) {265 // wp_die(esc_html__('Invalid request. Please refresh the page and try again.', 'sendpulse-subscription-for-woocommerce'));266 // }267 //268 // $previous_api_id = $this->get_option('api_id');269 // $previous_api_secret = $this->get_option('api_secret');270 // $previous_keep_token = $this->get_option('keep_token', 'wp_options');271 //272 // $this->api_id = !empty($_POST['woocommerce_sendpulse_api_id'])273 // ? sanitize_text_field(wp_unslash($_POST['woocommerce_sendpulse_api_id']))274 // : $this->get_option('api_id');275 //276 // $this->api_secret = !empty($_POST['woocommerce_sendpulse_api_secret'])277 // ? sanitize_text_field(wp_unslash($_POST['woocommerce_sendpulse_api_secret']))278 // : $this->get_option('api_secret');279 //280 // $this->storageType = !empty($_POST['woocommerce_sendpulse_keep_token'])281 // ? sanitize_text_field(wp_unslash($_POST['woocommerce_sendpulse_keep_token']))282 // : $this->get_option('keep_token');283 //284 // // Save settings normally285 // $result = parent::process_admin_options();286 //287 // // If storage type changed, delete token from old storage288 // if (isset($_POST['woocommerce_sendpulse_keep_token'])) {289 // $new_keep_token = sanitize_text_field(wp_unslash($_POST['woocommerce_sendpulse_keep_token']));290 // update_option('woocommerce_sendpulse_keep_token', $new_keep_token);291 //292 // if ( $previous_keep_token !== $new_keep_token && ($previous_api_id !== $this->api_id || $previous_api_secret !== $this->api_secret) ) {293 // $this->deleteTokenFromStorage($previous_keep_token);294 // }295 // $this->storageType = $new_keep_token;296 // } else {297 // $this->storageType = $previous_keep_token;298 // }299 //300 // // If API credentials changed, delete token so a new one will be fetched301 //// if ($previous_api_id !== $this->api_id || $previous_api_secret !== $this->api_secret) {302 //// $this->deleteTokenFromStorage($this->storageType);303 //// }304 //305 // //$this->getToken();306 //// if (!empty($this->client) && method_exists($this->client, 'getToken')) {307 //// $this->client->getToken();308 //// }309 //310 // return $result;311 // }312 313 212 public function process_admin_options() { 314 213 // Verify nonce … … 496 395 } 497 396 498 public function order_status_changed($id, $old_status = 'new', $new_status = 'pending') { 499 if ($this->s_api && $this->module_status && $new_status === $this->subscr_time) { 500 $order = $this->wc_get_order($id); 501 502 $subscribe_customer = get_post_meta($id, 'sendpulse-for-woocommerce_confirm_opt', true); 503 504 if (empty($subscribe_customer) || $subscribe_customer === 'yes') { 505 $this->syncUserAbook( 506 $order->billing_email, 507 $order->billing_first_name, 508 $order->billing_last_name, 509 $order->billing_phone, 510 $order->billing_company, 511 $order->billing_country, 512 $order->billing_state, 513 $order->billing_city 397 public function order_status_changed( $id, $old_status = 'new', $new_status = 'pending' ) { 398 // Preconditions 399 if ( ! $this->s_api || ! $this->module_status ) { 400 return; 401 } 402 if ( $new_status !== $this->subscr_time ) { 403 return; 404 } 405 406 $order = $this->wc_get_order( $id ); 407 if ( ! $order ) { 408 return; 409 } 410 411 $consent = $order->get_meta( 'sendpulse-for-woocommerce_confirm_opt', true ); // 'yes'|'no'|'' 412 $explicit_yes = ( $consent === 'yes' ); 413 $optin_ui_enabled = ( 'yes' === $this->show_confirm_opt ); 414 $should_subscribe = $optin_ui_enabled ? $explicit_yes : true; 415 416 if ( ! $should_subscribe ) { 417 if ( function_exists( 'wc_get_logger' ) ) { 418 wc_get_logger()->info( 419 sprintf( 'SendPulse: not subscribing order #%d (opt-in required; canonical consent=%s).', $id, var_export( $consent, true ) ), 420 [ 'source' => 'sendpulse' ] 514 421 ); 515 422 } 423 return; 424 } 425 426 // Subscribe using getters 427 $this->syncUserAbook( 428 $order->get_billing_email(), 429 $order->get_billing_first_name(), 430 $order->get_billing_last_name(), 431 $order->get_billing_phone(), 432 $order->get_billing_company(), 433 $order->get_billing_country(), 434 $order->get_billing_state(), 435 $order->get_billing_city() 436 ); 437 438 if ( function_exists( 'wc_get_logger' ) ) { 439 wc_get_logger()->info( sprintf( 'SendPulse: subscribed order #%d.', $id ), [ 'source' => 'sendpulse' ] ); 516 440 } 517 441 } 442 518 443 519 444 private function wc_get_order($order_id) { … … 526 451 527 452 function save_checkout_fields($order_id) { 528 // Verify nonce 529 if ( !isset($_POST['_wpnonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'woocommerce-settings')) { 530 wp_die(esc_html__('Invalid request. Please refresh the page and try again.', 'sendpulse-subscription-for-woocommerce')); 531 } 453 // Skip on Store API (Blocks) requests — consent is handled in class-sendpulse-blocks.php 454 455 if ( 456 ( defined( 'REST_REQUEST' ) && REST_REQUEST ) && 457 isset( $_SERVER['REQUEST_URI'] ) && 458 strpos( $_SERVER['REQUEST_URI'], '/wc/store/' ) !== false 459 ) { 460 return; 461 } 532 462 533 463 if ('yes' == $this->show_confirm_opt) { 534 464 $opt_in = isset($_POST['sendpulse-for-woocommerce_confirm_opt']) ? 'yes' : 'no'; 535 update_post_meta($order_id, 'sendpulse-for-woocommerce_confirm_opt', $opt_in); 465 $order = $this->wc_get_order( $order_id ); 466 if ( $order ) { 467 $order->update_meta_data( 'sendpulse-for-woocommerce_confirm_opt', $opt_in ); 468 $order->save(); 469 } 536 470 } 537 471 } -
sendpulse-subscription-for-woocommerce/trunk/readme.txt
r3473375 r3479083 9 9 Tested up to: 6.8 10 10 WC requires at least: 6.0 11 WC tested up to: 10. 0.412 Stable tag: 1.1. 513 License: G NU General Public License v3.014 License URI: http ://www.gnu.org/licenses/gpl-2.0.html11 WC tested up to: 10.3.8 12 Stable tag: 1.1.7 13 License: GPLv3 14 License URI: https://www.gnu.org/licenses/gpl-3.0.html 15 15 16 16 Start email marketing to your customers using SendPulse. … … 112 112 113 113 == Changelog == 114 = 1.1.7 = 115 * Fix opt-in checkbox consent handling for WooCommerce checkout (Blocks and classic checkout compatibility) 116 * Improve consent detection logic for WooCommerce HPOS and Store API 114 117 115 = 1.1. 3=116 * Initial Release to WordPress Plugin's Directory118 = 1.1.5 = 119 * Fix settings link from WordPress plugins page 117 120 118 121 = 1.1.4 = … … 121 124 * Tested up to WordPress 6.8.2 and WooCommerce 10.0.4 122 125 123 = 1.1. 5=124 * Fix settings link from WordPress plugins page126 = 1.1.3 = 127 * Initial Release to WordPress Plugin's Directory 125 128 126 129 == Upgrade Notice == -
sendpulse-subscription-for-woocommerce/trunk/sendpulse-subscription-for-woocommerce.php
r3352615 r3479083 6 6 * Author: SendPulse 7 7 * Author URI: https://sendpulse.com 8 * Version: 1.1. 58 * Version: 1.1.7 9 9 * Text Domain: sendpulse-subscription-for-woocommerce 10 10 * Domain Path: /languages … … 19 19 exit; 20 20 } 21 22 require_once __DIR__ . '/classes/class-sendpulse-blocks.php'; 21 23 22 24 function add_sendpulse_integration($methods) {
Note: See TracChangeset
for help on using the changeset viewer.