Changeset 3343001
- Timestamp:
- 08/11/2025 04:15:49 PM (8 months ago)
- Location:
- mailchimp-for-woocommerce/trunk
- Files:
-
- 3 added
- 16 edited
-
CHANGELOG.txt (modified) (1 diff)
-
README.txt (modified) (2 diffs)
-
admin/class-mailchimp-woocommerce-admin.php (modified) (8 diffs)
-
admin/js/mailchimp-woocommerce-create-account.js (modified) (3 diffs)
-
admin/v2/templates/connect-accounts/create-account-page.php (modified) (3 diffs)
-
blocks/package-lock.json (modified) (19 diffs)
-
bootstrap.php (modified) (12 diffs)
-
docs (added)
-
docs/enhanced-logging.md (added)
-
includes/api/class-mailchimp-api.php (modified) (9 diffs)
-
includes/api/class-mailchimp-woocommerce-logs.php (modified) (3 diffs)
-
includes/api/class-mailchimp-woocommerce-transform-products.php (modified) (5 diffs)
-
includes/class-mailchimp-woocommerce-enhanced-logger.php (added)
-
includes/class-mailchimp-woocommerce-hpos.php (modified) (1 diff)
-
includes/class-mailchimp-woocommerce-service.php (modified) (6 diffs)
-
includes/class-mailchimp-woocommerce.php (modified) (1 diff)
-
includes/processes/class-mailchimp-woocommerce-full-sync-manager.php (modified) (1 diff)
-
includes/processes/class-mailchimp-woocommerce-single-product.php (modified) (1 diff)
-
mailchimp-woocommerce.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mailchimp-for-woocommerce/trunk/CHANGELOG.txt
r3273692 r3343001 1 1 == Changelog == 2 = 5.5 = 3 * WooCommerce block dependency updates 4 * Logging enhancements 5 * Better compatibility when external object cache is detected 6 * Refactor Connected Sites API connection 7 * Adds support for Product visibility logic for syncing 2 8 = 5.4 = 3 9 * Performance and User Interface improvements -
mailchimp-for-woocommerce/trunk/README.txt
r3273739 r3343001 8 8 Requires PHP: 7.4 9 9 WC requires at least: 8.2 10 WC tested up to: 9.810 WC tested up to: 10.0 11 11 License: GPLv2 or later 12 12 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 79 79 80 80 == Changelog == 81 = 5.4 = 82 * Performance and User Interface improvements 83 * Ability to sync Product Short Description 81 = 5.5 = 82 * WooCommerce block dependency updates 83 * Logging enhancements 84 * Better compatibility when external object cache is detected 85 * Refactor Connected Sites API connection 86 * Adds support for Product visibility logic for syncing -
mailchimp-for-woocommerce/trunk/admin/class-mailchimp-woocommerce-admin.php
r3273692 r3343001 87 87 */ 88 88 private function is_disconnecting() { 89 return isset( $_REQUEST['mailchimp_woocommerce_disconnect_store'] )89 return isset( $_REQUEST['mailchimp_woocommerce_disconnect_store'] ) 90 90 && current_user_can( mailchimp_get_allowed_capability() ) 91 91 && $_REQUEST['mailchimp_woocommerce_disconnect_store'] == 1 … … 140 140 $checkbox_default_settings = ( array_key_exists( 'mailchimp_checkbox_defaults', $options ) && ! is_null( $options['mailchimp_checkbox_defaults'] ) ) ? $options['mailchimp_checkbox_defaults'] : 'check'; 141 141 wp_register_script( $this->plugin_name . 'create-account', plugin_dir_url( __FILE__ ) . 'js/mailchimp-woocommerce-create-account.js', array( 'jquery', 'swal' ), $this->version ); 142 wp_register_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mailchimp-woocommerce-admin.js', array( 'jquery', 'swal' ), $this->version );142 wp_register_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mailchimp-woocommerce-admin.js', array( 'jquery', 'swal' ), $this->version . 'test-122' ); 143 143 wp_register_script( $this->plugin_name . '-v2', plugin_dir_url( __FILE__ ) . 'v2/assets/js/scripts.js', array( 'jquery', 'swal' ), $this->version ); 144 144 wp_localize_script( … … 856 856 if ( $this->is_disconnecting() ) { 857 857 // Disconnect store! 858 if ( $this->disconnect_store() ) {858 if ( $this->disconnect_store() ) { 859 859 return array( 860 860 'active_tab' => 'api_key', … … 1055 1055 $result = json_decode( $response['body'], true); 1056 1056 $options = \Mailchimp_Woocommerce_DB_Helpers::get_option($this->plugin_name); 1057 $options['mailchimp_api_key'] = $result['access_token'].'-'.$result['data_center']; 1057 $api_key = $result['access_token'].'-'.$result['data_center']; 1058 $options['mailchimp_api_key'] = $api_key; 1058 1059 1059 1060 // \Mailchimp_Woocommerce_DB_Helpers::update_option($this->plugin_name, $options); this used to return false! … … 1066 1067 Mailchimp_Woocommerce_Event::track('connect_accounts_oauth:complete', new DateTime()); 1067 1068 1068 do_action('mailchimp_woocommerce_connected_to_mailchimp' );1069 do_action('mailchimp_woocommerce_connected_to_mailchimp', $api_key); 1069 1070 1070 1071 wp_send_json_success( $response ); … … 1235 1236 $result = json_decode( $response['body'], true); 1236 1237 $options = get_option($this->plugin_name, array()); 1237 $options['mailchimp_api_key'] = $result['data']['oauth_token'].'-'.$result['data']['dc']; 1238 $api_key = $result['data']['oauth_token'].'-'.$result['data']['dc']; 1239 $options['mailchimp_api_key'] = $api_key; 1238 1240 // go straight to the DB and update the options to bypass any filters. 1239 1241 $wpdb->update( … … 1246 1248 $response_body->redirect = admin_url('admin.php?page=mailchimp-woocommerce'); 1247 1249 1248 do_action('mailchimp_woocommerce_connected_to_mailchimp' );1250 do_action('mailchimp_woocommerce_connected_to_mailchimp', $api_key); 1249 1251 1250 1252 wp_send_json_success( $response_body ); … … 1252 1254 wp_send_json_error( array( 'success' => false ) ); 1253 1255 } else { 1256 $response_error = json_decode( $response_body->error, true ); 1254 1257 $username = preg_replace( '/[^A-Za-z0-9\-\@\.]/', '', $_POST['data']['username'] ); 1255 1258 $suggestion = wp_remote_get( 'https://woocommerce.mailchimpapp.com/api/usernames/suggestions/' . $username ); 1256 1259 $suggested_username = json_decode( $suggestion['body'] )->data; 1260 1257 1261 wp_send_json_error( 1258 1262 array( 1259 1263 'success' => false, 1260 ' suggest_login' => true,1264 'errors' => $response_error['errors'], 1261 1265 'suggested_username' => $suggested_username, 1266 'response' => $response, 1267 'response_body' => $response_body, 1262 1268 ) 1263 1269 ); 1264 1270 } 1265 1271 } 1272 1273 public function connect_account_flow_switch_account() 1274 { 1275 if ( 1276 current_user_can( mailchimp_get_allowed_capability() ) 1277 && isset( $_POST['data']['_disconnect-nonce'] ) 1278 && wp_verify_nonce( $_POST['data']['_disconnect-nonce'], '_disconnect-nonce-' . mailchimp_get_store_id() ) 1279 ) { 1280 $this->disconnect_store(); 1281 \Mailchimp_Woocommerce_DB_Helpers::delete_option('mailchimp-woocommerce-waiting-for-login'); 1282 1283 return wp_send_json_success(array( 1284 'success' => true, 1285 'redirect' => admin_url('admin.php?page=mailchimp-woocommerce') 1286 )); 1287 } else { 1288 return wp_send_json_success(array('success' => false, 'message' => 'Failed to disconnect account')); 1289 } 1290 } 1266 1291 1267 1292 /** -
mailchimp-for-woocommerce/trunk/admin/js/mailchimp-woocommerce-create-account.js
r3273692 r3343001 55 55 } 56 56 }) 57 58 59 $('#js-mc-woocommerce-switch-account').submit((e) => { 60 e.preventDefault(); 61 62 $("#js-mc-woocommerce-switch-account-button").attr('disabled', true) 63 $("#js-mc-woocommerce-switch-account-button .mc-wc-loading").removeClass('hidden') 64 65 let formData = $(e.target).serializeArray() 66 let formDataObject = {}; 67 formData.map(obj => { 68 let newObj = {} 69 formDataObject[obj.name] = obj.value 70 return newObj 71 }) 72 73 var data = { 74 action: 'mailchimp_woocommerce_switch_account', 75 data: formDataObject 76 }; 77 78 $.ajax({ 79 type: "post", 80 dataType: "json", 81 url: phpVars.ajaxurl, 82 data: data, 83 success: function (response) { 84 console.log('response', response.data) 85 if (response.data.success) { 86 window.location.href = response.data.redirect 87 } else { 88 alert(response.data.message) 89 } 90 }, 91 error: function (error) { 92 console.log('error', error) 93 } 94 }) 95 }); 57 96 58 97 $('.js-mc-woocommerce-activate-account').submit((e) => { … … 90 129 data: postData 91 130 }; 131 $('#mc-woocommerce-error-box').empty(); 92 132 $.ajax({ 93 133 type : "post", … … 96 136 data : data, 97 137 success: function(response) { 98 if (response.data.suggest_login) { 99 $('.js-mc-woocommerce-activate-account').addClass('hidden') 100 $("#mc-woocommerce-create-activate-account").attr('disabled', false) 101 $("#mc-woocommerce-create-activate-account .mc-wc-loading").addClass('hidden') 102 103 $('.js-mc-woocommerce-suggest-to-login').removeClass('hidden'); 104 $('.js-mc-woocommerce-email').text(formDataObject.email) 105 $('.mailchimp-connect').attr('href', response.data.login_link) 138 console.log('response', response.data) 139 140 if (!response.data.success) { 141 let errorHasUsername = response.data.errors?.some(err => err.field === 'username') 142 if (errorHasUsername) { 143 $('.js-mc-woocommerce-activate-account').addClass('hidden') 144 $("#mc-woocommerce-create-activate-account").attr('disabled', false) 145 $("#mc-woocommerce-create-activate-account .mc-wc-loading").addClass('hidden') 146 147 $('.js-mc-woocommerce-suggest-to-login').removeClass('hidden'); 148 $('.js-mc-woocommerce-email').text(formDataObject.email) 149 $('.mailchimp-connect').attr('href', response.data.login_link) 150 } else if (response.data.errors) { 151 let errorMessage = '' 152 console.log('errors', response.data.errors) 153 response.data.errors?.forEach(err => { 154 errorMessage += `<div class="error">${err.message}</div>` 155 }); 156 $("#mc-woocommerce-create-activate-account").attr('disabled', false) 157 $("#mc-woocommerce-create-activate-account .mc-wc-loading").addClass('hidden') 158 $('#mc-woocommerce-error-box').append(errorMessage) 159 } 106 160 } else { 107 161 window.location.href = response.data.redirect -
mailchimp-for-woocommerce/trunk/admin/v2/templates/connect-accounts/create-account-page.php
r3273692 r3343001 24 24 Mailchimp_Woocommerce_Event::track('connect_accounts:view_create_account', new \DateTime()); 25 25 } 26 $store_id = mailchimp_get_store_id(); 27 26 28 ?> 27 29 <div id="mc-woocommerce-create-account"> … … 294 296 </div> 295 297 <div class="box"> 298 <div id="mc-woocommerce-error-box"></div> 296 299 <button type="submit" id="mc-woocommerce-create-activate-account" class="button button-primary create-account-save"> 297 <span class="mc-wc-loading hidden">298 <svg class="animate-spin" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">299 <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor"300 stroke-width="4"></circle>301 <path class="opacity-75" fill="currentColor"302 d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>303 </svg>304 </span>305 <?php esc_html_e( 'Activate Account', 'mailchimp-for-woocommerce' ); ?>300 <span class="mc-wc-loading hidden"> 301 <svg class="animate-spin" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"> 302 <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" 303 stroke-width="4"></circle> 304 <path class="opacity-75" fill="currentColor" 305 d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> 306 </svg> 307 </span> 308 <?php esc_html_e( 'Activate Account', 'mailchimp-for-woocommerce' ); ?> 306 309 </button> 307 310 </div> … … 370 373 </a> 371 374 </div> 372 </div> 375 376 <div class="mc-wc-button-disconnect"> 377 <form id="js-mc-woocommerce-switch-account"> 378 <?php wp_nonce_field( '_disconnect-nonce-' . $store_id, '_disconnect-nonce' ); ?> 379 <button id="js-mc-woocommerce-switch-account-button" type="submit" class="button create-account-save"> 380 <span class="mc-wc-loading hidden"> 381 <svg class="animate-spin" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"> 382 <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" 383 stroke-width="4"></circle> 384 <path class="opacity-75" fill="currentColor" 385 d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> 386 </svg> 387 </span> 388 <?php esc_html_e('Switch account', 'mailchimp-for-woocommerce' ); ?></button> 389 </form> 390 </div> 391 </div> 373 392 <div id="mailchimp_woocommerce_options" class="js-mc-woocommerce-suggest-to-login hidden"> 374 393 <div class="title"><?php echo esc_html__( 'Login', 'mailchimp-for-woocommerce' ) ?></div> -
mailchimp-for-woocommerce/trunk/blocks/package-lock.json
r3273692 r3343001 8122 8122 } 8123 8123 }, 8124 "node_modules/body-parser/node_modules/bytes": {8125 "version": "3.1.2",8126 "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",8127 "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",8128 "dev": true,8129 "engines": {8130 "node": ">= 0.8"8131 }8132 },8133 8124 "node_modules/body-parser/node_modules/debug": { 8134 8125 "version": "2.6.9", … … 8293 8284 }, 8294 8285 "node_modules/bytes": { 8295 "version": "3.0.0", 8296 "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", 8297 "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", 8298 "dev": true, 8286 "version": "3.1.2", 8287 "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", 8288 "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", 8289 "dev": true, 8290 "license": "MIT", 8299 8291 "engines": { 8300 8292 "node": ">= 0.8" … … 8318 8310 "funding": { 8319 8311 "url": "https://github.com/sponsors/ljharb" 8312 } 8313 }, 8314 "node_modules/call-bind-apply-helpers": { 8315 "version": "1.0.2", 8316 "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", 8317 "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", 8318 "dev": true, 8319 "license": "MIT", 8320 "dependencies": { 8321 "es-errors": "^1.3.0", 8322 "function-bind": "^1.1.2" 8323 }, 8324 "engines": { 8325 "node": ">= 0.4" 8320 8326 } 8321 8327 }, … … 8846 8852 }, 8847 8853 "node_modules/compression": { 8848 "version": "1. 7.4",8849 "resolved": "https://registry.npmjs.org/compression/-/compression-1. 7.4.tgz",8850 "integrity": "sha512- jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ==",8851 "dev": true, 8852 " dependencies": {8853 "accepts": "~1.3.5",8854 "bytes": "3. 0.0",8855 "compressible": "~2.0.1 6",8854 "version": "1.8.1", 8855 "resolved": "https://registry.npmjs.org/compression/-/compression-1.8.1.tgz", 8856 "integrity": "sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w==", 8857 "dev": true, 8858 "license": "MIT", 8859 "dependencies": { 8860 "bytes": "3.1.2", 8861 "compressible": "~2.0.18", 8856 8862 "debug": "2.6.9", 8857 "on-headers": "~1.0.2", 8858 "safe-buffer": "5.1.2", 8863 "negotiator": "~0.6.4", 8864 "on-headers": "~1.1.0", 8865 "safe-buffer": "5.2.1", 8859 8866 "vary": "~1.1.2" 8860 8867 }, … … 8878 8885 "dev": true 8879 8886 }, 8880 "node_modules/compression/node_modules/safe-buffer": { 8881 "version": "5.1.2", 8882 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 8883 "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", 8884 "dev": true 8887 "node_modules/compression/node_modules/negotiator": { 8888 "version": "0.6.4", 8889 "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz", 8890 "integrity": "sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==", 8891 "dev": true, 8892 "license": "MIT", 8893 "engines": { 8894 "node": ">= 0.6" 8895 } 8885 8896 }, 8886 8897 "node_modules/compute-scroll-into-view": { … … 10107 10118 "peerDependencies": { 10108 10119 "react": ">=16.12.0" 10120 } 10121 }, 10122 "node_modules/dunder-proto": { 10123 "version": "1.0.1", 10124 "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", 10125 "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", 10126 "dev": true, 10127 "license": "MIT", 10128 "dependencies": { 10129 "call-bind-apply-helpers": "^1.0.1", 10130 "es-errors": "^1.3.0", 10131 "gopd": "^1.2.0" 10132 }, 10133 "engines": { 10134 "node": ">= 0.4" 10109 10135 } 10110 10136 }, … … 10311 10337 }, 10312 10338 "node_modules/es-define-property": { 10313 "version": "1.0.0", 10314 "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", 10315 "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", 10316 "dev": true, 10317 "dependencies": { 10318 "get-intrinsic": "^1.2.4" 10319 }, 10339 "version": "1.0.1", 10340 "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", 10341 "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", 10342 "dev": true, 10343 "license": "MIT", 10320 10344 "engines": { 10321 10345 "node": ">= 0.4" … … 10337 10361 "dev": true 10338 10362 }, 10363 "node_modules/es-object-atoms": { 10364 "version": "1.1.1", 10365 "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", 10366 "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", 10367 "dev": true, 10368 "license": "MIT", 10369 "dependencies": { 10370 "es-errors": "^1.3.0" 10371 }, 10372 "engines": { 10373 "node": ">= 0.4" 10374 } 10375 }, 10339 10376 "node_modules/es-set-tostringtag": { 10340 "version": "2.0.1", 10341 "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", 10342 "integrity": "sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==", 10343 "dev": true, 10344 "dependencies": { 10345 "get-intrinsic": "^1.1.3", 10346 "has": "^1.0.3", 10347 "has-tostringtag": "^1.0.0" 10377 "version": "2.1.0", 10378 "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", 10379 "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", 10380 "dev": true, 10381 "license": "MIT", 10382 "dependencies": { 10383 "es-errors": "^1.3.0", 10384 "get-intrinsic": "^1.2.6", 10385 "has-tostringtag": "^1.0.2", 10386 "hasown": "^2.0.2" 10348 10387 }, 10349 10388 "engines": { … … 11815 11854 }, 11816 11855 "node_modules/form-data": { 11817 "version": "4.0.0", 11818 "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 11819 "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 11820 "dev": true, 11856 "version": "4.0.4", 11857 "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", 11858 "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", 11859 "dev": true, 11860 "license": "MIT", 11821 11861 "dependencies": { 11822 11862 "asynckit": "^0.4.0", 11823 11863 "combined-stream": "^1.0.8", 11864 "es-set-tostringtag": "^2.1.0", 11865 "hasown": "^2.0.2", 11824 11866 "mime-types": "^2.1.12" 11825 11867 }, … … 11990 12032 }, 11991 12033 "node_modules/get-intrinsic": { 11992 "version": "1.2.4", 11993 "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", 11994 "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", 11995 "dev": true, 11996 "dependencies": { 12034 "version": "1.3.0", 12035 "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", 12036 "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", 12037 "dev": true, 12038 "license": "MIT", 12039 "dependencies": { 12040 "call-bind-apply-helpers": "^1.0.2", 12041 "es-define-property": "^1.0.1", 11997 12042 "es-errors": "^1.3.0", 12043 "es-object-atoms": "^1.1.1", 11998 12044 "function-bind": "^1.1.2", 11999 "has-proto": "^1.0.1", 12000 "has-symbols": "^1.0.3", 12001 "hasown": "^2.0.0" 12045 "get-proto": "^1.0.1", 12046 "gopd": "^1.2.0", 12047 "has-symbols": "^1.1.0", 12048 "hasown": "^2.0.2", 12049 "math-intrinsics": "^1.1.0" 12002 12050 }, 12003 12051 "engines": { … … 12036 12084 "funding": { 12037 12085 "url": "https://github.com/sponsors/sindresorhus" 12086 } 12087 }, 12088 "node_modules/get-proto": { 12089 "version": "1.0.1", 12090 "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", 12091 "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", 12092 "dev": true, 12093 "license": "MIT", 12094 "dependencies": { 12095 "dunder-proto": "^1.0.1", 12096 "es-object-atoms": "^1.0.0" 12097 }, 12098 "engines": { 12099 "node": ">= 0.4" 12038 12100 } 12039 12101 }, … … 12229 12291 }, 12230 12292 "node_modules/gopd": { 12231 "version": "1.0.1", 12232 "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", 12233 "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", 12234 "dev": true, 12235 "dependencies": { 12236 "get-intrinsic": "^1.1.3" 12293 "version": "1.2.0", 12294 "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", 12295 "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", 12296 "dev": true, 12297 "license": "MIT", 12298 "engines": { 12299 "node": ">= 0.4" 12237 12300 }, 12238 12301 "funding": { … … 12346 12409 }, 12347 12410 "node_modules/has-symbols": { 12348 "version": "1.0.3", 12349 "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", 12350 "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", 12351 "dev": true, 12411 "version": "1.1.0", 12412 "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", 12413 "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", 12414 "dev": true, 12415 "license": "MIT", 12352 12416 "engines": { 12353 12417 "node": ">= 0.4" … … 12358 12422 }, 12359 12423 "node_modules/has-tostringtag": { 12360 "version": "1.0.0", 12361 "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", 12362 "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", 12363 "dev": true, 12364 "dependencies": { 12365 "has-symbols": "^1.0.2" 12424 "version": "1.0.2", 12425 "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", 12426 "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", 12427 "dev": true, 12428 "license": "MIT", 12429 "dependencies": { 12430 "has-symbols": "^1.0.3" 12366 12431 }, 12367 12432 "engines": { … … 12624 12689 }, 12625 12690 "node_modules/http-proxy-middleware": { 12626 "version": "2.0.6", 12627 "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", 12628 "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", 12629 "dev": true, 12691 "version": "2.0.9", 12692 "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.9.tgz", 12693 "integrity": "sha512-c1IyJYLYppU574+YI7R4QyX2ystMtVXZwIdzazUIPIJsHuWNd+mho2j+bKoHftndicGj9yh+xjd+l0yj7VeT1Q==", 12694 "dev": true, 12695 "license": "MIT", 12630 12696 "dependencies": { 12631 12697 "@types/http-proxy": "^1.17.8", … … 15973 16039 "license": "Apache-2.0" 15974 16040 }, 16041 "node_modules/math-intrinsics": { 16042 "version": "1.1.0", 16043 "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", 16044 "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", 16045 "dev": true, 16046 "license": "MIT", 16047 "engines": { 16048 "node": ">= 0.4" 16049 } 16050 }, 15975 16051 "node_modules/mathml-tag-names": { 15976 16052 "version": "2.1.3", … … 16965 17041 }, 16966 17042 "node_modules/on-headers": { 16967 "version": "1.0.2", 16968 "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", 16969 "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", 16970 "dev": true, 17043 "version": "1.1.0", 17044 "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz", 17045 "integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==", 17046 "dev": true, 17047 "license": "MIT", 16971 17048 "engines": { 16972 17049 "node": ">= 0.8" … … 18536 18613 "unpipe": "1.0.0" 18537 18614 }, 18538 "engines": {18539 "node": ">= 0.8"18540 }18541 },18542 "node_modules/raw-body/node_modules/bytes": {18543 "version": "3.1.2",18544 "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",18545 "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",18546 "dev": true,18547 18615 "engines": { 18548 18616 "node": ">= 0.8" … … 20848 20916 }, 20849 20917 "node_modules/tar-fs": { 20850 "version": "3.0. 8",20851 "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0. 8.tgz",20852 "integrity": "sha512- ZoROL70jptorGAlgAYiLoBLItEKw/fUxg9BSYK/dF/GAGYFJOJJJMvjPAKDJraCXFwadD456FCuvLWgfhMsPwg==",20918 "version": "3.0.9", 20919 "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.9.tgz", 20920 "integrity": "sha512-XF4w9Xp+ZQgifKakjZYmFdkLoSWd34VGKcsTCwlNWM7QG3ZbaxnTsaBwnjFZqHRf/rROxaR8rXnbtwdvaDI+lA==", 20853 20921 "dev": true, 20854 20922 "license": "MIT", -
mailchimp-for-woocommerce/trunk/bootstrap.php
r3273692 r3343001 92 92 'MailChimp_WooCommerce_Tower' => 'includes/api/class-mailchimp-woocommerce-tower.php', 93 93 'MailChimp_WooCommerce_Log_Viewer' => 'includes/api/class-mailchimp-woocommerce-log-viewer.php', 94 'MailChimp_WooCommerce_Enhanced_Logger' => 'includes/class-mailchimp-woocommerce-enhanced-logger.php', 94 95 ); 95 96 … … 112 113 'repo' => 'master', 113 114 'environment' => 'production', // staging or production 114 'version' => '5. 4',115 'version' => '5.5', 115 116 'php_version' => phpversion(), 116 117 'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version), … … 134 135 135 136 if ($job->get_attempts() <= 5) { 137 $job_class = get_class($job); 136 138 137 139 $args = array( … … 142 144 143 145 $existing_actions = function_exists('as_get_scheduled_actions') ? as_get_scheduled_actions(array( 144 'hook' => get_class($job), 145 'status' => ActionScheduler_Store::STATUS_PENDING, 146 'hook' => $job_class, 147 'status' => ActionScheduler_Store::STATUS_PENDING, 148 'group' => 'mc-woocommerce', 146 149 'args' => array( 147 150 'obj_id' => isset($job->id) ? $job->id : null), 148 'group' => 'mc-woocommerce'149 151 ) 150 152 ) : null; … … 152 154 if (!empty($existing_actions)) { 153 155 try { 154 as_unschedule_action(get_class($job), array('obj_id' => $job->id), 'mc-woocommerce'); 155 156 // updating args after unschedule to refresh data in the jo 157 $wpdb->update( 158 $wpdb->prefix . "mailchimp_jobs", 159 array( 160 'job' => maybe_serialize($job), 161 'created_at' => gmdate('Y-m-d H:i:s', time()) 162 ), 163 array('obj_id' => $job->id) 156 as_unschedule_action($job_class, array('obj_id' => $job->id), 'mc-woocommerce'); 157 158 $table = $wpdb->prefix . "mailchimp_jobs"; 159 $serialized_job = maybe_serialize($job); 160 $created_at = gmdate('Y-m-d H:i:s'); 161 162 $wpdb->query( 163 $wpdb->prepare( 164 "UPDATE $table 165 SET job = %s, created_at = %s 166 WHERE obj_id = %s AND job LIKE %s", 167 $serialized_job, 168 $created_at, 169 $job->id, 170 '%' . $job_class . '%' 171 ) 164 172 ); 165 173 } catch (Exception $e) { … … 190 198 ); 191 199 192 if ($current_page !== false) {193 $action_args['page'] = $current_page;194 }195 196 200 // create the action to be handled in X seconds ( default time ) 197 201 $fire_at = strtotime( '+'.$delay.' seconds' ); … … 558 562 */ 559 563 function mailchimp_get_admin_options($default = array()) { 564 if (wp_using_ext_object_cache()) { 565 return \Mailchimp_Woocommerce_DB_Helpers::get_option('mailchimp-woocommerce', $default); 566 } 567 560 568 $options = wp_cache_get('mailchimp-woocommerce-options', 'mailchimp-woocommerce'); 561 569 … … 860 868 function mailchimp_get_coupons_count() { 861 869 $posts = mailchimp_count_posts('shop_coupon'); 862 unset($posts['auto-draft'], $posts['trash']); 870 863 871 $total = 0; 864 872 foreach ($posts as $status => $count) { … … 873 881 function mailchimp_get_product_count() { 874 882 $posts = mailchimp_count_posts('product'); 875 unset($posts['auto-draft'], $posts['trash']); 883 876 884 $total = 0; 877 885 foreach ($posts as $status => $count) { 878 886 $total += $count; 879 887 } 888 880 889 return $total; 881 890 } … … 935 944 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s"; 936 945 $posts = $wpdb->get_results( $wpdb->prepare($query, $type, 'wc-completed')); 937 } else if ($type === 'product') {938 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s AND post_status IN (%s, %s, %s) group BY post_status";939 $posts = $wpdb->get_results( $wpdb->prepare($query, $type, 'private', 'publish', 'draft'));940 946 } else { 941 947 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s"; … … 947 953 $response[$post->post_status] = $post->num_posts; 948 954 } 955 949 956 return $response; 950 957 } … … 1070 1077 $url = $store->getConnectedSiteScriptUrl(); 1071 1078 $fragment = $store->getConnectedSiteScriptFragment(); 1079 1080 // if script data is not available from store, try connected-sites endpoint 1081 if (!$url || !$fragment) { 1082 $connected_site_data = $api->checkConnectedSite($store->getId()); 1083 1084 if ($connected_site_data && isset($connected_site_data['site_script'])) { 1085 $url = isset($connected_site_data['site_script']['url']) ? $connected_site_data['site_script']['url'] : ''; 1086 $fragment = isset($connected_site_data['site_script']['fragment']) ? $connected_site_data['site_script']['fragment'] : ''; 1087 } 1088 } 1072 1089 1073 1090 // if it's not empty we need to set the values -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-api.php
r3273692 r3343001 2537 2537 curl_setopt_array( $curl, $options ); 2538 2538 2539 return $this->processCurlResponse( $curl );2539 return $this->processCurlResponse( $curl, $body ); 2540 2540 } 2541 2541 … … 2565 2565 curl_setopt_array( $curl, $options ); 2566 2566 2567 return $this->processCurlResponse( $curl );2567 return $this->processCurlResponse( $curl, $body ); 2568 2568 } 2569 2569 … … 2611 2611 curl_setopt_array( $curl, $options ); 2612 2612 2613 return $this->processCurlResponse( $curl );2613 return $this->processCurlResponse( $curl, $body ); 2614 2614 } 2615 2615 … … 2692 2692 * @throws MailChimp_WooCommerce_ServerError 2693 2693 */ 2694 protected function processCurlResponse( $curl ) {2694 protected function processCurlResponse( $curl, $request_data = null ) { 2695 2695 $response = curl_exec( $curl ); 2696 2696 2697 2697 $err = curl_error( $curl ); 2698 2698 $info = curl_getinfo( $curl ); 2699 2700 // Capture request details before closing curl 2701 $url = isset($info['url']) ? $info['url'] : 'UNKNOWN'; 2702 $request_headers = isset($info['request_header']) ? explode("\r\n", $info['request_header']) : array(); 2703 2704 // Extract method from curl options 2705 $method = $info['effective_method'] ?? 'UNKNOWN'; 2699 2706 2700 2707 if ($this->auto_doi) { … … 2703 2710 2704 2711 curl_close( $curl ); 2705 2712 2713 // Initialize error info array 2706 2714 if ( $err ) { 2715 $error_info = array( 2716 'type' => 'curl_error', 2717 'message' => $err, 2718 'code' => 500 2719 ); 2720 2721 // Log with enhanced logger 2722 if (class_exists('MailChimp_WooCommerce_Enhanced_Logger')) { 2723 MailChimp_WooCommerce_Enhanced_Logger::log_connection_attempt( 2724 $method, 2725 $url, 2726 $info, 2727 $response, 2728 $error_info, 2729 $request_headers, 2730 $request_data 2731 ); 2732 } 2733 2707 2734 throw new MailChimp_WooCommerce_Error( 'CURL error :: ' . $err, 500 ); 2708 2735 } … … 2715 2742 // let's block these from doing anything below because the API seems to be having trouble. 2716 2743 if ( $http_code <= 99 ) { 2744 $error_info = array( 2745 'type' => 'api_failure', 2746 'message' => 'API is failing - try again.', 2747 'code' => $http_code 2748 ); 2749 2750 // Log with enhanced logger 2751 if (class_exists('MailChimp_WooCommerce_Enhanced_Logger')) { 2752 MailChimp_WooCommerce_Enhanced_Logger::log_connection_attempt( 2753 $method, 2754 $url, 2755 $info, 2756 $response, 2757 $error_info, 2758 $request_headers, 2759 $request_data 2760 ); 2761 } 2762 2717 2763 throw new MailChimp_WooCommerce_RateLimitError( 'API is failing - try again.' ); 2718 2764 } … … 2728 2774 $this->checkForErrors( $data ); 2729 2775 } catch ( Exception $e ) { 2776 // Log error from checkForErrors 2777 $error_info = array( 2778 'type' => 'validation_error', 2779 'message' => $e->getMessage(), 2780 'code' => $e->getCode(), 2781 'response_data' => $data 2782 ); 2783 2784 if (class_exists('MailChimp_WooCommerce_Enhanced_Logger')) { 2785 MailChimp_WooCommerce_Enhanced_Logger::log_connection_attempt( 2786 $method, 2787 $url, 2788 $info, 2789 $response, 2790 $error_info, 2791 $request_headers, 2792 $request_data 2793 ); 2794 } 2795 2730 2796 throw $e; 2731 2797 } 2732 2798 } 2799 2800 // Log successful request if debug logging is enabled 2801 if (mailchimp_environment_variables()->logging === 'debug' && class_exists('MailChimp_WooCommerce_Enhanced_Logger')) { 2802 MailChimp_WooCommerce_Enhanced_Logger::log_connection_attempt( 2803 $method, 2804 $url, 2805 $info, 2806 $response, 2807 array(), // No error 2808 $request_headers, 2809 $request_data 2810 ); 2811 } 2812 2733 2813 return $data; 2734 2814 } … … 2739 2819 if ( $http_code >= 400 && $http_code <= 500 ) { 2740 2820 if ( $http_code == 403 ) { 2821 $error_info = array( 2822 'type' => 'rate_limit', 2823 'message' => 'Rate limit exceeded', 2824 'code' => 403, 2825 'response_data' => $data 2826 ); 2827 2828 // Log with enhanced logger 2829 if (class_exists('MailChimp_WooCommerce_Enhanced_Logger')) { 2830 MailChimp_WooCommerce_Enhanced_Logger::log_connection_attempt( 2831 $method, 2832 $url, 2833 $info, 2834 $response, 2835 $error_info, 2836 $request_headers, 2837 $request_data 2838 ); 2839 } 2840 2741 2841 throw new MailChimp_WooCommerce_RateLimitError(); 2742 2842 } 2743 2843 $error_message = isset( $data['title'] ) ? $data['title'] : ''; 2744 2844 $error_message .= isset( $data['detail'] ) ? $data['detail'] : ''; 2845 2846 $error_info = array( 2847 'type' => 'client_error', 2848 'message' => $error_message, 2849 'code' => $error_status, 2850 'response_data' => $data 2851 ); 2852 2853 // Log with enhanced logger 2854 if (class_exists('MailChimp_WooCommerce_Enhanced_Logger')) { 2855 MailChimp_WooCommerce_Enhanced_Logger::log_connection_attempt( 2856 $method, 2857 $url, 2858 $info, 2859 $response, 2860 $error_info, 2861 $request_headers, 2862 $request_data 2863 ); 2864 } 2865 2745 2866 throw new MailChimp_WooCommerce_Error( $error_message, $error_status ); 2746 2867 } … … 2748 2869 if ( $http_code >= 500 ) { 2749 2870 $error_message = isset( $data['detail'] ) ? $data['detail'] : ''; 2871 2872 $error_info = array( 2873 'type' => 'server_error', 2874 'message' => $error_message, 2875 'code' => $error_status, 2876 'response_data' => $data 2877 ); 2878 2879 // Log with enhanced logger 2880 if (class_exists('MailChimp_WooCommerce_Enhanced_Logger')) { 2881 MailChimp_WooCommerce_Enhanced_Logger::log_connection_attempt( 2882 $method, 2883 $url, 2884 $info, 2885 $response, 2886 $error_info, 2887 $request_headers, 2888 $request_data 2889 ); 2890 } 2891 2750 2892 throw new MailChimp_WooCommerce_ServerError( $error_message, $error_status ); 2751 2893 } 2752 2894 2753 2895 if ( ! is_array( $data ) ) { 2896 $error_info = array( 2897 'type' => 'decode_error', 2898 'message' => 'API response could not be decoded.', 2899 'code' => $http_code, 2900 'raw_response' => $response 2901 ); 2902 2903 // Log with enhanced logger 2904 if (class_exists('MailChimp_WooCommerce_Enhanced_Logger')) { 2905 MailChimp_WooCommerce_Enhanced_Logger::log_connection_attempt( 2906 $method, 2907 $url, 2908 $info, 2909 $response, 2910 $error_info, 2911 $request_headers, 2912 $request_data 2913 ); 2914 } 2915 2754 2916 mailchimp_error( 2755 2917 'api.debug', -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-woocommerce-logs.php
r2806636 r3343001 46 46 $logs = array(); 47 47 48 foreach ( MailChimp_WooCommerce_Log_Viewer::all() as $item ) { 49 try { 50 $date = new DateTime( $item['date'] ); 51 } catch ( Exception $e ) { 52 $date = new DateTime(); 48 // Check if we're viewing connection logs 49 if ( $this->view === base64_encode( 'connection-logs' ) ) { 50 // Get enhanced connection logs 51 if ( class_exists( 'MailChimp_WooCommerce_Enhanced_Logger' ) ) { 52 $connection_logs = MailChimp_WooCommerce_Enhanced_Logger::get_connection_logs( 200 ); 53 54 foreach ( $connection_logs as $log ) { 55 try { 56 $date = new DateTime( $log['timestamp'] ); 57 } catch ( Exception $e ) { 58 $date = new DateTime(); 59 } 60 61 // Format log entry for display 62 $http_code = isset( $log['connection']['http_code'] ) ? $log['connection']['http_code'] : 'N/A'; 63 $error_msg = isset( $log['error']['message'] ) ? $log['error']['message'] : ''; 64 $url_parts = parse_url( $log['url'] ); 65 $path = isset( $url_parts['path'] ) ? $url_parts['path'] : $log['url']; 66 67 // Determine context based on error 68 $context = 'info'; 69 if ( ! empty( $log['error'] ) ) { 70 $context = 'error'; 71 } elseif ( $http_code >= 400 ) { 72 $context = 'error'; 73 } elseif ( $http_code >= 300 ) { 74 $context = 'warning'; 75 } 76 77 // Build text for display 78 $text = sprintf( 79 '[%s %s] HTTP %s - %s%s', 80 $log['method'], 81 $path, 82 $http_code, 83 ! empty( $error_msg ) ? "Error: $error_msg" : 'Success', 84 isset( $log['connection']['total_time'] ) ? sprintf( ' (%.3fs)', $log['connection']['total_time'] ) : '' 85 ); 86 87 // Add diagnostic info if available 88 if ( ! empty( $log['diagnostics']['possible_causes'] ) ) { 89 $text .= ' | Causes: ' . implode( '; ', $log['diagnostics']['possible_causes'] ); 90 } 91 92 $item = array( 93 'context' => $context, 94 'level' => $context, 95 'level_class' => $context === 'error' ? 'error' : ( $context === 'warning' ? 'warning' : 'success' ), 96 'level_img' => $context === 'error' ? 'warning' : 'info', 97 'date' => $date->format( 'D, M j, Y g:i A' ), 98 'datetime' => $date->format( 'Y-m-d H:i:s A' ), 99 'text' => strtolower( $text ), 100 'stack' => json_encode( $log, JSON_PRETTY_PRINT ), 101 ); 102 103 if ( ! empty( $this->search_query ) && ! mailchimp_string_contains( $item['text'], $this->search_query ) ) { 104 continue; 105 } 106 107 $logs[] = $item; 108 } 53 109 } 54 $item['date'] = $date->format( 'D, M j, Y g:i A' ); 55 $item['datetime'] = $date->format( 'Y-m-d H:i:s A' ); 56 $item['text'] = strtolower( str_replace( '[]', ' ', $item['text'] ) ); 57 if ( ! empty( $this->search_query ) && ! mailchimp_string_contains( $item['text'], $this->search_query ) ) { 58 continue; 110 } else { 111 // Regular file logs 112 foreach ( MailChimp_WooCommerce_Log_Viewer::all() as $item ) { 113 try { 114 $date = new DateTime( $item['date'] ); 115 } catch ( Exception $e ) { 116 $date = new DateTime(); 117 } 118 $item['date'] = $date->format( 'D, M j, Y g:i A' ); 119 $item['datetime'] = $date->format( 'Y-m-d H:i:s A' ); 120 $item['text'] = strtolower( str_replace( '[]', ' ', $item['text'] ) ); 121 if ( ! empty( $this->search_query ) && ! mailchimp_string_contains( $item['text'], $this->search_query ) ) { 122 continue; 123 } 124 $logs[] = $item; 59 125 } 60 $logs[] = $item;61 126 } 62 127 … … 66 131 67 132 $files = array(); 133 134 // Add connection logs as a special "file" 135 $files[] = array( 136 'value' => base64_encode( 'connection-logs' ), 137 'filename' => 'connection-logs', 138 'label' => 'Connection Logs (Enhanced)', 139 ); 68 140 69 141 foreach ( MailChimp_WooCommerce_Log_Viewer::getFiles( true ) as $key => $file ) { … … 87 159 'search' => $this->search_query, 88 160 'dir' => MailChimp_WooCommerce_Log_Viewer::getLogDirectory(), 89 'current' => base64_encode( MailChimp_WooCommerce_Log_Viewer::getFileName() ),161 'current' => $this->view ? $this->view : base64_encode( MailChimp_WooCommerce_Log_Viewer::getFileName() ), 90 162 'files' => $files, 91 163 'logs' => $logs, -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-woocommerce-transform-products.php
r3253510 r3343001 70 70 71 71 /** 72 * @param $woo72 * @param WC_Product $woo 73 73 * @param null $fallback_title 74 74 * … … 182 182 } 183 183 184 /** 185 * -- if a product is not purchasable, it's always hidden -- 186 * 1. category is hidden, status is draft or pending = HIDDEN 187 * 2. category is hidden, status is not draft or pending = HIDDEN 188 * 3. category is NOT hidden, status is draft or pending = HIDDEN 189 * 4. category is NOT hidden, status is NOT draft or pending = VISIBLE 190 */ 191 192 $hidden_catalog = $woo->get_catalog_visibility() === 'hidden'; 193 $visible = $woo->is_visible(); 194 $is_purchasable = $woo->is_purchasable(); 195 $status = $woo->get_status(); 196 $is_private = $status === 'private'; 197 $is_draft_or_pending = in_array($status, ['draft', 'pending']); 198 199 if ($is_private || !$is_purchasable) { 200 $visible = false; 201 } else if ( $hidden_catalog && $is_draft_or_pending ) { 202 $visible = false; 203 } else if ( ! $hidden_catalog && $is_draft_or_pending) { 204 $visible = false; 205 } else if ( ! $hidden_catalog && !$is_draft_or_pending ) { 206 $visible = true; 207 } 208 184 209 // only set these properties if the product is currently visible or purchasable. 185 if ( $ woo->is_purchasable() && $woo->is_visible()) {210 if ( $is_purchasable && $visible ) { 186 211 if ( $woo->is_in_stock() ) { 187 212 $variant->setInventoryQuantity( ( $woo->managing_stock() ? $woo->get_stock_quantity() : 1000000 ) ); … … 210 235 211 236 $variant->setTitle( implode( ' :: ', $title ) ); 212 $variant->setVisibility( ( $woo->variation_is_visible() ? 'visible' : 'hidden' ) ); 237 $variation_visible = $woo->variation_is_visible() && $is_purchasable; 238 $variant->setVisibility( ( $visible && $variation_visible ? 'visible' : 'hidden' ) ); 213 239 } else { 214 $variant->setVisibility( ( $ woo->is_visible()? 'visible' : 'hidden' ) );240 $variant->setVisibility( ( $visible ? 'visible' : 'hidden' ) ); 215 241 $variant->setTitle( $woo->get_title() ); 216 242 } … … 236 262 'post_type' => array_merge( array_keys( wc_get_product_types() ), array( 'product' ) ), 237 263 'posts_per_page' => $limit, 238 'post_status' => array( 'p rivate', 'publish', 'draft' ),264 'post_status' => array( 'publish' ), 239 265 'offset' => $offset, 240 266 'orderby' => 'ID', … … 280 306 array( 281 307 'post_type' => 'product_variation', 282 'post_status' => array( 'p rivate', 'publish', 'draft' ),308 'post_status' => array( 'publish' ), 283 309 'numberposts' => -1, 284 310 'post_parent' => $id, -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce-hpos.php
r3141736 r3343001 41 41 * @param $post_id 42 42 * 43 * @return mixed 43 * @return mixed|WC_Product 44 44 */ 45 45 public static function get_product( $post_id ) -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce-service.php
r3273692 r3343001 379 379 } 380 380 381 // 'draft', 'pending'381 /// old filter array('trash', 'auto-draft', 'draft', 'pending', 'private') 382 382 if (in_array($post_after->post_status, array('trash', 'auto-draft'))) { 383 383 mailchimp_log('product.update.blocked', "product {$post_ID} was blocked because status is {$post_after->post_status}"); … … 469 469 } 470 470 471 if (!in_array($product->get_status(), array('trash', 'auto-draft', 'draft', 'pending' ))) {471 if (!in_array($product->get_status(), array('trash', 'auto-draft', 'draft', 'pending', 'private'))) { 472 472 if ($product instanceof WC_Product) { 473 473 mailchimp_debug('queue', "handling meta update for meta [{$meta_key}] on product {$object_id}"); … … 524 524 525 525 // If the product is of a certain status, process it. ( old values included 'draft', 'pending') 526 if (!in_array($post->post_status, array('trash', 'auto-draft' ))) {526 if (!in_array($post->post_status, array('trash', 'auto-draft', 'draft', 'pending', 'private'))) { 527 527 mailchimp_handle_or_queue(new MailChimp_WooCommerce_Single_Product($post_ID), 5); 528 528 } … … 704 704 705 705 // don't handle any of these statuses because they're not ready for the show 706 if (in_array($post->post_status, array('trash', 'auto-draft', 'draft', 'pending' ))) {706 if (in_array($post->post_status, array('trash', 'auto-draft', 'draft', 'pending', 'private'))) { 707 707 return; 708 708 } … … 1343 1343 // get job row from db 1344 1344 global $wpdb; 1345 $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mailchimp_jobs WHERE obj_id = %s", $obj_id ); 1345 $current_action = current_action(); 1346 $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mailchimp_jobs WHERE obj_id = %s AND job LIKE %s", array($obj_id, "%{$current_action}%") ); 1346 1347 $job_row = $wpdb->get_row( $sql ); 1347 1348 … … 1356 1357 $job = unserialize($job_row->job); 1357 1358 1358 $job_id = $job_row->id;1359 $job_id = $job_row->id; 1359 1360 1360 1361 // process job -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce.php
r3273692 r3343001 275 275 $this->loader->add_action( 'wp_ajax_mailchimp_woocommerce_create_account_check_username', $plugin_admin, 'mailchimp_woocommerce_ajax_create_account_check_username' ); 276 276 $this->loader->add_action( 'wp_ajax_mailchimp_woocommerce_create_account_signup', $plugin_admin, 'mailchimp_woocommerce_ajax_create_account_signup' ); 277 $this->loader->add_action( 'wp_ajax_mailchimp_woocommerce_switch_account', $plugin_admin, 'connect_account_flow_switch_account' ); 277 278 $this->loader->add_action( 'wp_ajax_mailchimp_woocommerce_check_login_session', $plugin_admin, 'mailchimp_woocommerce_ajax_check_login_session' ); 278 279 $this->loader->add_action( 'wp_ajax_mailchimp_woocommerce_support_form', $plugin_admin, 'mailchimp_woocommerce_ajax_support_form' ); -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-full-sync-manager.php
r3253510 r3343001 124 124 // if we have a transient telling us to stop this sync, just break out here instead of 125 125 // respawn and try to delete. 126 126 127 if (mailchimp_get_transient('stop_sync', false)) { 127 128 return; -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-single-product.php
r3209992 r3343001 157 157 } 158 158 159 if (in_array($product_post->get_status(), array('trash', 'auto-draft'))) { 160 mailchimp_log('product', "skipped products sync #{$this->id} because current status is {$product_post->get_status()}"); 161 return false; 162 } 163 159 164 // either updating or creating the product 160 165 $this->api()->updateStoreProduct($this->store_id, $product, false); -
mailchimp-for-woocommerce/trunk/mailchimp-woocommerce.php
r3273707 r3343001 17 17 * Plugin URI: https://mailchimp.com/connect-your-store/ 18 18 * Description: Connects WooCommerce to Mailchimp to sync your store data, send targeted campaigns to your customers, and sell more stuff. 19 * Version: 5. 419 * Version: 5.5 20 20 * Author: Mailchimp 21 21 * Author URI: https://mailchimp.com … … 28 28 * Tested up to: 6.8 29 29 * WC requires at least: 8.2 30 * WC tested up to: 9.830 * WC tested up to: 10 31 31 */ 32 32
Note: See TracChangeset
for help on using the changeset viewer.