Changeset 1762067
- Timestamp:
- 11/09/2017 03:59:40 PM (8 years ago)
- Location:
- mailchimp-for-woocommerce/trunk
- Files:
-
- 5 added
- 22 edited
-
README.md (modified) (3 diffs)
-
README.txt (modified) (3 diffs)
-
admin/class-mailchimp-woocommerce-admin.php (modified) (1 diff)
-
admin/partials/mailchimp-woocommerce-admin-tabs.php (modified) (1 diff)
-
admin/partials/tabs/logs.php (modified) (1 diff)
-
includes/api/assets/class-mailchimp-order.php (modified) (5 diffs)
-
includes/api/assets/class-mailchimp-promo-code.php (added)
-
includes/api/assets/class-mailchimp-promo-rule.php (added)
-
includes/api/class-mailchimp-api.php (modified) (1 diff)
-
includes/api/class-mailchimp-woocommerce-api.php (modified) (2 diffs)
-
includes/api/class-mailchimp-woocommerce-transform-coupons.php (added)
-
includes/api/class-mailchimp-woocommerce-transform-orders.php (modified) (1 diff)
-
includes/api/class-mailchimp-woocommerce-transform-products.php (modified) (2 diffs)
-
includes/class-mailchimp-woocommerce-options.php (modified) (1 diff)
-
includes/class-mailchimp-woocommerce-service.php (modified) (3 diffs)
-
includes/class-mailchimp-woocommerce.php (modified) (6 diffs)
-
includes/processes/class-mailchimp-woocommerce-abstract-sync.php (modified) (1 diff)
-
includes/processes/class-mailchimp-woocommerce-cart-update.php (modified) (5 diffs)
-
includes/processes/class-mailchimp-woocommerce-process-coupons.php (added)
-
includes/processes/class-mailchimp-woocommerce-process-orders.php (modified) (2 diffs)
-
includes/processes/class-mailchimp-woocommerce-process-products.php (modified) (1 diff)
-
includes/processes/class-mailchimp-woocommerce-single-coupon.php (added)
-
includes/processes/class-mailchimp-woocommerce-single-order.php (modified) (5 diffs)
-
includes/processes/class-mailchimp-woocommerce-single-product.php (modified) (1 diff)
-
includes/processes/class-mailchimp-woocommerce-user-submit.php (modified) (1 diff)
-
includes/vendor/queue/classes/worker/wp-worker.php (modified) (1 diff)
-
mailchimp-woocommerce.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mailchimp-for-woocommerce/trunk/README.md
r1735785 r1762067 11 11 - This plugin requires you to have the [WooCommerce plugin](https://wordpress.org/plugins/woocommerce) already installed and activated in WordPress. 12 12 13 - Your host environment must meet [WooCommerce's minimum requirements](https://docs.woocommerce.com/document/server-requirements), including PHP 5.6or greater.13 - Your host environment must meet [WooCommerce's minimum requirements](https://docs.woocommerce.com/document/server-requirements), including PHP 7.0 or greater. 14 14 15 15 - We recommend you use this plugin in a staging environment before installing it on production servers. … … 60 60 1) On the **Connect** tab, paste your MailChimp API key into the field, choose whether or not you want to send debugging logs to MailChimp, and click **Save all changes**. To learn how to generate a MailChimp API Key, read [About API Keys](http://kb.mailchimp.com/integrations/api-integrations/about-api-keys). 61 61 62 62  63 63 64 64 2) Navigate to the **Store Settings** tab. … … 68 68 3) Enter the contact and location details for your WooCommerce Store, and click **Save all changes**. 69 69 70 ![Save all changes] (https://cloud.githubusercontent.com/assets/6547700/18677996/a76d126c-7f28-11e6-9150-4b289d20f057.png)70  71 71 72 72 4) Navigate to the **List Settings** tab. 73 73 74 ![List Settings tab] (https://cloud.githubusercontent.com/assets/19805049/18878446/961221d0-849e-11e6-99bb-175c22bf921e.png)74  75 75 76 76 5) Choose the list you want to sync, decide whether or not you want to auto-subscribe existing customers, set the subscribe message you want customers to see at checkout, and click **Save all changes**. -
mailchimp-for-woocommerce/trunk/README.txt
r1741630 r1762067 23 23 - Grow your audience and sell more stuff with Facebook and Instagram Ad Campaigns in MailChimp. 24 24 - Automatically embed a pop-up form that converts your website visitors to subscribers. 25 - Add discount codes created in WooCommerce to your emails and automations with a Promo Code content block 25 26 26 27 ###A note for current WooCommerce integration users … … 34 35 35 36 - This plugin requires you to have the [WooCommerce plugin](https://woocommerce.com/) already installed and activated in WordPress. 36 - Your hosting environment must meet [WooCommerce's minimum requirements](https://docs.woocommerce.com/document/server-requirements), including PHP 5.6or greater.37 - Your hosting environment must meet [WooCommerce's minimum requirements](https://docs.woocommerce.com/document/server-requirements), including PHP 7.0 or greater. 37 38 - We recommend you use this plugin in a staging environment before installing it on production servers. To learn more about staging environments, [check out these related Wordpress plugins](https://wordpress.org/plugins/search.php?q=staging). 38 39 - MailChimp for WooCommerce syncs the customer’s first name, last name, email address, and orders. … … 50 51 51 52 == Changelog == 53 54 = 2.1.0 = 55 * Added Promo Code support. 52 56 53 57 = 2.0.2 = -
mailchimp-for-woocommerce/trunk/admin/class-mailchimp-woocommerce-admin.php
r1735785 r1762067 885 885 private function startSync() 886 886 { 887 $coupon_sync = new MailChimp_WooCommerce_Process_Coupons(); 888 wp_queue($coupon_sync); 889 887 890 $job = new MailChimp_WooCommerce_Process_Products(); 888 891 $job->flagStartSync(); -
mailchimp-for-woocommerce/trunk/admin/partials/mailchimp-woocommerce-admin-tabs.php
r1735785 r1762067 61 61 </style> 62 62 63 <?php if (!defined('PHP_VERSION_ID') || (PHP_VERSION_ID < 50600)): ?>63 <?php if (!defined('PHP_VERSION_ID') || (PHP_VERSION_ID < 70000)): ?> 64 64 <div data-dismissible="notice-php-version" class="error notice notice-error is-dismissible"> 65 <p><?php _e('MailChimp says: Please upgrade your PHP version to a minimum of 5.6', 'mailchimp-woocommerce'); ?></p>65 <p><?php _e('MailChimp says: Please upgrade your PHP version to a minimum of 7.0', 'mailchimp-woocommerce'); ?></p> 66 66 </div> 67 67 <?php endif; ?> -
mailchimp-for-woocommerce/trunk/admin/partials/tabs/logs.php
r1735785 r1762067 4 4 $log_handler = new WC_Log_Handler_File(); 5 5 $log_handler->remove($_REQUEST['handle']); 6 wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=logs'); 6 7 } 7 8 } -
mailchimp-for-woocommerce/trunk/includes/api/assets/class-mailchimp-order.php
r1709699 r1762067 30 30 protected $lines = array(); 31 31 protected $confirm_and_paid = false; 32 protected $promos = []; 32 33 33 34 /** … … 126 127 127 128 /** 129 * @param $code 130 * @param $amount 131 * @param bool $is_percentage 132 * @return $this 133 */ 134 public function addDiscount($code, $amount, $is_percentage = false) 135 { 136 $this->promos[] = [ 137 'code' => $code, 138 'amount_discounted' => $amount, 139 'type' => $is_percentage ? 'percent' : 'fixed' 140 ]; 141 142 return $this; 143 } 144 145 /** 128 146 * @return array 129 147 */ 148 public function discounts() 149 { 150 return $this->promos; 151 } 152 153 /** 154 * @return array 155 */ 130 156 public function items() 131 157 { … … 162 188 /** 163 189 * @param null $financial_status 164 * @return Order190 * @return MailChimp_WooCommerce_Order 165 191 */ 166 192 public function setFinancialStatus($financial_status) … … 448 474 'shipping_address' => $this->getShippingAddress()->toArray(), 449 475 'billing_address' => $this->getBillingAddress()->toArray(), 476 'promos' => !empty($this->promos) ? $this->promos : null, 450 477 'lines' => array_map(function ($item) { 451 478 /** @var MailChimp_WooCommerce_LineItem $item */ … … 481 508 $billing = new MailChimp_WooCommerce_Address(); 482 509 $this->billing_address = $billing->fromArray($data['billing_address']); 510 } 511 512 if (array_key_exists('promos', $data)) { 513 $this->promos = $data['promos']; 483 514 } 484 515 -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-api.php
r1735785 r1762067 837 837 $this->delete("ecommerce/stores/$store_id/products/$product_id"); 838 838 return true; 839 } catch (MailChimp_WooCommerce_Error $e) { 840 return false; 841 } 842 } 843 844 845 /** 846 * @param $store_id 847 * @param MailChimp_WooCommerce_PromoRule $rule 848 * @param bool $throw 849 * @return MailChimp_WooCommerce_PromoRule|bool 850 * @throws MailChimp_WooCommerce_Error 851 */ 852 public function addPromoRule($store_id, MailChimp_WooCommerce_PromoRule $rule, $throw = true) 853 { 854 try { 855 if (($response = $this->updatePromoRule($store_id, $rule, false))) { 856 return $response; 857 } 858 $data = $this->post("ecommerce/stores/{$store_id}/promo-rules", $rule->toArray()); 859 return (new MailChimp_WooCommerce_PromoRule)->fromArray($data); 860 } catch (MailChimp_WooCommerce_Error $e) { 861 if ($throw) throw $e; 862 return false; 863 } 864 } 865 866 /** 867 * @param $store_id 868 * @param MailChimp_WooCommerce_PromoRule $rule 869 * @param bool $throw 870 * @return MailChimp_WooCommerce_PromoRule|bool 871 * @throws MailChimp_WooCommerce_Error 872 */ 873 public function updatePromoRule($store_id, MailChimp_WooCommerce_PromoRule $rule, $throw = true) 874 { 875 try { 876 $data = $this->patch("ecommerce/stores/{$store_id}/promo-rules/{$rule->getId()}", $rule->toArray()); 877 return (new MailChimp_WooCommerce_PromoRule)->fromArray($data); 878 } catch (MailChimp_WooCommerce_Error $e) { 879 if ($throw) throw $e; 880 return false; 881 } 882 } 883 884 /** 885 * @param $store_id 886 * @param MailChimp_WooCommerce_PromoRule|int $rule 887 * @return bool 888 */ 889 public function deletePromoRule($store_id, $rule) 890 { 891 try { 892 $id = $rule instanceof MailChimp_WooCommerce_PromoRule ? $rule->getId() : $rule; 893 //print_r(array('id' => $id, 'store' => $store_id));die(); 894 return (bool) $this->delete("ecommerce/stores/{$store_id}/promo-rules/{$id}"); 895 } catch (MailChimp_WooCommerce_Error $e) { 896 //\Log::error("MC::deletePromoRule :: {$rule->getId()} :: {$e->getMessage()} on {$e->getLine()} in {$e->getFile()}"); 897 return false; 898 } 899 } 900 901 /** 902 * @param $store_id 903 * @param int $page 904 * @param int $count 905 * @return array 906 */ 907 public function getPromoRuleIds($store_id, $page = 1, $count = 10) 908 { 909 $result = $this->get("ecommerce/stores/{$store_id}/promo-rules", [ 910 'start' => $page, 911 'count' => $count, 912 'offset' => $page > 1 ? (($page-1) * $count) : 0, 913 'include' => 'id', 914 ]); 915 916 $ids = array(); 917 foreach ($result['promo_rules'] as $rule) { 918 $id = (string) $rule['id']; 919 $ids[$id] = $id; 920 } 921 return $ids; 922 } 923 924 /** 925 * @param $store_id 926 * @param int $page 927 * @param int $count 928 * @param bool $return_original 929 * @return array 930 */ 931 public function getPromoRules($store_id, $page = 1, $count = 10, $return_original = false) 932 { 933 $result = $this->get("ecommerce/stores/{$store_id}/promo-rules", [ 934 'start' => $page, 935 'count' => $count, 936 'offset' => $page > 1 ? (($page-1) * $count) : 0, 937 ]); 938 939 if ($return_original) { 940 return $result; 941 } 942 943 $rules = array(); 944 foreach ($result['promo_rules'] as $rule_data) { 945 $rule = new MailChimp_WooCommerce_PromoRule(); 946 $rule->fromArray($rule_data); 947 $rules[] = $rule; 948 } 949 return $rules; 950 } 951 952 /** 953 * @param $store_id 954 * @param $rule_id 955 * @param int $page 956 * @param int $count 957 * @param bool $return_original 958 * @return array 959 */ 960 public function getPromoCodesForRule($store_id, $rule_id, $page = 1, $count = 10, $return_original = false) 961 { 962 $result = $this->get("ecommerce/stores/{$store_id}/promo-rules/{$rule_id}/promo_codes", [ 963 'start' => $page, 964 'count' => $count, 965 'offset' => $page > 1 ? (($page-1) * $count) : 0, 966 ]); 967 968 if ($return_original) { 969 return $result; 970 } 971 972 $rules = array(); 973 foreach ($result as $rule_data) { 974 $rule = new MailChimp_WooCommerce_PromoCode(); 975 $rule->fromArray($rule_data); 976 $rules[] = $rule; 977 } 978 return $rules; 979 } 980 981 /** 982 * @param $store_id 983 * @param $rule_id 984 * @param $code_id 985 * 986 * @return MailChimp_WooCommerce_PromoCode|bool 987 */ 988 public function getPromoCodeForRule($store_id, $rule_id, $code_id) 989 { 990 try { 991 $data = $this->get("ecommerce/stores/{$store_id}/promo-rules/{$rule_id}/promo-codes/{$code_id}"); 992 return (new MailChimp_WooCommerce_PromoCode)->fromArray($data); 993 } catch (MailChimp_WooCommerce_Error $e) { 994 return false; 995 } 996 } 997 998 /** 999 * @param $store_id 1000 * @param MailChimp_WooCommerce_PromoRule $rule 1001 * @param MailChimp_WooCommerce_PromoCode $code 1002 * @param bool $throw 1003 * @return MailChimp_WooCommerce_PromoCode|bool 1004 * @throws MailChimp_WooCommerce_Error 1005 */ 1006 public function addPromoCodeForRule($store_id, MailChimp_WooCommerce_PromoRule $rule, MailChimp_WooCommerce_PromoCode $code, $throw = true) 1007 { 1008 try { 1009 if (($result = $this->updatePromoCodeForRule($store_id, $rule, $code, false))) { 1010 return $result; 1011 } 1012 $data = $this->post("ecommerce/stores/{$store_id}/promo-rules/{$rule->getId()}/promo-codes", $code->toArray()); 1013 return (new MailChimp_WooCommerce_PromoCode)->fromArray($data); 1014 } catch (MailChimp_WooCommerce_Error $e) { 1015 if ($throw) throw $e; 1016 return false; 1017 } 1018 } 1019 1020 /** 1021 * @param $store_id 1022 * @param MailChimp_WooCommerce_PromoRule $rule 1023 * @param MailChimp_WooCommerce_PromoCode $code 1024 * @param bool $throw 1025 * @return MailChimp_WooCommerce_PromoCode|bool 1026 * @throws MailChimp_WooCommerce_Error 1027 */ 1028 public function updatePromoCodeForRule($store_id, MailChimp_WooCommerce_PromoRule $rule, MailChimp_WooCommerce_PromoCode $code, $throw = true) 1029 { 1030 try { 1031 $data = $this->patch("ecommerce/stores/{$store_id}/promo-rules/{$rule->getId()}/promo-codes/{$code->getId()}", $code->toArray()); 1032 return (new MailChimp_WooCommerce_PromoCode)->fromArray($data); 1033 } catch (MailChimp_WooCommerce_Error $e) { 1034 if ($throw) throw $e; 1035 return false; 1036 } 1037 } 1038 1039 /** 1040 * @param $store_id 1041 * @param $rule_id 1042 * @param $code_id 1043 * @return bool 1044 */ 1045 public function deletePromoCodeForRule($store_id, $rule_id, $code_id) 1046 { 1047 try { 1048 return (bool) $this->delete("ecommerce/stores/{$store_id}/promo-rules/{$rule_id}/promo-codes/{$code_id}"); 839 1049 } catch (MailChimp_WooCommerce_Error $e) { 840 1050 return false; -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-woocommerce-api.php
r1639952 r1762067 82 82 /** 83 83 * @param $resource 84 * @return bool|MailChimp_WooCommerce_Transform_Orders|MailChimp_WooCommerce_Transform_Products 84 * @return bool|MailChimp_WooCommerce_Transform_Orders|MailChimp_WooCommerce_Transform_Products|MailChimp_WooCommerce_Transform_Coupons 85 85 */ 86 86 public function engine($resource) … … 93 93 return new MailChimp_WooCommerce_Transform_Orders(); 94 94 break; 95 95 case 'coupons': 96 return new MailChimp_WooCommerce_Transform_Coupons(); 96 97 default: 97 98 return false; -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-woocommerce-transform-orders.php
r1735785 r1762067 169 169 } 170 170 171 // apply the coupon discounts 172 if (($used_coupons = $woo->get_used_coupons()) && is_array($used_coupons)) { 173 foreach ($used_coupons as $coupon_code) { 174 if (($coupon_id = wc_get_coupon_id_by_code($coupon_code))) { 175 $coupon = new WC_Coupon($coupon_id); 176 $is_percentage = $coupon->get_discount_type() === 'percent'; 177 $order->addDiscount($coupon_code, $coupon->get_amount('edit'), $is_percentage); 178 } 179 } 180 } 181 171 182 //if (($refund = $woo->get_total_refunded()) && $refund > 0){ 172 183 // this is where we would be altering the submission to tell us about the refund. -
mailchimp-for-woocommerce/trunk/includes/api/class-mailchimp-woocommerce-transform-products.php
r1639952 r1762067 45 45 public function transform(WP_Post $post) 46 46 { 47 $woo = new WC_Product($post);47 $woo = wc_get_product($post); 48 48 49 49 $variant_posts = $this->getProductVariantPosts($post->ID); … … 99 99 $woo = new WC_Product_Variation($post->ID); 100 100 } else { 101 $woo = new WC_Product($post);101 $woo = wc_get_product($post); 102 102 } 103 103 } -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce-options.php
r1639952 r1762067 29 29 if (get_option('mailchimp_woocommerce_plugin_do_activation_redirect', false)) { 30 30 delete_option('mailchimp_woocommerce_plugin_do_activation_redirect'); 31 32 // don't do the redirect while activating the plugin through the rest API. ( Bartosz from Woo asked for this ) 33 if ((defined( 'REST_REQUEST' ) && REST_REQUEST)) { 34 return; 35 } 36 31 37 if (!isset($_GET['activate-multi'])) { 32 38 wp_redirect("options-general.php?page=mailchimp-woocommerce"); -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce-service.php
r1735785 r1762067 96 96 { 97 97 if ($this->hasOption('mailchimp_api_key')) { 98 99 98 // register this order is already in process.. 100 99 static::$pushed_orders[$order_id] = true; 101 102 100 // queue up the single order to be processed. 103 101 $handler = new MailChimp_WooCommerce_Single_Order($order_id, null, null, null); … … 168 166 169 167 return false; 168 } 169 170 /** 171 * @param $post_id 172 */ 173 public function handleNewCoupon($post_id) 174 { 175 $this->handleCouponSaved($post_id, new WC_Coupon($post_id)); 176 } 177 178 /** 179 * @param $post_id 180 * @param null $coupon 181 */ 182 public function handleCouponSaved($post_id, $coupon = null) 183 { 184 if ($coupon instanceof WC_Coupon) { 185 wp_queue(new MailChimp_WooCommerce_SingleCoupon($post_id)); 186 } 187 } 188 189 /** 190 * @param $post_id 191 */ 192 public function handleCouponRestored($post_id) 193 { 194 $this->handleCouponSaved($post_id, new WC_Coupon($post_id)); 170 195 } 171 196 … … 185 210 $this->handleOrderStatusChanged($post_id); 186 211 } 212 } 213 } 214 215 /** 216 * @param $post_id 217 * @return bool 218 */ 219 public function handlePostTrashed($post_id) 220 { 221 if (!$this->hasOption('mailchimp_api_key')) { 222 return false; 223 } 224 225 switch (get_post_type($post_id)) { 226 case 'shop_coupon': 227 mailchimp_get_api()->deletePromoRule(mailchimp_get_store_id(), $post_id); 228 mailchimp_log('promo_code.deleted', "deleted promo code {$post_id}"); 229 break; 230 } 231 } 232 233 /** 234 * @param $post_id 235 */ 236 public function handlePostRestored($post_id) 237 { 238 switch(get_post_type($post_id)) { 239 case 'shop_coupon': 240 return $this->handleCouponRestored($post_id); 241 break; 187 242 } 188 243 } -
mailchimp-for-woocommerce/trunk/includes/class-mailchimp-woocommerce.php
r1639952 r1762067 175 175 require_once $path . 'includes/api/class-mailchimp-woocommerce-create-list-submission.php'; 176 176 require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-products.php'; 177 require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-coupons.php'; 177 178 178 179 /** Require all the mailchimp api asset classes */ … … 185 186 require_once $path . 'includes/api/assets/class-mailchimp-product-variation.php'; 186 187 require_once $path . 'includes/api/assets/class-mailchimp-store.php'; 188 require_once $path . 'includes/api/assets/class-mailchimp-promo-code.php'; 189 require_once $path . 'includes/api/assets/class-mailchimp-promo-rule.php'; 187 190 188 191 /** Require all the api error helpers */ … … 205 208 require_once $path.'includes/processes/class-mailchimp-woocommerce-process-orders.php'; 206 209 require_once $path.'includes/processes/class-mailchimp-woocommerce-process-products.php'; 210 require_once $path.'includes/processes/class-mailchimp-woocommerce-process-coupons.php'; 207 211 208 212 // individual item sync … … 210 214 require_once $path.'includes/processes/class-mailchimp-woocommerce-single-order.php'; 211 215 require_once $path.'includes/processes/class-mailchimp-woocommerce-single-product.php'; 212 require_once $path.'includes/processes/class-mailchimp-woocommerce-user-submit.php'; 216 require_once $path.'includes/processes/class-mailchimp-woocommerce-single-coupon.php'; 217 require_once $path.'includes/processes/class-mailchimp-woocommerce-user-submit.php'; 213 218 214 219 // fire up the loader … … 326 331 // order hooks 327 332 $this->loader->add_action('woocommerce_thankyou', $service, 'onNewOrder', 1); 328 $this->loader->add_action('woocommerce_api_create_order', $service, ' handleOrderStatusChanged', 10);333 $this->loader->add_action('woocommerce_api_create_order', $service, 'onNewOrder', 10); 329 334 $this->loader->add_action('woocommerce_order_status_changed', $service, 'handleOrderStatusChanged', 2); 330 335 … … 337 342 $this->loader->add_action('woocommerce_cart_item_removed', $service, 'handleCartUpdated'); 338 343 339 // save post hook for products344 // save post hooks 340 345 $this->loader->add_action('save_post', $service, 'handlePostSaved', 10, 3); 346 $this->loader->add_action('wp_trash_post', $service, 'handlePostTrashed', 10); 347 $this->loader->add_action('untrashed_post', $service, 'handlePostRestored', 10); 348 349 //coupons 350 $this->loader->add_action('woocommerce_new_coupon', $service, 'handleNewCoupon', 10); 351 $this->loader->add_action('woocommerce_coupon_options_save', $service, 'handleCouponSaved', 10, 2); 352 $this->loader->add_action('woocommerce_api_create_coupon', $service, 'handleCouponSaved', 9, 2); 353 354 $this->loader->add_action('woocommerce_delete_coupon', $service, 'handleCouponTrashed', 10); 355 $this->loader->add_action('woocommerce_trash_coupon', $service, 'handleCouponTrashed', 10); 356 $this->loader->add_action('woocommerce_api_delete_coupon', $service, 'handleCouponTrashed', 9); 341 357 342 358 // handle the user registration hook -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-abstract-sync.php
r1735785 r1762067 103 103 if ($page->count <= 0) { 104 104 105 mailchimp_debug(get_called_class().'@handle', $this->getResourceType().' :: co unt is 0 : completing now!');105 mailchimp_debug(get_called_class().'@handle', $this->getResourceType().' :: completing now!'); 106 106 107 107 // reset the resource page back to 1 -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-cart-update.php
r1735785 r1762067 126 126 } catch (\Exception $e) { 127 127 128 mailchimp_ log('abandoned_cart.error', "email: {$customer->getEmailAddress()}");128 mailchimp_error('abandoned_cart.error', "email: {$customer->getEmailAddress()} :: attempting product update :: {$e->getMessage()}"); 129 129 130 130 // if we have an error it's most likely due to a product not being found. … … 139 139 } 140 140 141 mailchimp_log('abandoned_cart.submitting', "email: {$customer->getEmailAddress()}");142 143 141 // if the post is successful we're all good. 144 142 $api->addCart($store_id, $cart, false); … … 150 148 } catch (\Exception $e) { 151 149 update_option('mailchimp-woocommerce-cart-error', $e->getMessage()); 152 mailchimp_ log('abandoned_cart.error', "{$e->getMessage()} on {$e->getLine()} in {$e->getFile()}");150 mailchimp_error('abandoned_cart.error', $e); 153 151 } 154 152 … … 163 161 protected function transformLineItem($hash, $item) 164 162 { 165 $product = new WC_Product($item['product_id']); 163 $product = wc_get_product($item['product_id']); 164 $price = $product ? $product->get_price() : 0; 166 165 167 166 $line = new MailChimp_WooCommerce_LineItem(); … … 176 175 177 176 $line->setQuantity($item['quantity']); 178 $line->setPrice($pr oduct->get_price());177 $line->setPrice($price); 179 178 180 179 return $line; -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-process-orders.php
r1735785 r1762067 57 57 58 58 if (empty($response)) { 59 mailchimp_ log('order_submit.failure', "$call :: #{$item->getId()} :: email: {$item->getCustomer()->getEmailAddress()} produced a blank response from MailChimp");59 mailchimp_error('order_submit.failure', "$call :: #{$item->getId()} :: email: {$item->getCustomer()->getEmailAddress()} produced a blank response from MailChimp"); 60 60 return $response; 61 61 } … … 68 68 69 69 } catch (MailChimp_WooCommerce_ServerError $e) { 70 mailchimp_ log('order_submit.error', "$call :: {$item->getId()} :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}");70 mailchimp_error('order_submit.error', mailchimp_error_trace($e, "$call :: {$item->getId()}")); 71 71 return false; 72 72 } catch (MailChimp_WooCommerce_Error $e) { 73 mailchimp_ log('order_submit.error', "$call :: {$item->getId()} :: MailChimp_WooCommerce_Error :: {$e->getMessage()}");73 mailchimp_error('order_submit.error', mailchimp_error_trace($e, "$call :: {$item->getId()}")); 74 74 return false; 75 75 } catch (Exception $e) { 76 mailchimp_ log('order_submit.error', "$call :: {$item->getId()} :: Uncaught Exception :: {$e->getMessage()}");76 mailchimp_error('order_submit.error', mailchimp_error_trace($e, "$call :: {$item->getId()}")); 77 77 return false; 78 78 } -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-process-products.php
r1735785 r1762067 57 57 58 58 } catch (MailChimp_WooCommerce_ServerError $e) { 59 mailchimp_ log('product_sync.error', "addStoreProduct :: {$item->getId()} :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}");59 mailchimp_error('product_sync.error', mailchimp_error_trace($e, "addStoreProduct :: {$item->getId()}")); 60 60 } catch (MailChimp_WooCommerce_Error $e) { 61 mailchimp_ log('product_sync.error', "addStoreProduct :: {$item->getId()} :: MailChimp_WooCommerce_Error :: {$e->getMessage()}");61 mailchimp_error('product_sync.error', mailchimp_error_trace($e, "addStoreProduct :: {$item->getId()}")); 62 62 } catch (Exception $e) { 63 mailchimp_ log('product_sync.error', "addStoreProduct :: {$item->getId()} :: Uncaught Exception :: {$e->getMessage()}");63 mailchimp_error('product_sync.error', mailchimp_error_trace($e, "addStoreProduct :: {$item->getId()}")); 64 64 } 65 65 } -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-single-order.php
r1735785 r1762067 52 52 53 53 if (!($woo_order_number = $this->getRealOrderNumber())) { 54 mailchimp_log('order_submit.failure', "There is no real order number to use."); 54 55 return false; 55 56 } … … 118 119 119 120 if (empty($api_response)) { 120 mailchimp_ log('order_submit.failure', "$call :: #{$order->getId()} :: email: {$order->getCustomer()->getEmailAddress()} produced a blank response from MailChimp");121 mailchimp_error('order_submit.failure', "$call :: #{$order->getId()} :: email: {$order->getCustomer()->getEmailAddress()} produced a blank response from MailChimp"); 121 122 return $api_response; 122 123 } … … 134 135 } catch (\Exception $e) { 135 136 136 mailchimp_log('order_submit.tracing_error', $message = strtolower($e->getMessage())); 137 $message = strtolower($e->getMessage()); 138 139 mailchimp_error('order_submit.tracing_error', $e); 137 140 138 141 if (!isset($order)) { … … 171 174 172 175 } catch (\Exception $e) { 173 mailchimp_ log('order_submit.error', 'deleting-customer-re-add :: #'.$this->order_id.' :: '.$e->getMessage());176 mailchimp_error('order_submit.error', mailchimp_error_trace($e, 'deleting-customer-re-add :: #'.$this->order_id)); 174 177 } 175 178 } … … 193 196 } catch (\Exception $e) { 194 197 $this->woo_order_number = false; 195 mailchimp_ log('order_sync.failure', "{$this->order_id} could not be loaded {$e->getMessage()}");198 mailchimp_error('order_sync.failure', mailchimp_error_trace($e, "{$this->order_id} could not be loaded")); 196 199 return false; 197 200 } -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-single-product.php
r1735785 r1762067 69 69 70 70 } catch (MailChimp_WooCommerce_ServerError $e) { 71 mailchimp_ log('product_submit.error', "addStoreProduct :: #{$this->product_id} :: MailChimp_WooCommerce_ServerError :: {$e->getMessage()}");71 mailchimp_error('product_submit.error', mailchimp_error_trace($e, "addStoreProduct :: #{$this->product_id}")); 72 72 } catch (MailChimp_WooCommerce_Error $e) { 73 mailchimp_log('product_submit.error', "addStoreProduct :: #{$this->product_id} :: MailChimp_WooCommerce_Error :: {$e->getMessage()}");73 mailchimp_log('product_submit.error', mailchimp_error_trace($e, "addStoreProduct :: #{$this->product_id}")); 74 74 } catch (Exception $e) { 75 mailchimp_log('product_submit.error', "addStoreProduct :: #{$this->product_id} :: Uncaught Exception :: {$e->getMessage()}");75 mailchimp_log('product_submit.error', mailchimp_error_trace($e, "addStoreProduct :: #{$this->product_id}")); 76 76 } 77 77 -
mailchimp-for-woocommerce/trunk/includes/processes/class-mailchimp-woocommerce-user-submit.php
r1735785 r1762067 136 136 } 137 137 138 mailchimp_ log('member.sync', $e->getMessage());138 mailchimp_error('member.sync', mailchimp_error_trace($e, $user->user_email)); 139 139 } 140 140 -
mailchimp-for-woocommerce/trunk/includes/vendor/queue/classes/worker/wp-worker.php
r1735785 r1762067 55 55 56 56 try { 57 $this->payload->handle();57 $this->payload->handle(); 58 58 59 59 if ( $this->payload->is_released() ) { -
mailchimp-for-woocommerce/trunk/mailchimp-woocommerce.php
r1735785 r1762067 17 17 * Plugin URI: https://mailchimp.com/connect-your-store/ 18 18 * Description: MailChimp - WooCommerce plugin 19 * Version: 2. 0.219 * Version: 2.1.0 20 20 * Author: MailChimp 21 21 * Author URI: https://mailchimp.com … … 44 44 'repo' => 'master', 45 45 'environment' => 'production', 46 'version' => '2. 0.2',46 'version' => '2.1.0', 47 47 'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version), 48 48 'wc_version' => class_exists('WC') ? WC()->version : null, … … 270 270 271 271 /** 272 * @param $action 273 * @param $message 274 * @param array $data 275 * @return array|WP_Error 276 */ 277 function mailchimp_error($action, $message, $data = array()) { 278 if (mailchimp_environment_variables()->logging !== 'none') { 279 if ($message instanceof \Exception) $message = mailchimp_error_trace($message); 280 if (is_array($data) && !empty($data)) $message .= " :: ".wc_print_r($data, true); 281 wc_get_logger()->error("{$action} :: {$message}", array('source' => 'mailchimp_woocommerce')); 282 } 283 } 284 285 /** 286 * @param Exception $e 287 * @param string $wrap 288 * @return string 289 */ 290 function mailchimp_error_trace(\Exception $e, $wrap = "") { 291 $error = "{$e->getMessage()} on {$e->getLine()} in {$e->getFile()}"; 292 if (empty($wrap)) return $error; 293 return "{$wrap} :: {$error}"; 294 } 295 296 /** 272 297 * Determine if a given string contains a given substring. 273 298 * … … 341 366 if (($store = $api->getStore($store_id))) { 342 367 368 // handle the coupon sync if we don't have a flag that says otherwise. 369 $job = new MailChimp_WooCommerce_Process_Coupons(); 370 if ($job->getData('sync.coupons.completed_at', false) === false) { 371 wp_queue($job); 372 } 373 343 374 // see if we have a connected site script url/fragment 344 375 $url = $store->getConnectedSiteScriptUrl();
Note: See TracChangeset
for help on using the changeset viewer.