Changeset 1582981
- Timestamp:
- 01/26/2017 09:27:11 PM (9 years ago)
- Location:
- mailchimp-for-woocommerce
- Files:
-
- 116 added
- 14 edited
-
tags/1.0.8 (added)
-
tags/1.0.8/LICENSE.txt (added)
-
tags/1.0.8/README.md (added)
-
tags/1.0.8/README.txt (added)
-
tags/1.0.8/admin (added)
-
tags/1.0.8/admin/class-mailchimp-woocommerce-admin.php (added)
-
tags/1.0.8/admin/css (added)
-
tags/1.0.8/admin/css/mailchimp-woocommerce-admin.css (added)
-
tags/1.0.8/admin/index.php (added)
-
tags/1.0.8/admin/js (added)
-
tags/1.0.8/admin/js/mailchimp-woocommerce-admin.js (added)
-
tags/1.0.8/admin/partials (added)
-
tags/1.0.8/admin/partials/mailchimp-woocommerce-admin-tabs.php (added)
-
tags/1.0.8/admin/partials/tabs (added)
-
tags/1.0.8/admin/partials/tabs/api_key.php (added)
-
tags/1.0.8/admin/partials/tabs/campaign_defaults.php (added)
-
tags/1.0.8/admin/partials/tabs/errors (added)
-
tags/1.0.8/admin/partials/tabs/errors/missing_api_key.php (added)
-
tags/1.0.8/admin/partials/tabs/errors/missing_campaign_defaults.php (added)
-
tags/1.0.8/admin/partials/tabs/errors/missing_list.php (added)
-
tags/1.0.8/admin/partials/tabs/errors/missing_store.php (added)
-
tags/1.0.8/admin/partials/tabs/errors/not_ready_for_sync.php (added)
-
tags/1.0.8/admin/partials/tabs/newsletter_settings.php (added)
-
tags/1.0.8/admin/partials/tabs/notices.php (added)
-
tags/1.0.8/admin/partials/tabs/store_info.php (added)
-
tags/1.0.8/admin/partials/tabs/store_sync.php (added)
-
tags/1.0.8/admin/partials/tabs/success (added)
-
tags/1.0.8/admin/partials/tabs/success/re-sync-started.php (added)
-
tags/1.0.8/changelog.md (added)
-
tags/1.0.8/includes (added)
-
tags/1.0.8/includes/api (added)
-
tags/1.0.8/includes/api/assets (added)
-
tags/1.0.8/includes/api/assets/class-mailchimp-address.php (added)
-
tags/1.0.8/includes/api/assets/class-mailchimp-cart.php (added)
-
tags/1.0.8/includes/api/assets/class-mailchimp-customer.php (added)
-
tags/1.0.8/includes/api/assets/class-mailchimp-line-item.php (added)
-
tags/1.0.8/includes/api/assets/class-mailchimp-order.php (added)
-
tags/1.0.8/includes/api/assets/class-mailchimp-product-variation.php (added)
-
tags/1.0.8/includes/api/assets/class-mailchimp-product.php (added)
-
tags/1.0.8/includes/api/assets/class-mailchimp-store.php (added)
-
tags/1.0.8/includes/api/class-mailchimp-api.php (added)
-
tags/1.0.8/includes/api/class-mailchimp-woocommerce-api.php (added)
-
tags/1.0.8/includes/api/class-mailchimp-woocommerce-create-list-submission.php (added)
-
tags/1.0.8/includes/api/class-mailchimp-woocommerce-transform-orders.php (added)
-
tags/1.0.8/includes/api/class-mailchimp-woocommerce-transform-products.php (added)
-
tags/1.0.8/includes/api/errors (added)
-
tags/1.0.8/includes/api/errors/class-mailchimp-error.php (added)
-
tags/1.0.8/includes/api/errors/class-mailchimp-server-error.php (added)
-
tags/1.0.8/includes/api/helpers (added)
-
tags/1.0.8/includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php (added)
-
tags/1.0.8/includes/api/helpers/class-mailchimp-woocommerce-api-locales.php (added)
-
tags/1.0.8/includes/class-mailchimp-woocommerce-activator.php (added)
-
tags/1.0.8/includes/class-mailchimp-woocommerce-deactivator.php (added)
-
tags/1.0.8/includes/class-mailchimp-woocommerce-i18n.php (added)
-
tags/1.0.8/includes/class-mailchimp-woocommerce-loader.php (added)
-
tags/1.0.8/includes/class-mailchimp-woocommerce-newsletter.php (added)
-
tags/1.0.8/includes/class-mailchimp-woocommerce-options.php (added)
-
tags/1.0.8/includes/class-mailchimp-woocommerce-service.php (added)
-
tags/1.0.8/includes/class-mailchimp-woocommerce.php (added)
-
tags/1.0.8/includes/index.php (added)
-
tags/1.0.8/includes/plugin-update-checker (added)
-
tags/1.0.8/includes/plugin-update-checker/README.md (added)
-
tags/1.0.8/includes/plugin-update-checker/composer.json (added)
-
tags/1.0.8/includes/plugin-update-checker/css (added)
-
tags/1.0.8/includes/plugin-update-checker/css/puc-debug-bar.css (added)
-
tags/1.0.8/includes/plugin-update-checker/debug-bar-panel.php (added)
-
tags/1.0.8/includes/plugin-update-checker/debug-bar-plugin.php (added)
-
tags/1.0.8/includes/plugin-update-checker/github-checker.php (added)
-
tags/1.0.8/includes/plugin-update-checker/js (added)
-
tags/1.0.8/includes/plugin-update-checker/js/debug-bar.js (added)
-
tags/1.0.8/includes/plugin-update-checker/languages (added)
-
tags/1.0.8/includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo (added)
-
tags/1.0.8/includes/plugin-update-checker/languages/plugin-update-checker-fr_FR.po (added)
-
tags/1.0.8/includes/plugin-update-checker/languages/plugin-update-checker-hu_HU.mo (added)
-
tags/1.0.8/includes/plugin-update-checker/languages/plugin-update-checker-hu_HU.po (added)
-
tags/1.0.8/includes/plugin-update-checker/languages/plugin-update-checker.pot (added)
-
tags/1.0.8/includes/plugin-update-checker/license.txt (added)
-
tags/1.0.8/includes/plugin-update-checker/plugin-update-checker.php (added)
-
tags/1.0.8/includes/plugin-update-checker/vendor (added)
-
tags/1.0.8/includes/plugin-update-checker/vendor/Parsedown.php (added)
-
tags/1.0.8/includes/plugin-update-checker/vendor/ParsedownLegacy.php (added)
-
tags/1.0.8/includes/plugin-update-checker/vendor/readme-parser.php (added)
-
tags/1.0.8/includes/processes (added)
-
tags/1.0.8/includes/processes/class-mailchimp-woocommerce-abstract-sync.php (added)
-
tags/1.0.8/includes/processes/class-mailchimp-woocommerce-cart-update.php (added)
-
tags/1.0.8/includes/processes/class-mailchimp-woocommerce-process-orders.php (added)
-
tags/1.0.8/includes/processes/class-mailchimp-woocommerce-process-products.php (added)
-
tags/1.0.8/includes/processes/class-mailchimp-woocommerce-single-order.php (added)
-
tags/1.0.8/includes/processes/class-mailchimp-woocommerce-single-product.php (added)
-
tags/1.0.8/includes/processes/class-mailchimp-woocommerce-user-submit.php (added)
-
tags/1.0.8/includes/vendor (added)
-
tags/1.0.8/includes/vendor/queue (added)
-
tags/1.0.8/includes/vendor/queue.php (added)
-
tags/1.0.8/includes/vendor/queue/classes (added)
-
tags/1.0.8/includes/vendor/queue/classes/cli (added)
-
tags/1.0.8/includes/vendor/queue/classes/cli/queue-command.php (added)
-
tags/1.0.8/includes/vendor/queue/classes/worker (added)
-
tags/1.0.8/includes/vendor/queue/classes/worker/wp-http-worker.php (added)
-
tags/1.0.8/includes/vendor/queue/classes/worker/wp-worker.php (added)
-
tags/1.0.8/includes/vendor/queue/classes/wp-job.php (added)
-
tags/1.0.8/includes/vendor/queue/classes/wp-queue.php (added)
-
tags/1.0.8/index.php (added)
-
tags/1.0.8/languages (added)
-
tags/1.0.8/languages/mailchimp-woocommerce.pot (added)
-
tags/1.0.8/mailchimp-woocommerce.php (added)
-
tags/1.0.8/public (added)
-
tags/1.0.8/public/class-mailchimp-woocommerce-public.php (added)
-
tags/1.0.8/public/css (added)
-
tags/1.0.8/public/css/mailchimp-woocommerce-public.css (added)
-
tags/1.0.8/public/index.php (added)
-
tags/1.0.8/public/js (added)
-
tags/1.0.8/public/js/mailchimp-woocommerce-public.js (added)
-
tags/1.0.8/public/js/mailchimp-woocommerce-public.min.js (added)
-
tags/1.0.8/public/partials (added)
-
tags/1.0.8/public/partials/mailchimp-woocommerce-public-display.php (added)
-
tags/1.0.8/uninstall.php (added)
-
trunk/README.txt (modified) (1 diff)
-
trunk/admin/partials/tabs/newsletter_settings.php (modified) (1 diff)
-
trunk/changelog.md (modified) (2 diffs)
-
trunk/includes/api/assets/class-mailchimp-cart.php (modified) (1 diff)
-
trunk/includes/api/assets/class-mailchimp-customer.php (modified) (1 diff)
-
trunk/includes/api/assets/class-mailchimp-order.php (modified) (11 diffs)
-
trunk/includes/api/assets/class-mailchimp-product.php (modified) (1 diff)
-
trunk/includes/api/assets/class-mailchimp-store.php (modified) (1 diff)
-
trunk/includes/api/class-mailchimp-api.php (modified) (15 diffs)
-
trunk/includes/api/class-mailchimp-woocommerce-transform-orders.php (modified) (3 diffs)
-
trunk/includes/class-mailchimp-woocommerce-service.php (modified) (6 diffs)
-
trunk/includes/class-mailchimp-woocommerce.php (modified) (2 diffs)
-
trunk/includes/processes/class-mailchimp-woocommerce-single-order.php (modified) (7 diffs)
-
trunk/mailchimp-woocommerce.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mailchimp-for-woocommerce/trunk/README.txt
r1514922 r1582981 47 47 48 48 For more information on settings and configuration, please visit our Knowledge Base: [http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce](http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce) 49 50 == Changelog == 51 = 1.0.8 = 52 * add landing_site, financial status and discount information for orders 53 * fix to support php 5.3 54 55 = 1.0.7 = 56 * add options to move, hide and change defaults for opt-in checkbox 57 * add ability to re-sync and display connection details 58 * support for subscriptions without orders 59 * additional small fixes and some internal logging removal 60 61 = 1.0.6 = 62 * fixed conflict with the plugin updater where the class could not be loaded correctly. 63 * fixed error validation for store name. 64 * fixed cross device abandoned cart url's 65 66 = 1.0.4 = 67 * fix for Abandoned Carts without cookies 68 69 = 1.0.3 = 70 * fixed cart posts on dollar amounts greater than 1000 71 72 = 1.0.2 = 73 * title correction for Product Variants 74 * added installation checks for WooCommerce and phone contact info 75 * support for free orders 76 77 = 1.0 = 78 * added is_synicng flag to prevent sends during backfill 79 * fix for conflicts with Gravity Forms Pro and installation issues 80 * skip all Amazon orders 81 * allow users to set opt-in for pre-existing customers during first sync 82 * add Plugin Updater 83 84 = 0.1.22 = 85 * flag quantity as 1 if the product does not manage inventory 86 87 = 0.1.21 = 88 * php version check to display warnings < 5.5 89 90 = 0.1.19 = 91 * fix campaign tracking on new orders 92 93 = 0.1.18 = 94 * check woocommerce dependency before activating the plugin 95 96 = 0.1.17 = 97 * fix php version syntax errors for array's 98 99 = 0.1.16 = 100 * fix namespace conflicts 101 * fix free order 0.00 issue 102 * fix product variant naming issue 103 104 = 0.1.15 = 105 * adding special MailChimp header to requests 106 107 = 0.1.14 = 108 * removing jquery dependencies 109 110 = 0.1.13 = 111 * fixing a number format issue on total_spent 112 113 = 0.1.12 = 114 * skipping orders placed through amazon due to seller agreements 115 116 = 0.1.11 = 117 * removed an extra debug log that was not needed 118 119 = 0.1.10 = 120 * altered debug logging and fixed store settings validation requirements 121 122 = 0.1.9 = 123 * using fallback to stream context during failed patch requests 124 125 = 0.1.8 = 126 * fixing http request header for larger patch requests 127 128 = 0.1.7 = 129 * fixing various bugs with the sync and product issues. 130 131 = 0.1.2 = 132 * fixed admin order update hook. -
mailchimp-for-woocommerce/trunk/admin/partials/tabs/newsletter_settings.php
r1557758 r1582981 51 51 <?php 52 52 if (is_array($mailchimp_lists)) { 53 $selected_list = isset($options['mailchimp_list']) ? $options['mailchimp_list'] : null; 53 54 foreach ($mailchimp_lists as $key => $value ) { 54 echo '<option value="' . esc_attr( $key ) . '" ' . selected( $key === $options['mailchimp_list'], true, false) . '>' . esc_html( $value ) . '</option>';55 echo '<option value="' . esc_attr( $key ) . '" ' . selected(((string) $key === (string) $selected_list), true, false) . '>' . esc_html( $value ) . '</option>'; 55 56 } 56 57 } -
mailchimp-for-woocommerce/trunk/changelog.md
r1522130 r1582981 1 ** 1.0.8 ** 2 * add landing_site, financial status and discount information for orders 3 * fix to support php 5.3 4 5 ** 1.0.7 ** 6 * add options to move, hide and change defaults for opt-in checkbox 7 * add ability to re-sync and display connection details 8 * support for subscriptions without orders 9 * additional small fixes and some internal logging removal 10 1 11 ** 1.0.6 ** 2 12 * fixed conflict with the plugin updater where the class could not be loaded correctly. … … 4 14 * fixed cross device abandoned cart url's 5 15 16 ** 1.0.4 ** 17 * fix for Abandoned Carts without cookies 18 6 19 ** 1.0.3 ** 7 20 * fixed cart posts on dollar amounts greater than 1000 21 22 ** 1.0.2** 23 * title correction for Product Variants 24 * added installation checks for WooCommerce and phone contact info 25 support for free orders 26 27 ** 1.0 ** 28 * added is_synicng flag to prevent sends during backfill 29 * fix for conflicts with Gravity Forms Pro and installation issues 30 * skip all Amazon orders 31 * allow users to set opt-in for pre-existing customers during first sync 32 * add Plugin Updater 8 33 9 34 ** 0.1.22 ** -
mailchimp-for-woocommerce/trunk/includes/api/assets/class-mailchimp-cart.php
r1557758 r1582981 262 262 263 263 if (array_key_exists('customer', $data) && is_array($data['customer'])) { 264 $this->customer = (new MailChimp_WooCommerce_Customer())->fromArray($data['customer']); 264 $customer = new MailChimp_WooCommerce_Customer(); 265 $this->customer = $customer->fromArray($data['customer']); 265 266 } 266 267 267 268 if (array_key_exists('lines', $data) && is_array($data['lines'])) { 268 269 foreach ($data['lines'] as $line_item) { 269 $this->lines[] = (new MailChimp_WooCommerce_LineItem)->fromArray($line_item); 270 $item = new MailChimp_WooCommerce_LineItem(); 271 $this->lines[] = $item->fromArray($line_item); 270 272 } 271 273 } -
mailchimp-for-woocommerce/trunk/includes/api/assets/class-mailchimp-customer.php
r1557758 r1582981 250 250 251 251 if (array_key_exists('address', $data) && is_array($data['address'])) { 252 $this->address = (new MailChimp_WooCommerce_Address())->fromArray($data['address']); 252 $address = new MailChimp_WooCommerce_Address(); 253 $this->address = $address->fromArray($data['address']); 253 254 } 254 255 -
mailchimp-for-woocommerce/trunk/includes/api/assets/class-mailchimp-order.php
r1514325 r1582981 12 12 { 13 13 protected $id = null; 14 protected $landing_site = null; 14 15 protected $customer = null; 15 16 protected $campaign_id = null; … … 19 20 protected $order_total = null; 20 21 protected $tax_total = null; 22 protected $discount_total = null; 21 23 protected $shipping_total = null; 22 24 protected $updated_at_foreign = null; … … 34 36 return array( 35 37 'id' => 'required|string', 38 'landing_site' => 'required|string', 36 39 'customer' => 'required', 37 40 'campaign_id' => 'string', … … 41 44 'order_total' => 'required|numeric', 42 45 'tax_total' => 'numeric', 46 'discount_total' => 'numeric', 43 47 'processed_at_foreign' => 'date', 44 48 'updated_at_foreign' => 'date', … … 68 72 69 73 /** 74 * @param $landing_site 75 * @return $this 76 */ 77 public function setLandingSite($landing_site) 78 { 79 $this->landing_site = $landing_site; 80 81 return $this; 82 } 83 84 /** 85 * @return null|string 86 */ 87 public function getLandingSite() 88 { 89 return $this->landing_site; 90 } 91 92 /** 70 93 * @param MailChimp_WooCommerce_Customer $customer 71 94 * @return MailChimp_WooCommerce_Order … … 241 264 242 265 /** 266 * @return mixed 267 */ 268 public function getDiscountTotal() 269 { 270 return $this->discount_total; 271 } 272 273 /** 274 * @param mixed $discount_total 275 * @return MailChimp_WooCommerce_Order 276 */ 277 public function setDiscountTotal($discount_total) 278 { 279 $this->discount_total = $discount_total; 280 281 return $this; 282 } 283 284 /** 243 285 * @param \DateTime $time 244 286 * @return $this … … 348 390 return mailchimp_array_remove_empty(array( 349 391 'id' => (string) $this->getId(), 392 'landing_site' => (string) $this->getLandingSite(), 350 393 'customer' => $this->getCustomer()->toArray(), 351 394 'campaign_id' => (string) $this->getCampaignId(), … … 355 398 'order_total' => floatval($this->getOrderTotal()), 356 399 'tax_total' => floatval($this->getTaxTotal()), 400 'discount_total' => floatval($this->getDiscountTotal()), 357 401 'shipping_total' => floatval($this->getShippingTotal()), 358 402 'processed_at_foreign' => (string) $this->getProcessedAt(), … … 375 419 { 376 420 $singles = array( 377 'id', ' campaign_id', 'financial_status', 'fulfillment_status',378 'currency_code', 'order_total', 'tax_total', ' processed_at_foreign',421 'id', 'landing_site', 'campaign_id', 'financial_status', 'fulfillment_status', 422 'currency_code', 'order_total', 'tax_total', 'discount_total', 'processed_at_foreign', 379 423 'cancelled_at_foreign', 'updated_at_foreign' 380 424 ); … … 387 431 388 432 if (array_key_exists('shipping_address', $data) && is_array($data['shipping_address'])) { 389 $this->shipping_address = (new MailChimp_WooCommerce_Address())->fromArray($data['shipping_address']); 433 $shipping = new MailChimp_WooCommerce_Address(); 434 $this->shipping_address = $shipping->fromArray($data['shipping_address']); 390 435 } 391 436 392 437 if (array_key_exists('billing_address', $data) && is_array($data['billing_address'])) { 393 $this->billing_address = (new MailChimp_WooCommerce_Address())->fromArray($data['billing_address']); 438 $billing = new MailChimp_WooCommerce_Address(); 439 $this->billing_address = $billing->fromArray($data['billing_address']); 394 440 } 395 441 … … 397 443 $this->lines = array(); 398 444 foreach ($data['lines'] as $line_item) { 399 $this->lines[] = (new MailChimp_WooCommerce_LineItem())->fromArray($line_item); 445 $item = new MailChimp_WooCommerce_LineItem(); 446 $this->lines[] = $item->fromArray($line_item); 400 447 } 401 448 } -
mailchimp-for-woocommerce/trunk/includes/api/assets/class-mailchimp-product.php
r1514325 r1582981 273 273 $this->variants = array(); 274 274 foreach ($data['variants'] as $variant) { 275 $this->variants[] = (new MailChimp_WooCommerce_ProductVariation())->fromArray($variant); 275 $variation = new MailChimp_WooCommerce_ProductVariation(); 276 $this->variants[] = $variation->fromArray($variant); 276 277 } 277 278 } -
mailchimp-for-woocommerce/trunk/includes/api/assets/class-mailchimp-store.php
r1514325 r1582981 334 334 335 335 if (array_key_exists('address', $data)) { 336 $this->address = (new MailChimp_WooCommerce_Address())->fromArray($data['address']); 336 $address = new MailChimp_WooCommerce_Address(); 337 $this->address = $address->fromArray($data['address']); 337 338 } 338 339 -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-api.php
r1557758 r1582981 390 390 return false; 391 391 } 392 return (new MailChimp_WooCommerce_Store)->fromArray($data); 392 $store = new MailChimp_WooCommerce_Store(); 393 return $store->fromArray($data); 393 394 } catch (MailChimp_WooCommerce_Error $e) { 394 395 return false; … … 411 412 412 413 foreach ($data['stores'] as $store_data) { 413 $response[] = (new MailChimp_WooCommerce_Store)->fromArray($store_data); 414 $store = new MailChimp_WooCommerce_Store(); 415 $response[] = $store->fromArray($store_data); 414 416 } 415 417 … … 456 458 $this->validateStoreSubmission($store); 457 459 $data = $this->post("ecommerce/stores", $store->toArray()); 458 return (new MailChimp_WooCommerce_Store)->fromArray($data); 460 $store = new MailChimp_WooCommerce_Store(); 461 return $store->fromArray($data); 459 462 } catch (\Exception $e) { 460 463 if (!$silent) throw $e; … … 474 477 $this->validateStoreSubmission($store); 475 478 $data = $this->patch("ecommerce/stores/{$store->getId()}", $store->toArray()); 476 return (new MailChimp_WooCommerce_Store)->fromArray($data); 479 $store = new MailChimp_WooCommerce_Store(); 480 return $store->fromArray($data); 477 481 } catch (\Exception $e) { 478 482 if (!$silent) throw $e; … … 504 508 try { 505 509 $data = $this->get("ecommerce/stores/$store_id/customers/$customer_id"); 506 return (new MailChimp_WooCommerce_Customer)->fromArray($data); 510 $customer = new MailChimp_WooCommerce_Customer(); 511 return $customer->fromArray($data); 507 512 } catch (MailChimp_WooCommerce_Error $e) { 508 513 return false; … … 519 524 $this->validateStoreSubmission($store); 520 525 $data = $this->post("ecommerce/stores", $store->toArray()); 521 return (new MailChimp_WooCommerce_Customer)->fromArray($data); 526 $customer = new MailChimp_WooCommerce_Customer(); 527 return $customer->fromArray($data); 522 528 } 523 529 … … 550 556 try { 551 557 $data = $this->post("ecommerce/stores/$store_id/carts", $cart->toArray()); 552 return (new MailChimp_WooCommerce_Cart)->setStoreID($store_id)->fromArray($data); 558 $cart = new MailChimp_WooCommerce_Cart(); 559 return $cart->setStoreID($store_id)->fromArray($data); 553 560 } catch (MailChimp_WooCommerce_Error $e) { 554 561 if (!$silent) throw $e; … … 569 576 try { 570 577 $data = $this->patch("ecommerce/stores/$store_id/carts/{$cart->getId()}", $cart->toArrayForUpdate()); 571 return (new MailChimp_WooCommerce_Cart)->setStoreID($store_id)->fromArray($data); 578 $cart = new MailChimp_WooCommerce_Cart(); 579 return $cart->setStoreID($store_id)->fromArray($data); 572 580 } catch (MailChimp_WooCommerce_Error $e) { 573 581 if (!$silent) throw $e; … … 586 594 try { 587 595 $data = $this->get("ecommerce/stores/$store_id/carts/$id"); 588 return (new MailChimp_WooCommerce_Cart)->setStoreID($store_id)->fromArray($data); 596 $cart = new MailChimp_WooCommerce_Cart(); 597 return $cart->setStoreID($store_id)->fromArray($data); 589 598 } catch (MailChimp_WooCommerce_Error $e) { 590 599 return false; … … 619 628 $this->validateStoreSubmission($customer); 620 629 $data = $this->patch("ecommerce/stores/$store_id/customers/{$customer->getId()}", $customer->toArray()); 621 return (new MailChimp_WooCommerce_Customer)->fromArray($data); 630 $customer = new MailChimp_WooCommerce_Customer(); 631 return $customer->fromArray($data); 622 632 } catch (MailChimp_WooCommerce_Error $e) { 623 633 if (!$silent) throw $e; … … 656 666 $data = $this->post("ecommerce/stores/$store_id/orders", $order->toArray()); 657 667 update_option('mailchimp-woocommerce-resource-last-updated', time()); 658 return (new MailChimp_WooCommerce_Order)->fromArray($data); 668 $order = new MailChimp_WooCommerce_Order(); 669 return $order->fromArray($data); 659 670 } catch (\Exception $e) { 660 671 if (!$silent) throw $e; … … 679 690 $id = $order->getId(); 680 691 $data = $this->patch("ecommerce/stores/$store_id/orders/$id", $order->toArray()); 681 return (new MailChimp_WooCommerce_Order)->fromArray($data); 692 $order = new MailChimp_WooCommerce_Order(); 693 return $order->fromArray($data); 682 694 } catch (\Exception $e) { 683 695 if (!$silent) throw $e; … … 696 708 try { 697 709 $data = $this->get("ecommerce/stores/$store_id/orders/$order_id"); 698 return (new MailChimp_WooCommerce_Order)->fromArray($data); 710 $order = new MailChimp_WooCommerce_Order(); 711 return $order->fromArray($data); 699 712 } catch (MailChimp_WooCommerce_Error $e) { 700 713 return false; … … 726 739 try { 727 740 $data = $this->get("ecommerce/stores/$store_id/products/$product_id"); 728 return (new MailChimp_WooCommerce_Product)->fromArray($data); 741 $product = new MailChimp_WooCommerce_Product(); 742 return $product->fromArray($data); 729 743 } catch (MailChimp_WooCommerce_Error $e) { 730 744 return false; … … 762 776 $data = $this->post("ecommerce/stores/$store_id/products", $product->toArray()); 763 777 update_option('mailchimp-woocommerce-resource-last-updated', time()); 764 return (new MailChimp_WooCommerce_Product)->fromArray($data); 778 $product = new MailChimp_WooCommerce_Product(); 779 return $product->fromArray($data); 765 780 } catch (\Exception $e) { 766 781 if (!$silent) throw $e; -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-woocommerce-transform-orders.php
r1514325 r1582981 66 66 } 67 67 68 $order->setFulfillmentStatus($woo->get_status());69 68 $order->setProcessedAt(mailchimp_date_utc($woo->order_date)); 70 69 71 if ($woo->get_status() === 'cancelled') {72 $order->setCancelledAt(mailchimp_date_utc($woo->modified_date));73 }74 75 70 $order->setCurrencyCode($woo->get_order_currency()); 76 $order->setFinancialStatus($woo->is_paid() ? 'paid' : 'pending'); 77 71 72 // grab the current statuses - this will end up being custom at some point. 73 $statuses = $this->getOrderStatuses(); 74 75 // grab the order status 76 $status = $woo->get_status(); 77 78 // map the fulfillment and financial statuses based on the map above. 79 $fulfillment_status = array_key_exists($status, $statuses) ? $statuses[$status]->fulfillment : null; 80 $financial_status = array_key_exists($status, $statuses) ? $statuses[$status]->financial : $status; 81 82 // set the fulfillment_status 83 $order->setFulfillmentStatus($fulfillment_status); 84 85 // set the financial status 86 $order->setFinancialStatus($financial_status); 87 88 // only set this if the order is cancelled. 89 if ($status === 'cancelled') $order->setCancelledAt(mailchimp_date_utc($woo->modified_date)); 90 91 // set the total 78 92 $order->setOrderTotal($woo->get_total()); 79 93 … … 83 97 // if we have shipping. 84 98 $order->setShippingTotal($woo->get_total_shipping()); 99 100 // set the order discount 101 $order->setDiscountTotal($woo->get_total_discount()); 85 102 86 103 // set the customer … … 396 413 return $address; 397 414 } 415 416 /** 417 * @return array 418 */ 419 public function getOrderStatuses() 420 { 421 return array( 422 // Order received (unpaid) 423 'pending' => (object) array( 424 'financial' => 'pending', 425 'fulfillment' => null 426 ), 427 // Payment received and stock has been reduced – the order is awaiting fulfillment. 428 // All product orders require processing, except those for digital downloads 429 'processing' => (object) array( 430 'financial' => 'processing', 431 'fulfillment' => null 432 ), 433 // Awaiting payment – stock is reduced, but you need to confirm payment 434 'on-hold' => (object) array( 435 'financial' => 'on-hold', 436 'fulfillment' => null 437 ), 438 // Order fulfilled and complete – requires no further action 439 'completed' => (object) array( 440 'financial' => 'fulfilled', 441 'fulfillment' => 'fulfilled' 442 ), 443 // Cancelled by an admin or the customer – no further action required 444 'cancelled' => (object) array( 445 'financial' => 'cancelled', 446 'fulfillment' => null 447 ), 448 // Refunded by an admin – no further action required 449 'refunded' => (object) array( 450 'financial' => 'refunded', 451 'fulfillment' => null 452 ), 453 // Payment failed or was declined (unpaid). Note that this status may not show immediately and 454 // instead show as Pending until verified (i.e., PayPal) 455 'failed' => (object) array( 456 'financial' => 'failed', 457 'fulfillment' => null 458 ), 459 ); 460 } 398 461 } -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce-service.php
r1557758 r1582981 11 11 class MailChimp_Service extends MailChimp_Woocommerce_Options 12 12 { 13 protected static $pushed_orders = array(); 14 13 15 protected $user_email = null; 14 16 protected $previous_email = null; 15 17 protected $force_cart_post = false; 16 protected $pushed_orders = array();17 18 protected $cart_was_submitted = false; 18 19 protected $cart = array(); … … 55 56 56 57 /** 58 * This should only fire on a web based order so we can do real campaign tracking here. 59 * 57 60 * @param $order_id 58 61 */ 59 public function handleOrderStatusChanged($order_id)60 { 61 if ($this->hasOption('mailchimp_api_key') && !array_key_exists($order_id, $this->pushed_orders)) {62 public function onNewOrder($order_id) 63 { 64 if ($this->hasOption('mailchimp_api_key')) { 62 65 63 66 // register this order is already in process.. 64 $this->pushed_orders[$order_id] = true;67 static::$pushed_orders[$order_id] = true; 65 68 66 69 // see if we have a session id and a campaign id, also only do this when this user is not the admin. 67 70 $campaign_id = $this->getCampaignTrackingID(); 68 71 72 // grab the landing site cookie if we have one here. 73 $landing_site = $this->getLandingSiteCookie(); 74 75 // expire the landing site cookie so we can rinse and repeat tracking 76 $this->expireLandingSiteCookie(); 77 78 mailchimp_log('new_order', "New order #$order_id", array( 79 'campaign_id' => $campaign_id, 80 'landing_site' => $landing_site, 81 )); 82 69 83 // queue up the single order to be processed. 70 $handler = new MailChimp_WooCommerce_Single_Order($order_id, null, $campaign_id );84 $handler = new MailChimp_WooCommerce_Single_Order($order_id, null, $campaign_id, $landing_site); 71 85 wp_queue($handler); 72 86 } … … 74 88 75 89 /** 76 * @return bool|void 90 * @param $order_id 91 */ 92 public function handleOrderStatusChanged($order_id) 93 { 94 if ($this->hasOption('mailchimp_api_key')) { 95 96 // register this order is already in process.. 97 static::$pushed_orders[$order_id] = true; 98 99 // queue up the single order to be processed. 100 $handler = new MailChimp_WooCommerce_Single_Order($order_id, null, null, null); 101 $handler->is_update = true; 102 wp_queue($handler); 103 } 104 } 105 106 /** 107 * @return bool 77 108 */ 78 109 public function handleCartUpdated() … … 235 266 public function handleCampaignTracking() 236 267 { 268 // set the landing site cookie if we don't have one. 269 $this->setLandingSiteCookie(); 270 237 271 $cookie_duration = $this->getCookieDuration(); 238 272 … … 292 326 @setcookie('mailchimp_campaign_id', $cid, $cookie_duration, '/' ); 293 327 $this->setWooSession('mailchimp_campaign_id', $cid); 328 329 return $this; 330 } 331 332 /** 333 * @return mixed|null 334 */ 335 public function getLandingSiteCookie() 336 { 337 $cookie = $this->cookie('mailchimp_landing_site', false); 338 339 if (empty($cookie)) { 340 $cookie = $this->getWooSession('mailchimp_landing_site', false); 341 } 342 343 return $cookie; 344 } 345 346 /** 347 * @return $this 348 */ 349 public function setLandingSiteCookie() 350 { 351 if (isset($_GET['expire_landing_site'])) $this->expireLandingSiteCookie(); 352 353 // if we already have a cookie here, we need to skip it. 354 if ($this->getLandingSiteCookie() != false) return $this; 355 356 if (($http_referer = wp_get_raw_referer()) && !empty($http_referer)) { 357 358 // grab the current landing url since it's a referral. 359 $landing_site = home_url() . wp_unslash($_SERVER['REQUEST_URI']); 360 361 $compare_refer = str_replace(array('http://', 'https://'), '', $http_referer); 362 $compare_local = str_replace(array('http://', 'https://'), '', $landing_site); 363 364 if (strpos($compare_local, $compare_refer) === 0) return $this; 365 366 // set the cookie 367 @setcookie('mailchimp_landing_site', $landing_site, $this->getCookieDuration(), '/' ); 368 369 $this->setWooSession('mailchimp_landing_site', $landing_site); 370 } 371 372 return $this; 373 } 374 375 /** 376 * @return $this 377 */ 378 public function expireLandingSiteCookie() 379 { 380 @setcookie('mailchimp_landing_site', false, $this->getCookieDuration(), '/' ); 381 $this->setWooSession('mailchimp_landing_site', false); 294 382 295 383 return $this; … … 535 623 exit; 536 624 } 625 537 626 } -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce.php
r1557758 r1582981 326 326 327 327 // order hooks 328 $this->loader->add_action('woocommerce_api_create_order', $service, 'handleOrderStatusChanged');329 $this->loader->add_action('woocommerce_ thankyou', $service, 'handleOrderStatusChanged');330 $this->loader->add_action('woocommerce_order_status_changed', $service, 'handleOrderStatusChanged' );328 $this->loader->add_action('woocommerce_thankyou', $service, 'onNewOrder', 1); 329 $this->loader->add_action('woocommerce_api_create_order', $service, 'handleOrderStatusChanged', 10); 330 $this->loader->add_action('woocommerce_order_status_changed', $service, 'handleOrderStatusChanged', 2); 331 331 332 332 // cart hooks … … 390 390 return $this->version; 391 391 } 392 393 392 } -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-single-order.php
r1514325 r1582981 14 14 public $cart_session_id; 15 15 public $campaign_id; 16 public $landing_site; 17 public $is_update = false; 16 18 17 19 /** … … 20 22 * @param null $cart_session_id 21 23 * @param null $campaign_id 24 * @param null $landing_site 22 25 */ 23 public function __construct($order_id = null, $cart_session_id = null, $campaign_id = null )26 public function __construct($order_id = null, $cart_session_id = null, $campaign_id = null, $landing_site = null) 24 27 { 25 if (!empty($order_id)) { 26 $this->order_id = $order_id; 27 } 28 if (!empty($cart_session_id)) { 29 $this->cart_session_id = $cart_session_id; 30 } 31 if (!empty($campaign_id)) { 32 $this->campaign_id = $campaign_id; 33 } 28 if (!empty($order_id)) $this->order_id = $order_id; 29 if (!empty($cart_session_id)) $this->cart_session_id = $cart_session_id; 30 if (!empty($campaign_id)) $this->campaign_id = $campaign_id; 31 if (!empty($landing_site)) $this->landing_site = $landing_site; 34 32 } 35 33 … … 40 38 { 41 39 $this->process(); 42 43 40 return false; 44 41 } … … 58 55 $job->campaign_id = $this->campaign_id; 59 56 60 $call = $api->getStoreOrder($store_id, $this->order_id) ? 'updateStoreOrder' : 'addStoreOrder'; 57 $call = ($api_response = $api->getStoreOrder($store_id, $this->order_id)) ? 'updateStoreOrder' : 'addStoreOrder'; 58 59 if ($call === 'addStoreOrder' && $this->is_update === true) { 60 return false; 61 } 61 62 62 63 // if we already pushed this order into the system, we need to unset it now just in case there … … 64 65 if ($call === 'updateStoreOrder') { 65 66 $job->campaign_id = null; 67 $this->campaign_id = null; 68 $this->landing_site = null; 66 69 } 67 70 … … 77 80 $log = "$call :: #{$order->getId()} :: email: {$order->getCustomer()->getEmailAddress()}"; 78 81 79 if (!empty($this->campaign_id) && $call === 'addStoreOrder') { 80 $log .= ' :: campaign id '.$this->campaign_id; 81 $order->setCampaignId($this->campaign_id); 82 // only do this stuff on new orders 83 if ($call === 'addStoreOrder') { 84 85 // apply a campaign id if we have one. 86 if (!empty($this->campaign_id)) { 87 $log .= ' :: campaign id ' . $this->campaign_id; 88 $order->setCampaignId($this->campaign_id); 89 } 90 91 // apply the landing site if we have one. 92 if (!empty($this->landing_site)) { 93 $log .= ' :: landing site ' . $this->landing_site; 94 $order->setLandingSite($this->landing_site); 95 } 96 82 97 } 83 98 … … 148 163 } 149 164 } 165 -
mailchimp-for-woocommerce/trunk/mailchimp-woocommerce.php
r1557758 r1582981 17 17 * Plugin URI: https://mailchimp.com/connect-your-store/ 18 18 * Description: MailChimp - WooCommerce plugin 19 * Version: 1.0. 7019 * Version: 1.0.8 20 20 * Author: MailChimp 21 21 * Author URI: https://mailchimp.com … … 40 40 'repo' => 'master', 41 41 'environment' => 'production', 42 'version' => '1.0. 70',42 'version' => '1.0.8', 43 43 'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version), 44 44 ); … … 350 350 } 351 351 352 function mailchimp_woocommerce_add_meta_tags() { 353 echo '<meta name="referrer" content="always"/>'; 354 } 355 356 add_action('wp_head', 'mailchimp_woocommerce_add_meta_tags'); 357 352 358 /** Add the plugin updater function ONLY when they are logged in as admin. */ 353 359 add_action('admin_init', 'run_mailchimp_plugin_updater'); … … 355 361 /** Add all the MailChimp hooks. */ 356 362 run_mailchimp_woocommerce(); 363 364
Note: See TracChangeset
for help on using the changeset viewer.