Changeset 2638457
- Timestamp:
- 12/02/2021 09:41:34 AM (4 years ago)
- Location:
- woo-izettle-integration
- Files:
-
- 28 edited
- 1 copied
-
tags/7.5.0 (copied) (copied from woo-izettle-integration/trunk)
-
tags/7.5.0/README.txt (modified) (2 diffs)
-
tags/7.5.0/includes/admin/izettle-integration-helper.php (modified) (5 diffs)
-
tags/7.5.0/includes/admin/izettle-integration-notices.php (modified) (4 diffs)
-
tags/7.5.0/includes/admin/settings/views/html-admin-settings-products-from-izettle-options-desc.php (modified) (1 diff)
-
tags/7.5.0/includes/admin/settings/wc-settings-page-izettle.php (modified) (2 diffs)
-
tags/7.5.0/includes/api/izettle-integration-api.php (modified) (2 diffs)
-
tags/7.5.0/includes/izettle-integration-authorization.php (modified) (1 diff)
-
tags/7.5.0/includes/izettle-integration-iz-products.php (modified) (5 diffs)
-
tags/7.5.0/includes/izettle-integration-product-handler-admin.php (modified) (1 diff)
-
tags/7.5.0/includes/izettle-integration-product-handler.php (modified) (15 diffs)
-
tags/7.5.0/includes/izettle-integration-purchase-handler.php (modified) (4 diffs)
-
tags/7.5.0/includes/izettle-purchase-transaction-post.php (modified) (1 diff)
-
tags/7.5.0/includes/izettle-stock-level-handler.php (modified) (2 diffs)
-
tags/7.5.0/woo-izettle-integration.php (modified) (14 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/includes/admin/izettle-integration-helper.php (modified) (5 diffs)
-
trunk/includes/admin/izettle-integration-notices.php (modified) (4 diffs)
-
trunk/includes/admin/settings/views/html-admin-settings-products-from-izettle-options-desc.php (modified) (1 diff)
-
trunk/includes/admin/settings/wc-settings-page-izettle.php (modified) (2 diffs)
-
trunk/includes/api/izettle-integration-api.php (modified) (2 diffs)
-
trunk/includes/izettle-integration-authorization.php (modified) (1 diff)
-
trunk/includes/izettle-integration-iz-products.php (modified) (5 diffs)
-
trunk/includes/izettle-integration-product-handler-admin.php (modified) (1 diff)
-
trunk/includes/izettle-integration-product-handler.php (modified) (15 diffs)
-
trunk/includes/izettle-integration-purchase-handler.php (modified) (4 diffs)
-
trunk/includes/izettle-purchase-transaction-post.php (modified) (1 diff)
-
trunk/includes/izettle-stock-level-handler.php (modified) (2 diffs)
-
trunk/woo-izettle-integration.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-izettle-integration/tags/7.5.0/README.txt
r2602846 r2638457 5 5 Tested up to: 5.8 6 6 Requires PHP: 7.3 7 Stable tag: 7. 4.27 Stable tag: 7.5.0 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 118 118 119 119 == Changelog == 120 = 7.5.0 = 121 * The plugin is verified to work with WooCommerce 5.9 122 * New: Added option for prioritizing Zettle price above Sale price 123 * Fix: Changed import type to Merge products as default 124 * Fix: Error thrown if SKU is too long 125 * Fix: Notices failing to show up 126 * Fix: Variations out of stock were synced even when configured not to 127 * Fix: Added timestamp to notices 128 * Fix: Failing to unschedule actions causing error 129 * Fix: thepostid variable not declared causing warnings 130 * Fix: Wrong number of parameters in the update of products from zettle caused products to be created although setting was set to only update. 120 131 = 7.4.2 = 121 132 * The plugin is verified to work with WooCommerce 5.7 -
woo-izettle-integration/tags/7.5.0/includes/admin/izettle-integration-helper.php
r2602846 r2638457 426 426 public static function object_diff(stdClass $obj1, stdClass $obj2): bool 427 427 { 428 $array1 = json_decode(json_encode($obj1 ), true);429 $array2 = json_decode(json_encode($obj2 ), true);428 $array1 = json_decode(json_encode($obj1, JSON_INVALID_UTF8_IGNORE), true); 429 $array2 = json_decode(json_encode($obj2, JSON_INVALID_UTF8_IGNORE), true); 430 430 return self::array_diff($array1, $array2); 431 431 } … … 512 512 { 513 513 if (!is_array($object)) { 514 $object = json_decode(json_encode($object ), true);514 $object = json_decode(json_encode($object, JSON_INVALID_UTF8_IGNORE), true); 515 515 } 516 516 unset($object['etag']); … … 518 518 unset($object['updatedBy']); 519 519 self::ksort_recursive($object); 520 WC_IZ()->logger->add(print_r(json_encode($object ), true));520 WC_IZ()->logger->add(print_r(json_encode($object, JSON_INVALID_UTF8_IGNORE), true)); 521 521 return md5(json_encode((object) $object)); 522 522 } … … 885 885 if (false === $tax_rates) { 886 886 $tax_rates = izettle_api()->get_tax_rates(); 887 WC_IZ()->logger->add(sprintf('get_rates: "%s"', json_encode($tax_rates )));887 WC_IZ()->logger->add(sprintf('get_rates: "%s"', json_encode($tax_rates, JSON_INVALID_UTF8_IGNORE))); 888 888 set_site_transient('zettle_tax_rates', $tax_rates, DAY_IN_SECONDS); 889 889 } … … 958 958 if (false === $tax_settings) { 959 959 $tax_settings = izettle_api()->get_tax_settings(); 960 WC_IZ()->logger->add(sprintf('get_tax_settings: "%s"', json_encode($tax_settings )));960 WC_IZ()->logger->add(sprintf('get_tax_settings: "%s"', json_encode($tax_settings, JSON_INVALID_UTF8_IGNORE))); 961 961 set_site_transient('zettle_tax_settings', $tax_settings, DAY_IN_SECONDS); 962 962 } -
woo-izettle-integration/tags/7.5.0/includes/admin/izettle-integration-notices.php
r2526349 r2638457 62 62 63 63 $notices[$id] = $notice; 64 64 65 set_site_transient('izettle_notices', $notices); 65 66 … … 70 71 { 71 72 72 /* if (WC_Zettle_Helper::wc_version_check('4.0.0')) {73 require_once dirname(__FILE__) . '/izettle-admin-notes.php';74 \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_iZettle::clear($id);73 /* if (WC_Zettle_Helper::wc_version_check('4.0.0')) { 74 require_once dirname(__FILE__) . '/izettle-admin-notes.php'; 75 \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_iZettle::clear($id); 75 76 }*/ 76 77 77 78 $notices = get_site_transient('izettle_notices'); 78 if ($id && isset($notices[$id])) { 79 unset($notices[$id]); 79 if ($id) { 80 if (isset($notices[$id])) { 81 unset($notices[$id]); 82 } 80 83 } else { 81 84 $notices = array(); … … 87 90 { 88 91 $dismissable = $dismiss ? 'is-dismissible' : ''; 92 $date = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), date('U') + (get_option('gmt_offset') * HOUR_IN_SECONDS)); 93 $message = $date . ' - Zettle: ' . $message; 89 94 echo '<div class="iz_notice ' . $dismissable . ' notice notice-' . $type . ' ' . $id . '"><p>' . $message . '</p></div>'; 90 95 } … … 93 98 { 94 99 $notices = get_site_transient('izettle_notices'); 95 96 100 if (false !== $notices && !empty($notices)) { 97 101 foreach ($notices as $key => $notice) { -
woo-izettle-integration/tags/7.5.0/includes/admin/settings/views/html-admin-settings-products-from-izettle-options-desc.php
r2526349 r2638457 44 44 <?php _e('<b>Create and update products in WooCommerce</b> - Both the Create and Update above will happen.', 'woo-izettle-integration');?> 45 45 </li> 46 <li> 47 <?php _e('<b>Create, update and delete products in WooCommerce</b> - Both the Create and Update above will happen. Furthermore, products deleted in Zettle will also be deleted in WooCommerce.', 'woo-izettle-integration');?> 48 </li> 46 49 </ul> 47 50 <p> -
woo-izettle-integration/tags/7.5.0/includes/admin/settings/wc-settings-page-izettle.php
r2602846 r2638457 281 281 $pricelists = array( 282 282 '' => __('Regular price', 'woocommerce'), 283 '_sale' => __('Sale price if available (Regular if not)', 'woo-izettle-integration'), 284 '_special' => __('Zettle price from the Zettle tab if available (Regular if not)', 'woo-izettle-integration'), 283 '_sale' => __('Sale price if available - Regular if not', 'woo-izettle-integration'), 284 '_special' => __('Zettle price from the Zettle tab if available - Regular if not', 'woo-izettle-integration'), 285 '_sale_special' => __('Zettle price from Zettle tab if available - Sale price if not - Regular price if not', 'woo-izettle-integration'), 285 286 '_no_price' => __('Do not set the price', 'woo-izettle-integration'), 286 287 ); … … 708 709 'type' => 'select', 709 710 'desc' => __('Select type of manual import.', 'woo-izettle-integration'), 710 'default' => ' dry',711 'default' => 'merge', 711 712 'options' => array( 712 713 'dry' => __('Dry run full import', 'woo-izettle-integration'), 713 'merge' => __('Merge products ', 'woo-izettle-integration'),714 'merge' => __('Merge products (recommended)', 'woo-izettle-integration'), 714 715 'new' => __('Create all products', 'woo-izettle-integration'), 715 716 'match_dry' => __('Dry run matching only', 'woo-izettle-integration'), -
woo-izettle-integration/tags/7.5.0/includes/api/izettle-integration-api.php
r2602846 r2638457 130 130 $args['body'] = $form; 131 131 } else { 132 $json_body = json_encode($form );132 $json_body = json_encode($form, JSON_INVALID_UTF8_IGNORE); 133 133 if (!$json_body) { 134 134 $json_error = json_last_error(); … … 166 166 167 167 if (($http_code = wp_remote_retrieve_response_code($response)) > 299) { 168 $message = isset($data->developerMessage) ? $data->developerMessage : 'Error when connecting to Zettle'; 168 169 if (isset($data->violations)) { 170 $violatons = reset($data->violations); 171 $message = $violatons->developerMessage; 172 } elseif (isset($data->developerMessage)) { 173 $message = $data->developerMessage; 174 } else { 175 $message = __('Unknown error when connecting to Zettle', 'woo-izettle-integration'); 176 } 177 169 178 throw new IZ_Integration_API_Exception($message, $http_code); 170 179 } -
woo-izettle-integration/tags/7.5.0/includes/izettle-integration-authorization.php
r2526349 r2638457 148 148 ); 149 149 if (count($actions) > 1) { 150 as_unschedule_action('izettle_service_heartbeat'); 150 try{ 151 as_unschedule_action('izettle_service_heartbeat'); 152 }catch(\Throwable $throwable){ 153 WC_IZ()->logger->add(sprintf('schedule_heartbeat_sync - No process to unschedule')); 154 } 151 155 } 152 156 } else { 153 157 if (false !== as_next_scheduled_action('izettle_service_heartbeat')) { 154 as_unschedule_all_actions('izettle_service_heartbeat'); 158 try{ 159 as_unschedule_all_actions('izettle_service_heartbeat'); 160 }catch(\Throwable $throwable){ 161 WC_IZ()->logger->add(sprintf('schedule_heartbeat_sync - No process to unschedule')); 162 } 155 163 } 156 164 } -
woo-izettle-integration/tags/7.5.0/includes/izettle-integration-iz-products.php
r2602846 r2638457 39 39 add_filter('wciz_sync_iz_products_filter', array($this, 'sync_iz_products'), 10, 2); 40 40 add_action('wciz_sync_iz_products_action', array($this, 'sync_iz_products'), 10, 2); 41 add_action('wciz_sync_iz_products_process', array($this, 'sync_iz_products_process'), 10, 3);41 add_action('wciz_sync_iz_products_process', array($this, 'sync_iz_products_process'), 10, 4); 42 42 43 43 } … … 297 297 { 298 298 299 300 299 301 if (false !== $payload) { 300 $payload = is_object($payload) ? $payload : json_decode(json_encode($payload ));302 $payload = is_object($payload) ? $payload : json_decode(json_encode($payload, JSON_INVALID_UTF8_IGNORE)); 301 303 } else { 302 304 if ($payload = get_site_transient('sync_products_from_izettle_' . $key)) { … … 309 311 } 310 312 311 $this->logger(sprintf('sync_iz_products_process: got %s payload %s', $webhook ? 'webhook' : 'import', json_encode($payload))); 313 $this->logger(sprintf('sync_iz_products_process: got %s payload %s', $webhook ? 'webhook' : 'import', json_encode($payload, JSON_INVALID_UTF8_IGNORE))); 314 315 if($create){ 316 $this->logger(sprintf('sync_iz_products_process: create set to %s', $create)); 317 } 312 318 313 319 $iz_product = $this->get_iz_product($payload); … … 319 325 320 326 if (false === $webhook) { 321 $izettle_import_type = get_option('izettle_import_type', ' dry');327 $izettle_import_type = get_option('izettle_import_type', 'merge'); 322 328 $this->dry_run = false !== strpos($izettle_import_type, 'dry'); 323 329 $this->match_only = false !== strpos($izettle_import_type, 'match'); … … 713 719 $message = $e->getMessage(); 714 720 $this->logger(sprintf('sync_iz_products_process: %s when importing Zettle product', $message, $iz_product->uuid)); 715 IZ_Notice::add(sprintf(' Zettle:%s when importing Zettle product %s', $message, $iz_product->name), 'error');721 IZ_Notice::add(sprintf('%s when importing Zettle product %s', $message, $iz_product->name), 'error'); 716 722 717 723 } -
woo-izettle-integration/tags/7.5.0/includes/izettle-integration-product-handler-admin.php
r2526349 r2638457 42 42 public function show_izettle_fields_variable($loop, $variation_data, $variation) 43 43 { 44 global $thepostid; 44 45 if ($this->is_default_language($thepostid)) { 45 46 include 'views/html-product-data-inventory-variable.php'; -
woo-izettle-integration/tags/7.5.0/includes/izettle-integration-product-handler.php
r2602846 r2638457 385 385 } else { 386 386 387 // Use Zettle if available - sale price if not - regular price if not 388 if('_sale_special') { 389 if(($meta_price = $product->get_meta('_izettle_special_price', true, 'edit'))){ 390 $price = str_replace(',', '.', $meta_price); 391 WC_IZ()->logger->add(sprintf('get_price (%s): Using special price %s', $product_id, $price)); 392 } 393 elseif($product->is_on_sale('edit')) { 394 $sale_price = $product->get_sale_price('edit'); 395 WC_IZ()->logger->add(sprintf('get_price (%s): Using sale price %s instead of price %s', $product_id, $sale_price, $price)); 396 $price = $sale_price; 397 } 398 } 399 387 400 // Use the sale price if it is avaliable 388 if ('_sale' == $preferred_pricelist) {401 elseif ('_sale' == $preferred_pricelist) { 389 402 390 403 if ($product->is_on_sale('edit')) { … … 459 472 } 460 473 474 if(strlen($sku) > 64){ 475 throw new IZ_Integration_Exception(sprintf('SKU %s longer than 64 bytes', $sku)); 476 } 477 461 478 return $sku; 462 479 … … 597 614 598 615 if (false !== $tax_rate) { 599 $variant["vatPercentage"] = $tax_rate; 616 if (false === WC_Zettle_Helper::get_tax_settings()) { 617 $variant["vatPercentage"] = $tax_rate; 618 } 600 619 } 601 620 … … 744 763 } 745 764 746 $task_object = is_object($task_object) ? $task_object : json_decode(json_encode($task_object ));765 $task_object = is_object($task_object) ? $task_object : json_decode(json_encode($task_object, JSON_INVALID_UTF8_IGNORE)); 747 766 748 767 $product_id = $task_object->product_id; … … 781 800 $product_type = $product->get_type(); 782 801 802 $sync_in_stock_only = wc_string_to_bool(get_option('izettle_sync_in_stock_only')); 803 783 804 if ('variable' == $product_type) { 784 805 785 if ( 'yes' == get_option('izettle_sync_in_stock_only')) {806 if ($sync_in_stock_only) { 786 807 $variations = $product->get_available_variations(); 787 808 } else { … … 821 842 $variation = wc_get_product($variation['variation_id']); 822 843 } 844 $variation_id = $variation->get_id(); 823 845 824 846 if ($variation->get_meta('_izettle_nosync', true, 'edit') == 'yes') { 825 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s marked not to sync to Zettle', $product_id, $variation->get_id())); 847 848 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s marked not to sync to Zettle', $product_id, $variation_id)); 849 850 } elseif ($sync_in_stock_only && !$variation->is_in_stock('edit')) { 851 852 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s had no stock and will not sync', $product_id, $variation_id)); 853 826 854 } else { 855 827 856 $variant_array = $this->izettle_variant_array( 828 857 $variation … … 832 861 $changed_variation = $this->maybe_set_product_uuid($changed_variation, $variation, $product_uuid); 833 862 $changed_variation = $this->maybe_set_variant_uuid($changed_variation, $variation, $variant_array['uuid']); 834 835 863 } 836 864 837 865 if (true === $changed_variation) { 838 866 $variation->save(); 839 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Created variation %s with UUID %s', $product_id, $variation ->get_id(), $variant_array['uuid']));867 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Created variation %s with UUID %s', $product_id, $variation_id, $variant_array['uuid'])); 840 868 } 841 869 … … 854 882 ); 855 883 856 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Create variable "%s"', $product_id, json_encode($iz_product )));884 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Create variable "%s"', $product_id, json_encode($iz_product, JSON_INVALID_UTF8_IGNORE))); 857 885 858 886 $product_response = izettle_api()->create_product( … … 881 909 882 910 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s marked not to sync to Zettle', $product_id, $variation_id)); 911 912 } elseif ($sync_in_stock_only && !$variation->is_in_stock('edit')) { 913 914 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s had no stock and will not sync', $product_id, $variation_id)); 883 915 884 916 } else { … … 933 965 if ($this->is_product_changed($iz_product, $existing_product)) { 934 966 935 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Update variable "%s"', $product_id, json_encode($iz_product )));967 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Update variable "%s"', $product_id, json_encode($iz_product, JSON_INVALID_UTF8_IGNORE))); 936 968 937 969 $product_response = izettle_api()->update_product( … … 982 1014 $this->changed = $this->maybe_set_variant_uuid($this->changed, $product, $variant_array['uuid']); 983 1015 984 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Create simple "%s"', $product_id, json_encode($iz_product )));1016 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Create simple "%s"', $product_id, json_encode($iz_product, JSON_INVALID_UTF8_IGNORE))); 985 1017 986 1018 $product_response = izettle_api()->create_product( … … 1015 1047 if ($this->is_product_changed($iz_product, $existing_product)) { 1016 1048 1017 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Update simple "%s"', $product_id, json_encode($iz_product )));1049 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Update simple "%s"', $product_id, json_encode($iz_product, JSON_INVALID_UTF8_IGNORE))); 1018 1050 1019 1051 $product_response = izettle_api()->update_product( … … 1077 1109 $message = $e->getMessage(); 1078 1110 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): "%s" when creating Zettle product', $product_id, $message)); 1111 IZ_Notice::add(sprintf('%s when creating Zettle product from WooCommerce product %s', $message, $product_id), 'error'); 1079 1112 } 1080 1113 … … 1557 1590 { 1558 1591 1559 $task_object = is_object($task_object) ? $task_object : json_decode(json_encode($task_object ));1592 $task_object = is_object($task_object) ? $task_object : json_decode(json_encode($task_object, JSON_INVALID_UTF8_IGNORE)); 1560 1593 1561 1594 if (is_admin() && 'yes' == get_option('izettle_do_not_queue_admin_updates')) { … … 1638 1671 } 1639 1672 1640 WC_IZ()->logger->add(sprintf('sync_wc_products: Using product args %s', json_encode($args ), true));1673 WC_IZ()->logger->add(sprintf('sync_wc_products: Using product args %s', json_encode($args, JSON_INVALID_UTF8_IGNORE), true)); 1641 1674 1642 1675 $products_ids = wc_get_products($args); 1643 1676 1644 WC_IZ()->logger->add(sprintf('sync_wc_products: Get product id:s %s', json_encode($products_ids ), true));1677 WC_IZ()->logger->add(sprintf('sync_wc_products: Get product id:s %s', json_encode($products_ids, JSON_INVALID_UTF8_IGNORE), true)); 1645 1678 1646 1679 $total_to_sync = count($products_ids); -
woo-izettle-integration/tags/7.5.0/includes/izettle-integration-purchase-handler.php
r2592459 r2638457 76 76 if (count($actions) > 1) { 77 77 78 as_unschedule_action('wciz_sync_iz_purchases_action'); 79 78 try{ 79 as_unschedule_action('wciz_sync_iz_purchases_action'); 80 }catch(\Throwable $throwable){ 81 WC_IZ()->logger->add(sprintf('schedule_sync_izettle_purchases - No process to unschedule')); 82 } 80 83 } 81 84 … … 95 98 96 99 if (false !== as_next_scheduled_action('wciz_sync_iz_purchases_action')) { 97 as_unschedule_all_actions('wciz_sync_iz_purchases_action'); 100 101 try{ 102 as_unschedule_all_actions('wciz_sync_iz_purchases_action'); 103 }catch(\Throwable $throwable){ 104 WC_IZ()->logger->add(sprintf('schedule_heartbeat_sync - No process to unschedule')); 105 } 98 106 } 99 107 100 108 if (false !== as_next_scheduled_action('wciz_sync_iz_purchases_action_daily')) { 101 as_unschedule_all_actions('wciz_sync_iz_purchases_action_daily'); 109 try{ 110 as_unschedule_all_actions('wciz_sync_iz_purchases_action_daily'); 111 }catch(\Throwable $throwable){ 112 WC_IZ()->logger->add(sprintf('schedule_sync_izettle_purchases - No process to unschedule')); 113 } 102 114 } 103 115 … … 390 402 } 391 403 404 } else { 405 406 $new_stock = wc_update_product_stock($product, $purchase_product->quantity, $reverse ? 'increase' : 'decrease'); 407 $this->document_changes($post_id, $purchase->purchaseNumber, $reverse ? 'reverse' : 'wc_stockchange', sprintf(__('Product not tracked, stocklevel for %s (%s) changed from %s to %s', 'woo-izettle-integration'), $product_name, $product_id, $current_stock, $new_stock)); 408 392 409 } 393 410 } … … 727 744 self::$order_id = $order_id; 728 745 729 WC_IZ()->logger->add(sprintf('process_purchase_wc_order: got purchase %s', json_encode($purchase )));746 WC_IZ()->logger->add(sprintf('process_purchase_wc_order: got purchase %s', json_encode($purchase, JSON_INVALID_UTF8_IGNORE))); 730 747 731 748 $order_tax_values = array(); -
woo-izettle-integration/tags/7.5.0/includes/izettle-purchase-transaction-post.php
r2568813 r2638457 153 153 $item = izettle_api()->get_purchase($uuid); 154 154 155 WC_IZ()->logger->add(sprintf('insert_post: got purchase change %s', json_encode($item )));155 WC_IZ()->logger->add(sprintf('insert_post: got purchase change %s', json_encode($item, JSON_INVALID_UTF8_IGNORE))); 156 156 157 157 if (apply_filters('zettle_before_insert_purchase_post', true, $item, $post)) { -
woo-izettle-integration/tags/7.5.0/includes/izettle-stock-level-handler.php
r2592459 r2638457 149 149 150 150 $stock_quantity = $product->get_stock_quantity('view'); 151 $wc_level = $stock_quantity? $stock_quantity : 0;151 $wc_level = is_numeric($stock_quantity) ? $stock_quantity : 0; 152 152 153 153 $product_uuid = $product->get_meta('woocommerce_izettle_product_uuid', true); … … 300 300 do_action('izettle_remove_product_update_actions'); 301 301 302 WC_IZ()->logger->add(sprintf('received_inventory_balance_changed: got balance change %s', json_encode($change_record )));303 304 $change_record = is_object($change_record) ? $change_record : json_decode(json_encode($change_record ));302 WC_IZ()->logger->add(sprintf('received_inventory_balance_changed: got balance change %s', json_encode($change_record, JSON_INVALID_UTF8_IGNORE))); 303 304 $change_record = is_object($change_record) ? $change_record : json_decode(json_encode($change_record, JSON_INVALID_UTF8_IGNORE)); 305 305 306 306 if (isset($change_record->change_record_key)) { -
woo-izettle-integration/tags/7.5.0/woo-izettle-integration.php
r2602846 r2638457 14 14 * Plugin Name: WooCommerce Zettle Integration 15 15 * Plugin URI: https://www.bjorntech.com/woocommerce-zettle/?utm_source=wp-izettle&utm_medium=plugin&utm_campaign=product 16 * Description: Sync ronizes products, purchases and stock-levels.17 * Version: 7. 4.216 * Description: Synchronizes products, purchases and stock levels. 17 * Version: 7.5.0 18 18 * Author: BjornTech AB 19 19 * Author URI: https://www.bjorntech.com/?utm_source=wp-izettle&utm_medium=plugin&utm_campaign=product … … 21 21 * 22 22 * WC requires at least: 4.0 23 * WC tested up to: 5. 723 * WC tested up to: 5.9 24 24 * 25 25 * Copyright: 2017-2020 BjornTech AB … … 73 73 */ 74 74 const NAME = 'WooCommerce Zettle Integration'; 75 const VERSION = '7. 4.2';75 const VERSION = '7.5.0'; 76 76 const SCRIPT_HANDLE = 'wc-izettle-integration'; 77 77 const PLUGIN_FILE = __FILE__; … … 376 376 'version' => $this->version, 377 377 ); 378 $encoded_params = base64_encode(json_encode($site_params ));378 $encoded_params = base64_encode(json_encode($site_params, JSON_INVALID_UTF8_IGNORE)); 379 379 $client_id = $this->client_id; 380 380 $state = array( … … 428 428 429 429 } elseif ('start' == $_POST['task']) { 430 431 as_unschedule_all_actions($id . '_process'); 430 try{ 431 as_unschedule_all_actions($id . '_process'); 432 }catch(\Throwable $throwable){ 433 WC_IZ()->logger->add(sprintf('ajax_wciz_processing_button - No process to unschedule')); 434 } 432 435 $response = array( 433 436 'status' => 'success', … … 476 479 delete_site_transient('zettle_tax_rates'); 477 480 delete_site_transient('zettle_tax_settings'); 478 IZ_Notice::add(' Zettle:New token requested from service', 'success');481 IZ_Notice::add('New token requested from service', 'success'); 479 482 480 483 } catch (IZ_Integration_API_Exception $e) { 481 484 482 485 $e->write_to_logs(); 483 IZ_Notice::add(' Zettle:Error when connecting to service, check logs', 'success');486 IZ_Notice::add('Error when connecting to service, check logs', 'success'); 484 487 485 488 } … … 623 626 { 624 627 $webhook_signing_key = izettle_api()->get_webhook_signing_key(); 625 WC_IZ()->logger->add(sprintf('Webhook signing key %s', $webhook_signing_key));628 WC_IZ()->logger->add(sprintf('Webhook signing key %s', $webhook_signing_key)); 626 629 return hash_hmac( 627 630 'sha256', … … 643 646 if (wc_string_to_bool(get_option('zettle_enable_purchase_processing')) && 1 == get_option('izettle_purchase_sync_model')) { 644 647 $payload = json_decode($request['payload']); 648 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering PurchaseCreated')); 645 649 do_action('izettle_add_purchase_to_queue', $payload->purchaseUuid, true); 646 650 } else { … … 653 657 $payload = json_decode($request['payload']); 654 658 if (!get_site_transient('izettle_stocklevel_update' . $payload->externalUuid)) { 659 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering InventoryBalanceChanged')); 655 660 do_action('izettle_received_inventory_balance_changed_add', $payload, $request['messageId'], true); 656 661 } else { … … 664 669 if ($payload = json_decode($request['payload'])) { 665 670 if (!isset($payload->externalReference)) { 671 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering ProductCreated')); 666 672 do_action('izettle_sync_products_from_izettle_add', $payload, $request['messageId'], true); 667 673 } else { … … 676 682 if ($payload = json_decode($request['payload'])) { 677 683 if (!isset($payload->newEntity->externalReference) || $payload->newEntity->etag != get_post_meta(WC_Zettle_Helper::get_id($payload->newEntity->externalReference), '_izettle_product_etag', true)) { 684 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering ProductUpdated')); 678 685 do_action('izettle_sync_products_from_izettle_add', $payload, $request['messageId'], true, false); 679 686 } else { … … 687 694 if (false !== strpos(get_option('izettle_when_changed_in_izettle'), 'delete')) { 688 695 if ($payload = json_decode($request['payload'])) { 696 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering ProductDeleted')); 689 697 do_action('izettle_delete_product_from_izettle', $payload->uuid, get_option('izettle_force_delete_in_woocommerce') == 'yes'); 690 698 } … … 695 703 if (WC_Zettle_Helper::zettle_changes_stock()) { 696 704 if ($payload = json_decode($request['payload'])) { 705 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering InventoryTrackingStarted')); 697 706 do_action('izettle_received_inventory_tracking_started_add', $payload, $request['messageId'], true); 698 707 } … … 703 712 if (WC_Zettle_Helper::zettle_changes_stock()) { 704 713 if ($payload = json_decode($request['payload'])) { 714 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering InventoryTrackingStopped')); 705 715 do_action('izettle_received_inventory_tracking_stopped_add', $payload, $request['messageId'], true); 706 716 } -
woo-izettle-integration/trunk/README.txt
r2602846 r2638457 5 5 Tested up to: 5.8 6 6 Requires PHP: 7.3 7 Stable tag: 7. 4.27 Stable tag: 7.5.0 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 118 118 119 119 == Changelog == 120 = 7.5.0 = 121 * The plugin is verified to work with WooCommerce 5.9 122 * New: Added option for prioritizing Zettle price above Sale price 123 * Fix: Changed import type to Merge products as default 124 * Fix: Error thrown if SKU is too long 125 * Fix: Notices failing to show up 126 * Fix: Variations out of stock were synced even when configured not to 127 * Fix: Added timestamp to notices 128 * Fix: Failing to unschedule actions causing error 129 * Fix: thepostid variable not declared causing warnings 130 * Fix: Wrong number of parameters in the update of products from zettle caused products to be created although setting was set to only update. 120 131 = 7.4.2 = 121 132 * The plugin is verified to work with WooCommerce 5.7 -
woo-izettle-integration/trunk/includes/admin/izettle-integration-helper.php
r2602846 r2638457 426 426 public static function object_diff(stdClass $obj1, stdClass $obj2): bool 427 427 { 428 $array1 = json_decode(json_encode($obj1 ), true);429 $array2 = json_decode(json_encode($obj2 ), true);428 $array1 = json_decode(json_encode($obj1, JSON_INVALID_UTF8_IGNORE), true); 429 $array2 = json_decode(json_encode($obj2, JSON_INVALID_UTF8_IGNORE), true); 430 430 return self::array_diff($array1, $array2); 431 431 } … … 512 512 { 513 513 if (!is_array($object)) { 514 $object = json_decode(json_encode($object ), true);514 $object = json_decode(json_encode($object, JSON_INVALID_UTF8_IGNORE), true); 515 515 } 516 516 unset($object['etag']); … … 518 518 unset($object['updatedBy']); 519 519 self::ksort_recursive($object); 520 WC_IZ()->logger->add(print_r(json_encode($object ), true));520 WC_IZ()->logger->add(print_r(json_encode($object, JSON_INVALID_UTF8_IGNORE), true)); 521 521 return md5(json_encode((object) $object)); 522 522 } … … 885 885 if (false === $tax_rates) { 886 886 $tax_rates = izettle_api()->get_tax_rates(); 887 WC_IZ()->logger->add(sprintf('get_rates: "%s"', json_encode($tax_rates )));887 WC_IZ()->logger->add(sprintf('get_rates: "%s"', json_encode($tax_rates, JSON_INVALID_UTF8_IGNORE))); 888 888 set_site_transient('zettle_tax_rates', $tax_rates, DAY_IN_SECONDS); 889 889 } … … 958 958 if (false === $tax_settings) { 959 959 $tax_settings = izettle_api()->get_tax_settings(); 960 WC_IZ()->logger->add(sprintf('get_tax_settings: "%s"', json_encode($tax_settings )));960 WC_IZ()->logger->add(sprintf('get_tax_settings: "%s"', json_encode($tax_settings, JSON_INVALID_UTF8_IGNORE))); 961 961 set_site_transient('zettle_tax_settings', $tax_settings, DAY_IN_SECONDS); 962 962 } -
woo-izettle-integration/trunk/includes/admin/izettle-integration-notices.php
r2526349 r2638457 62 62 63 63 $notices[$id] = $notice; 64 64 65 set_site_transient('izettle_notices', $notices); 65 66 … … 70 71 { 71 72 72 /* if (WC_Zettle_Helper::wc_version_check('4.0.0')) {73 require_once dirname(__FILE__) . '/izettle-admin-notes.php';74 \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_iZettle::clear($id);73 /* if (WC_Zettle_Helper::wc_version_check('4.0.0')) { 74 require_once dirname(__FILE__) . '/izettle-admin-notes.php'; 75 \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_iZettle::clear($id); 75 76 }*/ 76 77 77 78 $notices = get_site_transient('izettle_notices'); 78 if ($id && isset($notices[$id])) { 79 unset($notices[$id]); 79 if ($id) { 80 if (isset($notices[$id])) { 81 unset($notices[$id]); 82 } 80 83 } else { 81 84 $notices = array(); … … 87 90 { 88 91 $dismissable = $dismiss ? 'is-dismissible' : ''; 92 $date = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), date('U') + (get_option('gmt_offset') * HOUR_IN_SECONDS)); 93 $message = $date . ' - Zettle: ' . $message; 89 94 echo '<div class="iz_notice ' . $dismissable . ' notice notice-' . $type . ' ' . $id . '"><p>' . $message . '</p></div>'; 90 95 } … … 93 98 { 94 99 $notices = get_site_transient('izettle_notices'); 95 96 100 if (false !== $notices && !empty($notices)) { 97 101 foreach ($notices as $key => $notice) { -
woo-izettle-integration/trunk/includes/admin/settings/views/html-admin-settings-products-from-izettle-options-desc.php
r2526349 r2638457 44 44 <?php _e('<b>Create and update products in WooCommerce</b> - Both the Create and Update above will happen.', 'woo-izettle-integration');?> 45 45 </li> 46 <li> 47 <?php _e('<b>Create, update and delete products in WooCommerce</b> - Both the Create and Update above will happen. Furthermore, products deleted in Zettle will also be deleted in WooCommerce.', 'woo-izettle-integration');?> 48 </li> 46 49 </ul> 47 50 <p> -
woo-izettle-integration/trunk/includes/admin/settings/wc-settings-page-izettle.php
r2602846 r2638457 281 281 $pricelists = array( 282 282 '' => __('Regular price', 'woocommerce'), 283 '_sale' => __('Sale price if available (Regular if not)', 'woo-izettle-integration'), 284 '_special' => __('Zettle price from the Zettle tab if available (Regular if not)', 'woo-izettle-integration'), 283 '_sale' => __('Sale price if available - Regular if not', 'woo-izettle-integration'), 284 '_special' => __('Zettle price from the Zettle tab if available - Regular if not', 'woo-izettle-integration'), 285 '_sale_special' => __('Zettle price from Zettle tab if available - Sale price if not - Regular price if not', 'woo-izettle-integration'), 285 286 '_no_price' => __('Do not set the price', 'woo-izettle-integration'), 286 287 ); … … 708 709 'type' => 'select', 709 710 'desc' => __('Select type of manual import.', 'woo-izettle-integration'), 710 'default' => ' dry',711 'default' => 'merge', 711 712 'options' => array( 712 713 'dry' => __('Dry run full import', 'woo-izettle-integration'), 713 'merge' => __('Merge products ', 'woo-izettle-integration'),714 'merge' => __('Merge products (recommended)', 'woo-izettle-integration'), 714 715 'new' => __('Create all products', 'woo-izettle-integration'), 715 716 'match_dry' => __('Dry run matching only', 'woo-izettle-integration'), -
woo-izettle-integration/trunk/includes/api/izettle-integration-api.php
r2602846 r2638457 130 130 $args['body'] = $form; 131 131 } else { 132 $json_body = json_encode($form );132 $json_body = json_encode($form, JSON_INVALID_UTF8_IGNORE); 133 133 if (!$json_body) { 134 134 $json_error = json_last_error(); … … 166 166 167 167 if (($http_code = wp_remote_retrieve_response_code($response)) > 299) { 168 $message = isset($data->developerMessage) ? $data->developerMessage : 'Error when connecting to Zettle'; 168 169 if (isset($data->violations)) { 170 $violatons = reset($data->violations); 171 $message = $violatons->developerMessage; 172 } elseif (isset($data->developerMessage)) { 173 $message = $data->developerMessage; 174 } else { 175 $message = __('Unknown error when connecting to Zettle', 'woo-izettle-integration'); 176 } 177 169 178 throw new IZ_Integration_API_Exception($message, $http_code); 170 179 } -
woo-izettle-integration/trunk/includes/izettle-integration-authorization.php
r2526349 r2638457 148 148 ); 149 149 if (count($actions) > 1) { 150 as_unschedule_action('izettle_service_heartbeat'); 150 try{ 151 as_unschedule_action('izettle_service_heartbeat'); 152 }catch(\Throwable $throwable){ 153 WC_IZ()->logger->add(sprintf('schedule_heartbeat_sync - No process to unschedule')); 154 } 151 155 } 152 156 } else { 153 157 if (false !== as_next_scheduled_action('izettle_service_heartbeat')) { 154 as_unschedule_all_actions('izettle_service_heartbeat'); 158 try{ 159 as_unschedule_all_actions('izettle_service_heartbeat'); 160 }catch(\Throwable $throwable){ 161 WC_IZ()->logger->add(sprintf('schedule_heartbeat_sync - No process to unschedule')); 162 } 155 163 } 156 164 } -
woo-izettle-integration/trunk/includes/izettle-integration-iz-products.php
r2602846 r2638457 39 39 add_filter('wciz_sync_iz_products_filter', array($this, 'sync_iz_products'), 10, 2); 40 40 add_action('wciz_sync_iz_products_action', array($this, 'sync_iz_products'), 10, 2); 41 add_action('wciz_sync_iz_products_process', array($this, 'sync_iz_products_process'), 10, 3);41 add_action('wciz_sync_iz_products_process', array($this, 'sync_iz_products_process'), 10, 4); 42 42 43 43 } … … 297 297 { 298 298 299 300 299 301 if (false !== $payload) { 300 $payload = is_object($payload) ? $payload : json_decode(json_encode($payload ));302 $payload = is_object($payload) ? $payload : json_decode(json_encode($payload, JSON_INVALID_UTF8_IGNORE)); 301 303 } else { 302 304 if ($payload = get_site_transient('sync_products_from_izettle_' . $key)) { … … 309 311 } 310 312 311 $this->logger(sprintf('sync_iz_products_process: got %s payload %s', $webhook ? 'webhook' : 'import', json_encode($payload))); 313 $this->logger(sprintf('sync_iz_products_process: got %s payload %s', $webhook ? 'webhook' : 'import', json_encode($payload, JSON_INVALID_UTF8_IGNORE))); 314 315 if($create){ 316 $this->logger(sprintf('sync_iz_products_process: create set to %s', $create)); 317 } 312 318 313 319 $iz_product = $this->get_iz_product($payload); … … 319 325 320 326 if (false === $webhook) { 321 $izettle_import_type = get_option('izettle_import_type', ' dry');327 $izettle_import_type = get_option('izettle_import_type', 'merge'); 322 328 $this->dry_run = false !== strpos($izettle_import_type, 'dry'); 323 329 $this->match_only = false !== strpos($izettle_import_type, 'match'); … … 713 719 $message = $e->getMessage(); 714 720 $this->logger(sprintf('sync_iz_products_process: %s when importing Zettle product', $message, $iz_product->uuid)); 715 IZ_Notice::add(sprintf(' Zettle:%s when importing Zettle product %s', $message, $iz_product->name), 'error');721 IZ_Notice::add(sprintf('%s when importing Zettle product %s', $message, $iz_product->name), 'error'); 716 722 717 723 } -
woo-izettle-integration/trunk/includes/izettle-integration-product-handler-admin.php
r2526349 r2638457 42 42 public function show_izettle_fields_variable($loop, $variation_data, $variation) 43 43 { 44 global $thepostid; 44 45 if ($this->is_default_language($thepostid)) { 45 46 include 'views/html-product-data-inventory-variable.php'; -
woo-izettle-integration/trunk/includes/izettle-integration-product-handler.php
r2602846 r2638457 385 385 } else { 386 386 387 // Use Zettle if available - sale price if not - regular price if not 388 if('_sale_special') { 389 if(($meta_price = $product->get_meta('_izettle_special_price', true, 'edit'))){ 390 $price = str_replace(',', '.', $meta_price); 391 WC_IZ()->logger->add(sprintf('get_price (%s): Using special price %s', $product_id, $price)); 392 } 393 elseif($product->is_on_sale('edit')) { 394 $sale_price = $product->get_sale_price('edit'); 395 WC_IZ()->logger->add(sprintf('get_price (%s): Using sale price %s instead of price %s', $product_id, $sale_price, $price)); 396 $price = $sale_price; 397 } 398 } 399 387 400 // Use the sale price if it is avaliable 388 if ('_sale' == $preferred_pricelist) {401 elseif ('_sale' == $preferred_pricelist) { 389 402 390 403 if ($product->is_on_sale('edit')) { … … 459 472 } 460 473 474 if(strlen($sku) > 64){ 475 throw new IZ_Integration_Exception(sprintf('SKU %s longer than 64 bytes', $sku)); 476 } 477 461 478 return $sku; 462 479 … … 597 614 598 615 if (false !== $tax_rate) { 599 $variant["vatPercentage"] = $tax_rate; 616 if (false === WC_Zettle_Helper::get_tax_settings()) { 617 $variant["vatPercentage"] = $tax_rate; 618 } 600 619 } 601 620 … … 744 763 } 745 764 746 $task_object = is_object($task_object) ? $task_object : json_decode(json_encode($task_object ));765 $task_object = is_object($task_object) ? $task_object : json_decode(json_encode($task_object, JSON_INVALID_UTF8_IGNORE)); 747 766 748 767 $product_id = $task_object->product_id; … … 781 800 $product_type = $product->get_type(); 782 801 802 $sync_in_stock_only = wc_string_to_bool(get_option('izettle_sync_in_stock_only')); 803 783 804 if ('variable' == $product_type) { 784 805 785 if ( 'yes' == get_option('izettle_sync_in_stock_only')) {806 if ($sync_in_stock_only) { 786 807 $variations = $product->get_available_variations(); 787 808 } else { … … 821 842 $variation = wc_get_product($variation['variation_id']); 822 843 } 844 $variation_id = $variation->get_id(); 823 845 824 846 if ($variation->get_meta('_izettle_nosync', true, 'edit') == 'yes') { 825 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s marked not to sync to Zettle', $product_id, $variation->get_id())); 847 848 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s marked not to sync to Zettle', $product_id, $variation_id)); 849 850 } elseif ($sync_in_stock_only && !$variation->is_in_stock('edit')) { 851 852 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s had no stock and will not sync', $product_id, $variation_id)); 853 826 854 } else { 855 827 856 $variant_array = $this->izettle_variant_array( 828 857 $variation … … 832 861 $changed_variation = $this->maybe_set_product_uuid($changed_variation, $variation, $product_uuid); 833 862 $changed_variation = $this->maybe_set_variant_uuid($changed_variation, $variation, $variant_array['uuid']); 834 835 863 } 836 864 837 865 if (true === $changed_variation) { 838 866 $variation->save(); 839 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Created variation %s with UUID %s', $product_id, $variation ->get_id(), $variant_array['uuid']));867 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Created variation %s with UUID %s', $product_id, $variation_id, $variant_array['uuid'])); 840 868 } 841 869 … … 854 882 ); 855 883 856 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Create variable "%s"', $product_id, json_encode($iz_product )));884 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Create variable "%s"', $product_id, json_encode($iz_product, JSON_INVALID_UTF8_IGNORE))); 857 885 858 886 $product_response = izettle_api()->create_product( … … 881 909 882 910 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s marked not to sync to Zettle', $product_id, $variation_id)); 911 912 } elseif ($sync_in_stock_only && !$variation->is_in_stock('edit')) { 913 914 WC_IZ()->logger->add(sprintf('add_or_update_izettle_product (%s): Variation %s had no stock and will not sync', $product_id, $variation_id)); 883 915 884 916 } else { … … 933 965 if ($this->is_product_changed($iz_product, $existing_product)) { 934 966 935 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Update variable "%s"', $product_id, json_encode($iz_product )));967 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Update variable "%s"', $product_id, json_encode($iz_product, JSON_INVALID_UTF8_IGNORE))); 936 968 937 969 $product_response = izettle_api()->update_product( … … 982 1014 $this->changed = $this->maybe_set_variant_uuid($this->changed, $product, $variant_array['uuid']); 983 1015 984 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Create simple "%s"', $product_id, json_encode($iz_product )));1016 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Create simple "%s"', $product_id, json_encode($iz_product, JSON_INVALID_UTF8_IGNORE))); 985 1017 986 1018 $product_response = izettle_api()->create_product( … … 1015 1047 if ($this->is_product_changed($iz_product, $existing_product)) { 1016 1048 1017 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Update simple "%s"', $product_id, json_encode($iz_product )));1049 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): Update simple "%s"', $product_id, json_encode($iz_product, JSON_INVALID_UTF8_IGNORE))); 1018 1050 1019 1051 $product_response = izettle_api()->update_product( … … 1077 1109 $message = $e->getMessage(); 1078 1110 WC_IZ()->logger->add(sprintf('sync_wc_products_process (%s): "%s" when creating Zettle product', $product_id, $message)); 1111 IZ_Notice::add(sprintf('%s when creating Zettle product from WooCommerce product %s', $message, $product_id), 'error'); 1079 1112 } 1080 1113 … … 1557 1590 { 1558 1591 1559 $task_object = is_object($task_object) ? $task_object : json_decode(json_encode($task_object ));1592 $task_object = is_object($task_object) ? $task_object : json_decode(json_encode($task_object, JSON_INVALID_UTF8_IGNORE)); 1560 1593 1561 1594 if (is_admin() && 'yes' == get_option('izettle_do_not_queue_admin_updates')) { … … 1638 1671 } 1639 1672 1640 WC_IZ()->logger->add(sprintf('sync_wc_products: Using product args %s', json_encode($args ), true));1673 WC_IZ()->logger->add(sprintf('sync_wc_products: Using product args %s', json_encode($args, JSON_INVALID_UTF8_IGNORE), true)); 1641 1674 1642 1675 $products_ids = wc_get_products($args); 1643 1676 1644 WC_IZ()->logger->add(sprintf('sync_wc_products: Get product id:s %s', json_encode($products_ids ), true));1677 WC_IZ()->logger->add(sprintf('sync_wc_products: Get product id:s %s', json_encode($products_ids, JSON_INVALID_UTF8_IGNORE), true)); 1645 1678 1646 1679 $total_to_sync = count($products_ids); -
woo-izettle-integration/trunk/includes/izettle-integration-purchase-handler.php
r2592459 r2638457 76 76 if (count($actions) > 1) { 77 77 78 as_unschedule_action('wciz_sync_iz_purchases_action'); 79 78 try{ 79 as_unschedule_action('wciz_sync_iz_purchases_action'); 80 }catch(\Throwable $throwable){ 81 WC_IZ()->logger->add(sprintf('schedule_sync_izettle_purchases - No process to unschedule')); 82 } 80 83 } 81 84 … … 95 98 96 99 if (false !== as_next_scheduled_action('wciz_sync_iz_purchases_action')) { 97 as_unschedule_all_actions('wciz_sync_iz_purchases_action'); 100 101 try{ 102 as_unschedule_all_actions('wciz_sync_iz_purchases_action'); 103 }catch(\Throwable $throwable){ 104 WC_IZ()->logger->add(sprintf('schedule_heartbeat_sync - No process to unschedule')); 105 } 98 106 } 99 107 100 108 if (false !== as_next_scheduled_action('wciz_sync_iz_purchases_action_daily')) { 101 as_unschedule_all_actions('wciz_sync_iz_purchases_action_daily'); 109 try{ 110 as_unschedule_all_actions('wciz_sync_iz_purchases_action_daily'); 111 }catch(\Throwable $throwable){ 112 WC_IZ()->logger->add(sprintf('schedule_sync_izettle_purchases - No process to unschedule')); 113 } 102 114 } 103 115 … … 390 402 } 391 403 404 } else { 405 406 $new_stock = wc_update_product_stock($product, $purchase_product->quantity, $reverse ? 'increase' : 'decrease'); 407 $this->document_changes($post_id, $purchase->purchaseNumber, $reverse ? 'reverse' : 'wc_stockchange', sprintf(__('Product not tracked, stocklevel for %s (%s) changed from %s to %s', 'woo-izettle-integration'), $product_name, $product_id, $current_stock, $new_stock)); 408 392 409 } 393 410 } … … 727 744 self::$order_id = $order_id; 728 745 729 WC_IZ()->logger->add(sprintf('process_purchase_wc_order: got purchase %s', json_encode($purchase )));746 WC_IZ()->logger->add(sprintf('process_purchase_wc_order: got purchase %s', json_encode($purchase, JSON_INVALID_UTF8_IGNORE))); 730 747 731 748 $order_tax_values = array(); -
woo-izettle-integration/trunk/includes/izettle-purchase-transaction-post.php
r2568813 r2638457 153 153 $item = izettle_api()->get_purchase($uuid); 154 154 155 WC_IZ()->logger->add(sprintf('insert_post: got purchase change %s', json_encode($item )));155 WC_IZ()->logger->add(sprintf('insert_post: got purchase change %s', json_encode($item, JSON_INVALID_UTF8_IGNORE))); 156 156 157 157 if (apply_filters('zettle_before_insert_purchase_post', true, $item, $post)) { -
woo-izettle-integration/trunk/includes/izettle-stock-level-handler.php
r2592459 r2638457 149 149 150 150 $stock_quantity = $product->get_stock_quantity('view'); 151 $wc_level = $stock_quantity? $stock_quantity : 0;151 $wc_level = is_numeric($stock_quantity) ? $stock_quantity : 0; 152 152 153 153 $product_uuid = $product->get_meta('woocommerce_izettle_product_uuid', true); … … 300 300 do_action('izettle_remove_product_update_actions'); 301 301 302 WC_IZ()->logger->add(sprintf('received_inventory_balance_changed: got balance change %s', json_encode($change_record )));303 304 $change_record = is_object($change_record) ? $change_record : json_decode(json_encode($change_record ));302 WC_IZ()->logger->add(sprintf('received_inventory_balance_changed: got balance change %s', json_encode($change_record, JSON_INVALID_UTF8_IGNORE))); 303 304 $change_record = is_object($change_record) ? $change_record : json_decode(json_encode($change_record, JSON_INVALID_UTF8_IGNORE)); 305 305 306 306 if (isset($change_record->change_record_key)) { -
woo-izettle-integration/trunk/woo-izettle-integration.php
r2602846 r2638457 14 14 * Plugin Name: WooCommerce Zettle Integration 15 15 * Plugin URI: https://www.bjorntech.com/woocommerce-zettle/?utm_source=wp-izettle&utm_medium=plugin&utm_campaign=product 16 * Description: Sync ronizes products, purchases and stock-levels.17 * Version: 7. 4.216 * Description: Synchronizes products, purchases and stock levels. 17 * Version: 7.5.0 18 18 * Author: BjornTech AB 19 19 * Author URI: https://www.bjorntech.com/?utm_source=wp-izettle&utm_medium=plugin&utm_campaign=product … … 21 21 * 22 22 * WC requires at least: 4.0 23 * WC tested up to: 5. 723 * WC tested up to: 5.9 24 24 * 25 25 * Copyright: 2017-2020 BjornTech AB … … 73 73 */ 74 74 const NAME = 'WooCommerce Zettle Integration'; 75 const VERSION = '7. 4.2';75 const VERSION = '7.5.0'; 76 76 const SCRIPT_HANDLE = 'wc-izettle-integration'; 77 77 const PLUGIN_FILE = __FILE__; … … 376 376 'version' => $this->version, 377 377 ); 378 $encoded_params = base64_encode(json_encode($site_params ));378 $encoded_params = base64_encode(json_encode($site_params, JSON_INVALID_UTF8_IGNORE)); 379 379 $client_id = $this->client_id; 380 380 $state = array( … … 428 428 429 429 } elseif ('start' == $_POST['task']) { 430 431 as_unschedule_all_actions($id . '_process'); 430 try{ 431 as_unschedule_all_actions($id . '_process'); 432 }catch(\Throwable $throwable){ 433 WC_IZ()->logger->add(sprintf('ajax_wciz_processing_button - No process to unschedule')); 434 } 432 435 $response = array( 433 436 'status' => 'success', … … 476 479 delete_site_transient('zettle_tax_rates'); 477 480 delete_site_transient('zettle_tax_settings'); 478 IZ_Notice::add(' Zettle:New token requested from service', 'success');481 IZ_Notice::add('New token requested from service', 'success'); 479 482 480 483 } catch (IZ_Integration_API_Exception $e) { 481 484 482 485 $e->write_to_logs(); 483 IZ_Notice::add(' Zettle:Error when connecting to service, check logs', 'success');486 IZ_Notice::add('Error when connecting to service, check logs', 'success'); 484 487 485 488 } … … 623 626 { 624 627 $webhook_signing_key = izettle_api()->get_webhook_signing_key(); 625 WC_IZ()->logger->add(sprintf('Webhook signing key %s', $webhook_signing_key));628 WC_IZ()->logger->add(sprintf('Webhook signing key %s', $webhook_signing_key)); 626 629 return hash_hmac( 627 630 'sha256', … … 643 646 if (wc_string_to_bool(get_option('zettle_enable_purchase_processing')) && 1 == get_option('izettle_purchase_sync_model')) { 644 647 $payload = json_decode($request['payload']); 648 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering PurchaseCreated')); 645 649 do_action('izettle_add_purchase_to_queue', $payload->purchaseUuid, true); 646 650 } else { … … 653 657 $payload = json_decode($request['payload']); 654 658 if (!get_site_transient('izettle_stocklevel_update' . $payload->externalUuid)) { 659 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering InventoryBalanceChanged')); 655 660 do_action('izettle_received_inventory_balance_changed_add', $payload, $request['messageId'], true); 656 661 } else { … … 664 669 if ($payload = json_decode($request['payload'])) { 665 670 if (!isset($payload->externalReference)) { 671 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering ProductCreated')); 666 672 do_action('izettle_sync_products_from_izettle_add', $payload, $request['messageId'], true); 667 673 } else { … … 676 682 if ($payload = json_decode($request['payload'])) { 677 683 if (!isset($payload->newEntity->externalReference) || $payload->newEntity->etag != get_post_meta(WC_Zettle_Helper::get_id($payload->newEntity->externalReference), '_izettle_product_etag', true)) { 684 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering ProductUpdated')); 678 685 do_action('izettle_sync_products_from_izettle_add', $payload, $request['messageId'], true, false); 679 686 } else { … … 687 694 if (false !== strpos(get_option('izettle_when_changed_in_izettle'), 'delete')) { 688 695 if ($payload = json_decode($request['payload'])) { 696 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering ProductDeleted')); 689 697 do_action('izettle_delete_product_from_izettle', $payload->uuid, get_option('izettle_force_delete_in_woocommerce') == 'yes'); 690 698 } … … 695 703 if (WC_Zettle_Helper::zettle_changes_stock()) { 696 704 if ($payload = json_decode($request['payload'])) { 705 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering InventoryTrackingStarted')); 697 706 do_action('izettle_received_inventory_tracking_started_add', $payload, $request['messageId'], true); 698 707 } … … 703 712 if (WC_Zettle_Helper::zettle_changes_stock()) { 704 713 if ($payload = json_decode($request['payload'])) { 714 WC_IZ()->logger->add(sprintf('received_webhook_call: Entering InventoryTrackingStopped')); 705 715 do_action('izettle_received_inventory_tracking_stopped_add', $payload, $request['messageId'], true); 706 716 }
Note: See TracChangeset
for help on using the changeset viewer.