Changeset 1709699
- Timestamp:
- 08/07/2017 05:04:24 PM (9 years ago)
- Location:
- mailchimp-for-woocommerce
- Files:
-
- 99 added
- 19 edited
-
tags/2.0.1 (added)
-
tags/2.0.1/LICENSE.txt (added)
-
tags/2.0.1/README.md (added)
-
tags/2.0.1/README.txt (added)
-
tags/2.0.1/admin (added)
-
tags/2.0.1/admin/class-mailchimp-woocommerce-admin.php (added)
-
tags/2.0.1/admin/css (added)
-
tags/2.0.1/admin/css/mailchimp-woocommerce-admin.css (added)
-
tags/2.0.1/admin/index.php (added)
-
tags/2.0.1/admin/js (added)
-
tags/2.0.1/admin/js/mailchimp-woocommerce-admin.js (added)
-
tags/2.0.1/admin/partials (added)
-
tags/2.0.1/admin/partials/mailchimp-woocommerce-admin-tabs.php (added)
-
tags/2.0.1/admin/partials/tabs (added)
-
tags/2.0.1/admin/partials/tabs/api_key.php (added)
-
tags/2.0.1/admin/partials/tabs/campaign_defaults.php (added)
-
tags/2.0.1/admin/partials/tabs/elements (added)
-
tags/2.0.1/admin/partials/tabs/elements/enable_debugging.php (added)
-
tags/2.0.1/admin/partials/tabs/errors (added)
-
tags/2.0.1/admin/partials/tabs/errors/missing_api_key.php (added)
-
tags/2.0.1/admin/partials/tabs/errors/missing_campaign_defaults.php (added)
-
tags/2.0.1/admin/partials/tabs/errors/missing_list.php (added)
-
tags/2.0.1/admin/partials/tabs/errors/missing_store.php (added)
-
tags/2.0.1/admin/partials/tabs/errors/not_ready_for_sync.php (added)
-
tags/2.0.1/admin/partials/tabs/newsletter_settings.php (added)
-
tags/2.0.1/admin/partials/tabs/notices.php (added)
-
tags/2.0.1/admin/partials/tabs/store_info.php (added)
-
tags/2.0.1/admin/partials/tabs/store_sync.php (added)
-
tags/2.0.1/admin/partials/tabs/success (added)
-
tags/2.0.1/admin/partials/tabs/success/re-sync-started.php (added)
-
tags/2.0.1/changelog.md (added)
-
tags/2.0.1/env.php (added)
-
tags/2.0.1/includes (added)
-
tags/2.0.1/includes/api (added)
-
tags/2.0.1/includes/api/assets (added)
-
tags/2.0.1/includes/api/assets/class-mailchimp-address.php (added)
-
tags/2.0.1/includes/api/assets/class-mailchimp-cart.php (added)
-
tags/2.0.1/includes/api/assets/class-mailchimp-customer.php (added)
-
tags/2.0.1/includes/api/assets/class-mailchimp-line-item.php (added)
-
tags/2.0.1/includes/api/assets/class-mailchimp-order.php (added)
-
tags/2.0.1/includes/api/assets/class-mailchimp-product-variation.php (added)
-
tags/2.0.1/includes/api/assets/class-mailchimp-product.php (added)
-
tags/2.0.1/includes/api/assets/class-mailchimp-store.php (added)
-
tags/2.0.1/includes/api/class-mailchimp-api.php (added)
-
tags/2.0.1/includes/api/class-mailchimp-woocommerce-api.php (added)
-
tags/2.0.1/includes/api/class-mailchimp-woocommerce-create-list-submission.php (added)
-
tags/2.0.1/includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php (added)
-
tags/2.0.1/includes/api/class-mailchimp-woocommerce-transform-orders.php (added)
-
tags/2.0.1/includes/api/class-mailchimp-woocommerce-transform-products.php (added)
-
tags/2.0.1/includes/api/errors (added)
-
tags/2.0.1/includes/api/errors/class-mailchimp-error.php (added)
-
tags/2.0.1/includes/api/errors/class-mailchimp-server-error.php (added)
-
tags/2.0.1/includes/api/helpers (added)
-
tags/2.0.1/includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php (added)
-
tags/2.0.1/includes/api/helpers/class-mailchimp-woocommerce-api-locales.php (added)
-
tags/2.0.1/includes/class-mailchimp-woocommerce-activator.php (added)
-
tags/2.0.1/includes/class-mailchimp-woocommerce-deactivator.php (added)
-
tags/2.0.1/includes/class-mailchimp-woocommerce-i18n.php (added)
-
tags/2.0.1/includes/class-mailchimp-woocommerce-loader.php (added)
-
tags/2.0.1/includes/class-mailchimp-woocommerce-newsletter.php (added)
-
tags/2.0.1/includes/class-mailchimp-woocommerce-options.php (added)
-
tags/2.0.1/includes/class-mailchimp-woocommerce-service.php (added)
-
tags/2.0.1/includes/class-mailchimp-woocommerce.php (added)
-
tags/2.0.1/includes/index.php (added)
-
tags/2.0.1/includes/processes (added)
-
tags/2.0.1/includes/processes/class-mailchimp-woocommerce-abstract-sync.php (added)
-
tags/2.0.1/includes/processes/class-mailchimp-woocommerce-cart-update.php (added)
-
tags/2.0.1/includes/processes/class-mailchimp-woocommerce-process-orders.php (added)
-
tags/2.0.1/includes/processes/class-mailchimp-woocommerce-process-products.php (added)
-
tags/2.0.1/includes/processes/class-mailchimp-woocommerce-single-order.php (added)
-
tags/2.0.1/includes/processes/class-mailchimp-woocommerce-single-product.php (added)
-
tags/2.0.1/includes/processes/class-mailchimp-woocommerce-user-submit.php (added)
-
tags/2.0.1/includes/vendor (added)
-
tags/2.0.1/includes/vendor/queue (added)
-
tags/2.0.1/includes/vendor/queue.php (added)
-
tags/2.0.1/includes/vendor/queue/classes (added)
-
tags/2.0.1/includes/vendor/queue/classes/cli (added)
-
tags/2.0.1/includes/vendor/queue/classes/cli/queue-command.php (added)
-
tags/2.0.1/includes/vendor/queue/classes/worker (added)
-
tags/2.0.1/includes/vendor/queue/classes/worker/wp-http-worker.php (added)
-
tags/2.0.1/includes/vendor/queue/classes/worker/wp-worker.php (added)
-
tags/2.0.1/includes/vendor/queue/classes/wp-job.php (added)
-
tags/2.0.1/includes/vendor/queue/classes/wp-queue.php (added)
-
tags/2.0.1/index.php (added)
-
tags/2.0.1/languages (added)
-
tags/2.0.1/languages/mailchimp-woocommerce.pot (added)
-
tags/2.0.1/mailchimp-woocommerce.php (added)
-
tags/2.0.1/public (added)
-
tags/2.0.1/public/class-mailchimp-woocommerce-public.php (added)
-
tags/2.0.1/public/css (added)
-
tags/2.0.1/public/css/mailchimp-woocommerce-public.css (added)
-
tags/2.0.1/public/index.php (added)
-
tags/2.0.1/public/js (added)
-
tags/2.0.1/public/js/mailchimp-woocommerce-public.js (added)
-
tags/2.0.1/public/js/mailchimp-woocommerce-public.min.js (added)
-
tags/2.0.1/public/partials (added)
-
tags/2.0.1/public/partials/mailchimp-woocommerce-public-display.php (added)
-
tags/2.0.1/uninstall.php (added)
-
trunk/README.md (modified) (1 diff)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/class-mailchimp-woocommerce-admin.php (modified) (8 diffs)
-
trunk/admin/partials/mailchimp-woocommerce-admin-tabs.php (modified) (3 diffs)
-
trunk/admin/partials/tabs/store_info.php (modified) (8 diffs)
-
trunk/changelog.md (modified) (1 diff)
-
trunk/env.php (added)
-
trunk/includes/api/assets/class-mailchimp-order.php (modified) (4 diffs)
-
trunk/includes/api/assets/class-mailchimp-store.php (modified) (3 diffs)
-
trunk/includes/api/class-mailchimp-api.php (modified) (3 diffs)
-
trunk/includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php (modified) (4 diffs)
-
trunk/includes/api/class-mailchimp-woocommerce-transform-orders.php (modified) (8 diffs)
-
trunk/includes/api/errors/class-mailchimp-server-error.php (modified) (1 diff)
-
trunk/includes/class-mailchimp-woocommerce-activator.php (modified) (1 diff)
-
trunk/includes/class-mailchimp-woocommerce-newsletter.php (modified) (1 diff)
-
trunk/includes/processes/class-mailchimp-woocommerce-process-orders.php (modified) (1 diff)
-
trunk/includes/processes/class-mailchimp-woocommerce-process-products.php (modified) (1 diff)
-
trunk/includes/processes/class-mailchimp-woocommerce-single-product.php (modified) (1 diff)
-
trunk/mailchimp-woocommerce.php (modified) (6 diffs)
-
trunk/public/class-mailchimp-woocommerce-public.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mailchimp-for-woocommerce/trunk/README.md
r1522130 r1709699 38 38 2) In the left navigation panel, click **Plugins**, and choose **Add New**. 39 39 40 ![Add new] (https://cloud.githubusercontent.com/assets/6547700/18677991/a7622bcc-7f28-11e6-8e8c-9bbdfa9861c7.png)40  41 41 42 42 3) Click **Upload Plugin**. 43 43 44 ![Upload] (https://cloud.githubusercontent.com/assets/6547700/18677997/a76dab82-7f28-11e6-98e4-4309739cd840.png)44  45 45 46 46 4) Click **Choose File** to select the ZIP file for the plugin, then click **Install Now**. -
mailchimp-for-woocommerce/trunk/README.txt
r1639952 r1709699 4 4 Donate link: https://mailchimp.com 5 5 Requires at least: 4.3 6 Tested up to: 4. 6.16 Tested up to: 4.8 7 7 Stable tag: 4.6.1 8 8 License: GPLv2 or later … … 50 50 51 51 == Changelog == 52 = 2.0.1 = 53 * Added support for "Connected Site" scripts. 54 * Made physical address a required field for store setup. 55 * Fixed order, cart timestamps to begin using UTC. 56 52 57 = 2.0 = 53 58 * Support WooComerce 3.0 -
mailchimp-for-woocommerce/trunk/admin/class-mailchimp-woocommerce-admin.php
r1639952 r1709699 282 282 $this->setData('validation.api.ping', $valid); 283 283 284 $data['active_tab'] = $valid ? 'store_info' : 'api_key'; 285 284 286 if ($valid && isset($profile) && is_array($profile) && array_key_exists('account_id', $profile)) { 285 287 $data['mailchimp_account_info_id'] = $profile['account_id']; … … 300 302 protected function validatePostStoreInfo($input) 301 303 { 302 $data = array( 303 304 // store basics 305 'store_name' => trim((isset($input['store_name']) ? $input['store_name'] : get_option('blogname'))), 306 'store_street' => isset($input['store_street']) ? $input['store_street'] : false, 307 'store_city' => isset($input['store_city']) ? $input['store_city'] : false, 308 'store_state' => isset($input['store_state']) ? $input['store_state'] : false, 309 'store_postal_code' => isset($input['store_postal_code']) ? $input['store_postal_code'] : false, 310 'store_country' => isset($input['store_country']) ? $input['store_country'] : false, 311 'store_phone' => isset($input['store_phone']) ? $input['store_phone'] : false, 312 313 // locale info 314 'store_locale' => isset($input['store_locale']) ? $input['store_locale'] : false, 315 'store_timezone' => isset($input['store_timezone']) ? $input['store_timezone'] : false, 316 'store_currency_code' => isset($input['store_currency_code']) ? $input['store_currency_code'] : false, 317 318 'admin_email' => isset($input['admin_email']) && is_email($input['admin_email']) ? $input['admin_email'] : $this->getOption('admin_email', false), 319 ); 304 $data = $this->compileStoreInfoData($input); 320 305 321 306 if (!$this->hasValidStoreInfo($data)) { 322 307 323 if (empty($data['admin_email']) || empty($data['store_city']) || empty($data['store_state']) || empty($data['store_postal_code']) || empty($data['store_country']) || empty($data['store_street'])) {324 add_settings_error('mailchimp_store_settings', '', 'As part of the MailChimp Terms of Use, we require a contact email and a physical mailing address.');325 }326 327 if (empty($data['store_phone']) || strlen($data['store_phone']) <= 6) {328 add_settings_error('mailchimp_store_settings', '', 'As part of the MailChimp Terms of Use, we require a valid phone number for your store.');329 }330 331 if (empty($data['store_name'])) {332 add_settings_error('mailchimp_store_settings', '', 'MailChimp for WooCommerce requires a Store Name to connect your store.');333 }308 if ($this->hasInvalidStoreAddress($data)) { 309 $this->addInvalidAddressAlert(); 310 } 311 312 if ($this->hasInvalidStorePhone($data)) { 313 $this->addInvalidPhoneAlert(); 314 } 315 316 if ($this->hasInvalidStoreName($data)) { 317 $this->addInvalidStoreNameAlert(); 318 } 334 319 335 320 $this->setData('validation.store_info', false); 321 322 $data['active_tab'] = 'store_info'; 323 336 324 return array(); 337 325 } 338 326 339 327 $this->setData('validation.store_info', true); 328 329 $data['active_tab'] = 'campaign_defaults'; 340 330 341 331 if ($this->hasValidMailChimpList()) { … … 345 335 return $data; 346 336 } 337 338 /** 339 * @param $input 340 * @return array 341 */ 342 protected function compileStoreInfoData($input) 343 { 344 return array( 345 // store basics 346 'store_name' => trim((isset($input['store_name']) ? $input['store_name'] : get_option('blogname'))), 347 'store_street' => isset($input['store_street']) ? $input['store_street'] : false, 348 'store_city' => isset($input['store_city']) ? $input['store_city'] : false, 349 'store_state' => isset($input['store_state']) ? $input['store_state'] : false, 350 'store_postal_code' => isset($input['store_postal_code']) ? $input['store_postal_code'] : false, 351 'store_country' => isset($input['store_country']) ? $input['store_country'] : false, 352 'store_phone' => isset($input['store_phone']) ? $input['store_phone'] : false, 353 // locale info 354 'store_locale' => isset($input['store_locale']) ? $input['store_locale'] : false, 355 'store_timezone' => isset($input['store_timezone']) ? $input['store_timezone'] : false, 356 'store_currency_code' => isset($input['store_currency_code']) ? $input['store_currency_code'] : false, 357 'admin_email' => isset($input['admin_email']) && is_email($input['admin_email']) ? $input['admin_email'] : $this->getOption('admin_email', false), 358 ); 359 } 360 361 /** 362 * @param array $data 363 * @return array|bool 364 */ 365 protected function hasInvalidStoreAddress($data) 366 { 367 $address_keys = array( 368 'admin_email', 369 'store_city', 370 'store_state', 371 'store_postal_code', 372 'store_country', 373 'store_street' 374 ); 375 376 $invalid = array(); 377 foreach ($address_keys as $address_key) { 378 if (empty($data[$address_key])) { 379 $invalid[] = $address_key; 380 } 381 } 382 return empty($invalid) ? false : $invalid; 383 } 384 385 /** 386 * @param $data 387 * @return bool 388 */ 389 protected function hasInvalidStorePhone($data) 390 { 391 if (empty($data['store_phone']) || strlen($data['store_phone']) <= 6) { 392 return true; 393 } 394 395 return false; 396 } 397 398 /** 399 * @param $data 400 * @return bool 401 */ 402 protected function hasInvalidStoreName($data) 403 { 404 if (empty($data['store_name'])) { 405 return true; 406 } 407 return false; 408 } 409 410 /** 411 * 412 */ 413 protected function addInvalidAddressAlert() 414 { 415 add_settings_error('mailchimp_store_settings', '', 'As part of the MailChimp Terms of Use, we require a contact email and a physical mailing address.'); 416 } 417 418 /** 419 * 420 */ 421 protected function addInvalidPhoneAlert() 422 { 423 add_settings_error('mailchimp_store_settings', '', 'As part of the MailChimp Terms of Use, we require a valid phone number for your store.'); 424 } 425 426 /** 427 * 428 */ 429 protected function addInvalidStoreNameAlert() 430 { 431 add_settings_error('mailchimp_store_settings', '', 'MailChimp for WooCommerce requires a Store Name to connect your store.'); 432 } 347 433 348 434 /** … … 366 452 if (!$this->hasValidCampaignDefaults($data)) { 367 453 $this->setData('validation.campaign_defaults', false); 368 return array(); 454 455 return array('active_tab' => 'campaign_defaults'); 369 456 } 370 457 371 458 $this->setData('validation.campaign_defaults', true); 459 460 $data['active_tab'] = 'newsletter_settings'; 372 461 373 462 return $data; … … 395 484 'mailchimp_list' => isset($input['mailchimp_list']) ? $input['mailchimp_list'] : $this->getOption('mailchimp_list', ''), 396 485 'newsletter_label' => isset($input['newsletter_label']) ? $input['newsletter_label'] : $this->getOption('newsletter_label', 'Subscribe to our newsletter'), 397 'mailchimp_auto_subscribe' => isset($input['mailchimp_auto_subscribe']) ? $input['mailchimp_auto_subscribe'] : $this->getOption('mailchimp_auto_subscribe', '0'),486 'mailchimp_auto_subscribe' => isset($input['mailchimp_auto_subscribe']) ? (bool) $input['mailchimp_auto_subscribe'] : $this->getOption('mailchimp_auto_subscribe', '0'), 398 487 'mailchimp_checkbox_defaults' => $checkbox, 399 488 'mailchimp_checkbox_action' => isset($input['mailchimp_checkbox_action']) ? $input['mailchimp_checkbox_action'] : $this->getOption('mailchimp_checkbox_action', 'woocommerce_after_checkout_billing_form'), … … 406 495 // as long as we have a list set, and it's currently in MC as a valid list, let's sync the store. 407 496 if (!empty($data['mailchimp_list']) && $this->api()->hasList($data['mailchimp_list'])) { 497 498 $this->setData('validation.newsletter_settings', true); 408 499 409 500 // sync the store with MC … … 415 506 $this->showSyncStartedMessage(); 416 507 } 417 } 418 419 return $data; 508 509 $data['active_tab'] = 'sync'; 510 511 return $data; 512 } 513 514 $this->setData('validation.newsletter_settings', false); 515 516 $data['active_tab'] = 'newsletter_settings'; 517 518 return $data; 420 519 } 421 520 … … 692 791 $this->setData($time_key, time()); 693 792 793 // on a new store push, we need to make sure we save the site script into a local variable. 794 if ($new) { 795 mailchimp_update_connected_site_script(); 796 } 797 694 798 return true; 695 799 -
mailchimp-for-woocommerce/trunk/admin/partials/mailchimp-woocommerce-admin-tabs.php
r1639952 r1709699 1 1 <?php 2 2 $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'api_key'; 3 $is_mailchimp_post = isset($_POST['mailchimp_woocommerce_settings_hidden']) && $_POST['mailchimp_woocommerce_settings_hidden'] === 'Y'; 3 4 4 5 $handler = MailChimp_Woocommerce_Admin::connect(); … … 7 8 $options = get_option($this->plugin_name, array()); 8 9 10 if (!isset($_GET['tab']) && isset($options['active_tab'])) { 11 $active_tab = $options['active_tab']; 12 } 13 9 14 $show_sync_tab = isset($_GET['resync']) ? $_GET['resync'] === '1' : false;; 10 15 $show_campaign_defaults = true; … … 12 17 $allow_new_list = true; 13 18 14 $clicked_sync_button = isset($_POST['mailchimp_woocommerce_settings_hidden'])&& $active_tab == 'sync';19 $clicked_sync_button = $is_mailchimp_post&& $active_tab == 'sync'; 15 20 16 21 if (isset($options['mailchimp_api_key']) && $handler->hasValidApiKey()) { -
mailchimp-for-woocommerce/trunk/admin/partials/tabs/store_info.php
r1557758 r1709699 19 19 </legend> 20 20 <label for="<?php echo $this->plugin_name; ?>-store-name-label"> 21 <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-name-label" name="<?php echo $this->plugin_name; ?>[store_name]" value="<?php echo isset($options['store_name']) ? $options['store_name'] : get_option('blogname') ?>" /> 22 <span><?php esc_attr_e('Name', $this->plugin_name); ?></span> 21 <input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-name-label" name="<?php echo $this->plugin_name; ?>[store_name]" value="<?php echo isset($options['store_name']) ? $options['store_name'] : get_option('blogname') ?>" /> 22 <span> 23 <?php 24 if (!empty($options['store_name']) ) { 25 esc_attr_e('Name', $this->plugin_name); 26 } else { 27 esc_attr_e('Name', $this->plugin_name); echo '<span style="color:red;">*</span>'; 28 } 29 ?> 30 </span> 23 31 </label> 24 32 </fieldset> … … 29 37 </legend> 30 38 <label for="<?php echo $this->plugin_name; ?>-admin-email-label"> 31 <input style="width: 30%;" type="email" id="<?php echo $this->plugin_name; ?>-admin-email-label" name="<?php echo $this->plugin_name; ?>[admin_email]" value="<?php echo isset($options['admin_email']) ? $options['admin_email'] : get_option('admin_email') ?>" /> 32 <span><?php esc_attr_e('Email', $this->plugin_name); ?></span> 39 <input required style="width: 30%;" type="email" id="<?php echo $this->plugin_name; ?>-admin-email-label" name="<?php echo $this->plugin_name; ?>[admin_email]" value="<?php echo isset($options['admin_email']) ? $options['admin_email'] : get_option('admin_email') ?>" /> 40 <span> 41 <?php 42 if (!empty($options['admin_email']) ) { 43 esc_attr_e('Email', $this->plugin_name); 44 } else { 45 esc_attr_e('Email', $this->plugin_name); echo '<span style="color:red;">*</span>'; 46 } 47 ?> 48 </span> 33 49 </label> 34 50 </fieldset> … … 39 55 </legend> 40 56 <label for="<?php echo $this->plugin_name; ?>-store-address-label"> 41 <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-address-label" name="<?php echo $this->plugin_name; ?>[store_street]" value="<?php echo isset($options['store_street']) ? $options['store_street'] : '' ?>" /> 42 <span><?php esc_attr_e('Street address', $this->plugin_name); ?></span> 57 <input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-address-label" name="<?php echo $this->plugin_name; ?>[store_street]" value="<?php echo isset($options['store_street']) ? $options['store_street'] : '' ?>" /> 58 <span> 59 <?php 60 if (!empty($options['store_street']) ) { 61 esc_attr_e('Street address', $this->plugin_name); 62 } else { 63 esc_attr_e('Street address', $this->plugin_name); echo '<span style="color:red;">*</span>'; 64 } 65 ?> 66 </span> 43 67 </label> 44 68 </fieldset> … … 49 73 </legend> 50 74 <label for="<?php echo $this->plugin_name; ?>-store-city-label"> 51 <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-city-label" name="<?php echo $this->plugin_name; ?>[store_city]" value="<?php echo isset($options['store_city']) ? $options['store_city'] : '' ?>" /> 52 <span><?php esc_attr_e('City', $this->plugin_name); ?></span> 75 <input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-city-label" name="<?php echo $this->plugin_name; ?>[store_city]" value="<?php echo isset($options['store_city']) ? $options['store_city'] : '' ?>" /> 76 <span> 77 <?php 78 if (!empty($options['store_city']) ) { 79 esc_attr_e('City', $this->plugin_name); 80 } else { 81 esc_attr_e('City', $this->plugin_name); echo '<span style="color:red;">*</span>'; 82 } 83 ?> 84 </span> 53 85 </label> 54 86 </fieldset> … … 59 91 </legend> 60 92 <label for="<?php echo $this->plugin_name; ?>-store-state-label"> 61 <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-state-label" name="<?php echo $this->plugin_name; ?>[store_state]" value="<?php echo isset($options['store_state']) ? $options['store_state'] : '' ?>" /> 62 <span><?php esc_attr_e('State', $this->plugin_name); ?></span> 93 <input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-state-label" name="<?php echo $this->plugin_name; ?>[store_state]" value="<?php echo isset($options['store_state']) ? $options['store_state'] : '' ?>" /> 94 <span> 95 <?php 96 if (!empty($options['store_state']) ) { 97 esc_attr_e('State', $this->plugin_name); 98 } else { 99 esc_attr_e('State', $this->plugin_name); echo '<span style="color:red;">*</span>'; 100 } 101 ?> 102 </span> 63 103 </label> 64 104 </fieldset> … … 69 109 </legend> 70 110 <label for="<?php echo $this->plugin_name; ?>-store-state-label"> 71 <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-postal-code-label" name="<?php echo $this->plugin_name; ?>[store_postal_code]" value="<?php echo isset($options['store_postal_code']) ? $options['store_postal_code'] : '' ?>" /> 72 <span><?php esc_attr_e('Postal Code', $this->plugin_name); ?></span> 111 <input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-postal-code-label" name="<?php echo $this->plugin_name; ?>[store_postal_code]" value="<?php echo isset($options['store_postal_code']) ? $options['store_postal_code'] : '' ?>" /> 112 <span> 113 <?php 114 if (!empty($options['store_postal_code']) ) { 115 esc_attr_e('Postal Code', $this->plugin_name); 116 } else { 117 esc_attr_e('Postal Code', $this->plugin_name); echo '<span style="color:red;">*</span>'; 118 } 119 ?> 120 </span> 73 121 </label> 74 122 </fieldset> … … 79 127 </legend> 80 128 <label for="<?php echo $this->plugin_name; ?>-store-country-label"> 81 <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-country-label" name="<?php echo $this->plugin_name; ?>[store_country]" value="<?php echo isset($options['store_country']) ? $options['store_country'] : 'US' ?>" /> 82 <span><?php esc_attr_e('Country', $this->plugin_name); ?></span> 129 <input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-country-label" name="<?php echo $this->plugin_name; ?>[store_country]" value="<?php echo isset($options['store_country']) ? $options['store_country'] : 'US' ?>" /> 130 <span> 131 <?php 132 if (!empty($options['store_country'])) { 133 esc_attr_e('Country', $this->plugin_name); 134 } else { 135 esc_attr_e('Country', $this->plugin_name); echo '<span style="color:red;">*</span>'; 136 } 137 ?> 138 </span> 83 139 </label> 84 140 </fieldset> … … 89 145 </legend> 90 146 <label for="<?php echo $this->plugin_name; ?>-store-phone-label"> 91 <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-phone-label" name="<?php echo $this->plugin_name; ?>[store_phone]" value="<?php echo isset($options['store_phone']) ? $options['store_phone'] : '' ?>" /> 92 <span><?php esc_attr_e('Phone Number', $this->plugin_name); ?></span> 147 <input required style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-store-phone-label" name="<?php echo $this->plugin_name; ?>[store_phone]" value="<?php echo isset($options['store_phone']) ? $options['store_phone'] : '' ?>" /> 148 <span> 149 <?php 150 if (!empty($options['store_phone']) ) { 151 esc_attr_e('Phone Number', $this->plugin_name); 152 } else { 153 esc_attr_e('Phone Number', $this->plugin_name); echo '<span style="color:red;">*</span>'; 154 } 155 ?> 156 </span> 93 157 </label> 94 158 </fieldset> -
mailchimp-for-woocommerce/trunk/changelog.md
r1639952 r1709699 1 ** 2.0.1 ** 2 3 ##### New Features: ##### 4 * MC.js support added. 5 * Added pop-up forms to the site details page with a warning to upgrade to 2.0.1 before using them. 6 7 ##### Fixes: ##### 8 * Adding physical address as a required field for store setup, since this is also a field required by MailChimp. 9 * Order/carts timestamps now pass over as UTC. 10 * Improved handling of Order Notification and sending Order Invoice and Order Confirmation simultaneously when order is moved to “Processing” in Woocommerce. 11 * Tabs paginating on store set up, moving the user through each step automatically. 12 1 13 ** 2.0 ** 2 14 * Support WooComerce 3.0 -
mailchimp-for-woocommerce/trunk/includes/api/assets/class-mailchimp-order.php
r1604825 r1709699 29 29 protected $billing_address = null; 30 30 protected $lines = array(); 31 protected $confirm_and_paid = false; 31 32 32 33 /** … … 361 362 362 363 /** 364 * @param $bool 365 * @param $bool 366 * @return $this 367 */ 368 public function confirmAndPay($bool) 369 { 370 $this->confirm_and_paid = (bool) $bool; 371 372 return $this; 373 } 374 375 /** 376 * @return bool 377 */ 378 public function shouldConfirmAndPay() 379 { 380 return $this->confirm_and_paid; 381 } 382 383 /** 363 384 * @param MailChimp_WooCommerce_Address $address 364 385 * @return $this … … 377 398 { 378 399 if (empty($this->shipping_address)) { 379 $this->shipping_address = new MailChimp_WooCommerce_Address( 'shipping');400 $this->shipping_address = new MailChimp_WooCommerce_Address(); 380 401 } 381 402 return $this->shipping_address; … … 399 420 { 400 421 if (empty($this->billing_address)) { 401 $this->billing_address = new MailChimp_WooCommerce_Address( 'billing');422 $this->billing_address = new MailChimp_WooCommerce_Address(); 402 423 } 403 424 return $this->billing_address; -
mailchimp-for-woocommerce/trunk/includes/api/assets/class-mailchimp-store.php
r1582981 r1709699 24 24 protected $address = null; 25 25 protected $platform = null; 26 protected $connected_site = null; 26 27 27 28 /** … … 291 292 292 293 return $this; 294 } 295 296 /** 297 * @return null|string 298 */ 299 public function getConnectedSiteForeignID() 300 { 301 return $this->getConnectedSiteParam('site_foreign_id'); 302 } 303 304 /** 305 * @return null|string 306 */ 307 public function getConnectedSiteScriptUrl() 308 { 309 if (($script = $this->getConnectedSiteParam('site_script'))) { 310 return $script['url']; 311 } 312 return false; 313 } 314 315 /** 316 * @return null|string 317 */ 318 public function getConnectedSiteScriptFragment() 319 { 320 if (($script = $this->getConnectedSiteParam('site_script'))) { 321 return $script['fragment']; 322 } 323 return false; 324 } 325 326 /** 327 * @param $key 328 * @param null $default 329 * @return null 330 */ 331 public function getConnectedSiteParam($key, $default = null) 332 { 333 if (empty($this->connected_site)) { 334 return $default; 335 } 336 return array_key_exists($key, $this->connected_site) ? $this->connected_site[$key] : null; 293 337 } 294 338 … … 338 382 } 339 383 384 if (array_key_exists('connected_site', $data)) { 385 $this->connected_site = $data['connected_site']; 386 } 387 340 388 return $this; 341 389 } -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-api.php
r1582981 r1709699 398 398 399 399 /** 400 * @param $store_id 401 * @return array|bool 402 */ 403 public function checkConnectedSite($store_id) 404 { 405 try { 406 return $this->get("connected-sites/{$store_id}"); 407 } catch (MailChimp_WooCommerce_Error $e) { 408 return false; 409 } 410 } 411 412 /** 413 * @param $store_id 414 * @return array|bool 415 */ 416 public function connectSite($store_id) 417 { 418 try { 419 return $this->post("connected-sites/{$store_id}/actions/verify-script-installation", array()); 420 } catch (MailChimp_WooCommerce_Error $e) { 421 return false; 422 } 423 } 424 425 /** 400 426 * @return array|bool 401 427 */ … … 664 690 return false; 665 691 } 692 693 // submit the first one 666 694 $data = $this->post("ecommerce/stores/$store_id/orders", $order->toArray()); 695 696 // if the order is in pending status, we need to submit the order again with a paid status. 697 if ($order->shouldConfirmAndPay() && $order->getFinancialStatus() !== 'paid') { 698 $order->setFinancialStatus('paid'); 699 $data = $this->patch("ecommerce/stores/{$store_id}/orders/{$order->getId()}", $order->toArray()); 700 } 701 667 702 update_option('mailchimp-woocommerce-resource-last-updated', time()); 668 703 $order = new MailChimp_WooCommerce_Order(); … … 689 724 } 690 725 $id = $order->getId(); 691 $data = $this->patch("ecommerce/stores/$store_id/orders/$id", $order->toArray()); 726 $data = $this->patch("ecommerce/stores/{$store_id}/orders/{$id}", $order->toArray()); 727 728 // if the order is in pending status, we need to submit the order again with a paid status. 729 if ($order->shouldConfirmAndPay() && $order->getFinancialStatus() !== 'paid') { 730 $order->setFinancialStatus('paid'); 731 $data = $this->patch("ecommerce/stores/{$store_id}/orders/{$id}", $order->toArray()); 732 } 733 692 734 $order = new MailChimp_WooCommerce_Order(); 693 735 return $order->fromArray($data); -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php
r1639952 r1709699 59 59 $order = new MailChimp_WooCommerce_Order(); 60 60 61 $order->setId($woo->get_ id());61 $order->setId($woo->get_order_number()); 62 62 63 63 // if we have a campaign id let's set it now. … … 66 66 } 67 67 68 $order->setProcessedAt($woo->get_date_created() );68 $order->setProcessedAt($woo->get_date_created()->setTimezone(new \DateTimeZone('UTC'))); 69 69 70 70 $order->setCurrencyCode($woo->get_currency()); … … 86 86 $order->setFinancialStatus($financial_status); 87 87 88 // if the status is processing, we need to send this one first, then send a 'paid' status right after. 89 if ($status === 'processing') { 90 $order->confirmAndPay(true); 91 } 92 88 93 // only set this if the order is cancelled. 89 if ($status === 'cancelled') $order->setCancelledAt($woo->get_date_modified()); 94 if ($status === 'cancelled') { 95 $order->setCancelledAt($woo->get_date_modified()->setTimezone(new \DateTimeZone('UTC'))); 96 } 90 97 91 98 // set the total … … 329 336 // All product orders require processing, except those for digital downloads 330 337 'processing' => (object) array( 331 'financial' => 'p rocessing',338 'financial' => 'pending', 332 339 'fulfillment' => null 333 340 ), -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-woocommerce-transform-orders.php
r1639952 r1709699 12 12 { 13 13 public $campaign_id = null; 14 protected $use_user_address = false; 14 15 15 16 /** … … 59 60 $order = new MailChimp_WooCommerce_Order(); 60 61 61 $order->setId($woo-> id);62 $order->setId($woo->get_order_number()); 62 63 63 64 // if we have a campaign id let's set it now. … … 66 67 } 67 68 68 $order->setProcessedAt( mailchimp_date_utc($woo->order_date));69 70 $order->setCurrencyCode($woo->get_ order_currency());69 $order->setProcessedAt($woo->get_date_created()->setTimezone(new \DateTimeZone('UTC'))); 70 71 $order->setCurrencyCode($woo->get_currency()); 71 72 72 73 // grab the current statuses - this will end up being custom at some point. … … 86 87 $order->setFinancialStatus($financial_status); 87 88 89 // if the status is processing, we need to send this one first, then send a 'paid' status right after. 90 if ($status === 'processing') { 91 $order->confirmAndPay(true); 92 } 93 88 94 // only set this if the order is cancelled. 89 if ($status === 'cancelled') $order->setCancelledAt(mailchimp_date_utc($woo->modified_date)); 95 if ($status === 'cancelled') { 96 $order->setCancelledAt($woo->get_date_modified()->setTimezone(new \DateTimeZone('UTC'))); 97 } 90 98 91 99 // set the total … … 135 143 } 136 144 137 mailchimp_log('order.items.error', "Order #{$woo-> id} :: Product {$item->getProductId()} does not exist!");145 mailchimp_log('order.items.error', "Order #{$woo->get_order_number()} :: Product {$item->getProductId()} does not exist!"); 138 146 continue; 139 147 } … … 166 174 167 175 // we are saving the post meta for subscribers on each order... so if they have subscribed on checkout 168 $subscriber_meta = get_post_meta($order-> id, 'mailchimp_woocommerce_is_subscribed', true);176 $subscriber_meta = get_post_meta($order->get_id(), 'mailchimp_woocommerce_is_subscribed', true); 169 177 $subscribed_on_order = $subscriber_meta === '' ? false : (bool) $subscriber_meta; 170 178 … … 189 197 190 198 if (($user = get_userdata($order->customer_user))) { 191 192 /** IF we wanted to use the user data instead we would do it here.199 /** 200 * IF we wanted to use the user data instead we would do it here. 193 201 * but we discussed using the billing address instead. 194 202 */ 195 196 /* 197 $customer->setId($user->ID); 198 $customer->setEmailAddress($user->user_email); 199 $customer->setFirstName($user->first_name); 200 $customer->setLastName($user->last_name); 201 202 if (($address = $this->getUserAddress($user->ID))) { 203 if (count($address->toArray()) > 3) { 204 $customer->setAddress($address); 205 } 206 } 207 */ 203 if ($this->use_user_address) { 204 $customer->setId($user->ID); 205 $customer->setEmailAddress($user->user_email); 206 $customer->setFirstName($user->first_name); 207 $customer->setLastName($user->last_name); 208 209 if (($address = $this->getUserAddress($user->ID))) { 210 if (count($address->toArray()) > 3) { 211 $customer->setAddress($address); 212 } 213 } 214 } 208 215 209 216 if (!($stats = $this->getCustomerOrderTotals($order->customer_user))) { … … 461 468 // All product orders require processing, except those for digital downloads 462 469 'processing' => (object) array( 463 'financial' => 'p rocessing',470 'financial' => 'pending', 464 471 'fulfillment' => null 465 472 ), -
mailchimp-for-woocommerce/trunk/includes/api/errors/class-mailchimp-server-error.php
r1514325 r1709699 9 9 * Time: 11:13 AM 10 10 */ 11 class MailChimp_WooCommerce_ServerError extends \Exception11 class MailChimp_WooCommerce_ServerError extends MailChimp_WooCommerce_Error 12 12 { 13 13 -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce-activator.php
r1615883 r1709699 34 34 // add a store id flag which will be a random hash 35 35 update_option('mailchimp-woocommerce-store_id', md5(get_option('siteurl')), 'yes'); 36 37 // try this now for existing stores on an update. 38 mailchimp_update_connected_site_script(); 36 39 } 37 40 -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce-newsletter.php
r1557758 r1709699 65 65 public function processPayPalNewsletterField($order) 66 66 { 67 $this->handleStatus($order-> id);67 $this->handleStatus($order->get_id()); 68 68 } 69 69 -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-process-orders.php
r1639952 r1709699 63 63 return $response; 64 64 65 } catch (MailChimp_WooCommerce_ServerError $e) { 66 mailchimp_log('sync.orders.error', "$call :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}"); 67 return false; 65 68 } catch (MailChimp_WooCommerce_Error $e) { 66 69 mailchimp_log('sync.orders.error', "$call :: MailChimp_WooCommerce_Error :: {$e->getMessage()}"); 67 return false;68 } catch (MailChimp_WooCommerce_ServerError $e) {69 mailchimp_log('sync.orders.error', "$call :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}");70 70 return false; 71 71 } catch (Exception $e) { -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-process-products.php
r1639952 r1709699 54 54 return $response; 55 55 56 } catch (MailChimp_WooCommerce_ServerError $e) { 57 mailchimp_log('sync.products.error', "addStoreProduct :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}"); 56 58 } catch (MailChimp_WooCommerce_Error $e) { 57 59 mailchimp_log('sync.products.error', "addStoreProduct :: MailChimp_WooCommerce_Error :: {$e->getMessage()}"); 58 } catch (MailChimp_WooCommerce_ServerError $e) {59 mailchimp_log('sync.products.error', "addStoreProduct :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}");60 60 } catch (Exception $e) { 61 61 mailchimp_log('sync.products.error', "addStoreProduct :: Uncaught Exception :: {$e->getMessage()}"); -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-single-product.php
r1639952 r1709699 68 68 return $product; 69 69 70 } catch (MailChimp_WooCommerce_ServerError $e) { 71 mailchimp_log('product_submit.error', "addStoreProduct :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}"); 70 72 } catch (MailChimp_WooCommerce_Error $e) { 71 73 mailchimp_log('product_submit.error', "addStoreProduct :: MailChimp_WooCommerce_Error :: {$e->getMessage()}"); 72 } catch (MailChimp_WooCommerce_ServerError $e) {73 mailchimp_log('product_submit.error', "addStoreProduct :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}");74 74 } catch (Exception $e) { 75 75 mailchimp_log('product_submit.error', "addStoreProduct :: Uncaught Exception :: {$e->getMessage()}"); -
mailchimp-for-woocommerce/trunk/mailchimp-woocommerce.php
r1639952 r1709699 17 17 * Plugin URI: https://mailchimp.com/connect-your-store/ 18 18 * Description: MailChimp - WooCommerce plugin 19 * Version: 2.0. 019 * Version: 2.0.1 20 20 * Author: MailChimp 21 21 * Author URI: https://mailchimp.com … … 25 25 * Domain Path: /languages 26 26 * Requires at least: 4.4 27 * Tested up to: 4. 727 * Tested up to: 4.8 28 28 */ 29 29 … … 37 37 */ 38 38 function mailchimp_environment_variables() { 39 global $wp_version; 40 41 return (object) array( 42 'repo' => 'master', 43 'environment' => 'production', 44 'version' => '2.0.0', 45 'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version), 46 'wc_version' => function_exists('WC') ? WC()->version : null, 47 ); 39 return require 'env.php'; 48 40 } 49 41 … … 244 236 } 245 237 246 /**247 * See if we need to run any updates.248 */249 function run_mailchimp_plugin_updater() {250 if (!class_exists('PucFactory')) {251 require plugin_dir_path( __FILE__ ) . 'includes/plugin-update-checker/plugin-update-checker.php';252 }253 254 /** @var \PucGitHubChecker_3_1 $checker */255 $updater = PucFactory::getLatestClassVersion('PucGitHubChecker');256 257 if (class_exists($updater)) {258 $env = mailchimp_environment_variables();259 $checker = new $updater('https://github.com/mailchimp/mc-woocommerce/', __FILE__, $env->repo, 1);260 $checker->handleManualCheck();261 }262 }263 264 238 function mailchimp_debug($action, $message, $data = null) 265 239 { … … 349 323 } 350 324 325 /** 326 * @return bool 327 */ 328 function mailchimp_update_connected_site_script() { 329 // pull the store ID 330 $store_id = mailchimp_get_store_id(); 331 332 // if the api is configured 333 if ($store_id && ($api = mailchimp_get_api())) { 334 335 // if we have a store 336 if (($store = $api->getStore($store_id))) { 337 338 // see if we have a connected site script url/fragment 339 $url = $store->getConnectedSiteScriptUrl(); 340 $fragment = $store->getConnectedSiteScriptFragment(); 341 342 // if it's not empty we need to set the values 343 if ($url && $fragment) { 344 345 // update the options for script_url and script_fragment 346 update_option('mailchimp-woocommerce-script_url', $url); 347 update_option('mailchimp-woocommerce-script_fragment', $fragment); 348 349 // check to see if the site is connected 350 if (!$api->checkConnectedSite($store_id)) { 351 352 // if it's not, connect it now. 353 $api->connectSite($store_id); 354 } 355 356 return true; 357 } 358 } 359 } 360 return false; 361 } 362 363 /** 364 * @return string|false 365 */ 366 function mailchimp_get_connected_site_script_url() { 367 return get_option('mailchimp-woocommerce-script_url', false); 368 } 369 370 /** 371 * @return string|false 372 */ 373 function mailchimp_get_connected_site_script_fragment() { 374 return get_option('mailchimp-woocommerce-script_fragment', false); 375 } 376 351 377 register_activation_hook( __FILE__, 'activate_mailchimp_woocommerce' ); 352 378 register_deactivation_hook( __FILE__, 'deactivate_mailchimp_woocommerce' ); … … 385 411 add_action('wp_head', 'mailchimp_woocommerce_add_meta_tags'); 386 412 387 /** Add the plugin updater function ONLY when they are logged in as admin. */388 add_action('admin_init', 'run_mailchimp_plugin_updater');389 390 413 /** Add all the MailChimp hooks. */ 391 414 run_mailchimp_woocommerce(); 392 -
mailchimp-for-woocommerce/trunk/public/class-mailchimp-woocommerce-public.php
r1557758 r1709699 74 74 75 75 //wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mailchimp-woocommerce-public.css', array(), $this->version, 'all' ); 76 77 76 } 78 77 … … 106 105 wp_enqueue_script($this->plugin_name); 107 106 107 // if we have the connected_site script url saved, we need to inject it 108 if (($site = mailchimp_get_connected_site_script_url()) && !empty($site)) { 109 wp_enqueue_script($this->plugin_name.'_connected_site', $site, array(), $this->version, true); 110 } 108 111 } 109 112 }
Note: See TracChangeset
for help on using the changeset viewer.