Changeset 2672287
- Timestamp:
- 02/03/2022 02:39:21 PM (4 years ago)
- Location:
- woo-fortnox-hub
- Files:
-
- 26 edited
- 1 copied
-
tags/5.2.2 (copied) (copied from woo-fortnox-hub/trunk)
-
tags/5.2.2/includes/admin/class-fortnox-notices.php (modified) (1 diff)
-
tags/5.2.2/includes/class-woo-fortnox-customer-handler.php (modified) (1 diff)
-
tags/5.2.2/includes/class-woo-fortnox-hub-fn-product-handler.php (modified) (2 diffs)
-
tags/5.2.2/includes/class-woo-fortnox-hub-invoice-status-handler.php (modified) (5 diffs)
-
tags/5.2.2/includes/class-woo-fortnox-hub-invoice.php (modified) (5 diffs)
-
tags/5.2.2/includes/class-woo-fortnox-hub-lager.php (modified) (5 diffs)
-
tags/5.2.2/includes/class-woo-fortnox-hub-order.php (modified) (7 diffs)
-
tags/5.2.2/includes/class-woo-fortnox-hub-product-admin.php (modified) (1 diff)
-
tags/5.2.2/includes/class-woo-fortnox-hub-refund.php (modified) (6 diffs)
-
tags/5.2.2/includes/class-woo-fortnox-hub-wc-product-handler.php (modified) (2 diffs)
-
tags/5.2.2/includes/payment-handlers/klarna/class-woo-fortnox-hub-klarna-handler.php (modified) (1 diff)
-
tags/5.2.2/readme.txt (modified) (2 diffs)
-
tags/5.2.2/woo-fortnox-hub.php (modified) (2 diffs)
-
trunk/includes/admin/class-fortnox-notices.php (modified) (1 diff)
-
trunk/includes/class-woo-fortnox-customer-handler.php (modified) (1 diff)
-
trunk/includes/class-woo-fortnox-hub-fn-product-handler.php (modified) (2 diffs)
-
trunk/includes/class-woo-fortnox-hub-invoice-status-handler.php (modified) (5 diffs)
-
trunk/includes/class-woo-fortnox-hub-invoice.php (modified) (5 diffs)
-
trunk/includes/class-woo-fortnox-hub-lager.php (modified) (5 diffs)
-
trunk/includes/class-woo-fortnox-hub-order.php (modified) (7 diffs)
-
trunk/includes/class-woo-fortnox-hub-product-admin.php (modified) (1 diff)
-
trunk/includes/class-woo-fortnox-hub-refund.php (modified) (6 diffs)
-
trunk/includes/class-woo-fortnox-hub-wc-product-handler.php (modified) (2 diffs)
-
trunk/includes/payment-handlers/klarna/class-woo-fortnox-hub-klarna-handler.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/woo-fortnox-hub.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-fortnox-hub/tags/5.2.2/includes/admin/class-fortnox-notices.php
r2635282 r2672287 92 92 { 93 93 $dismissable = $dismiss ? 'is-dismissible' : ''; 94 $date = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), date('U') + (get_option('gmt_offset') * HOUR_IN_SECONDS)); 95 $message = 'Fortnox: ' . $message; 94 96 echo '<div class="fortnox_notice ' . $dismissable . ' notice notice-' . $type . ' ' . $id . '" id="' . $id . '"><p>' . $message . '</p></div>'; 95 97 } -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-customer-handler.php
r2658743 r2672287 176 176 $settings[] = [ 177 177 'title' => __('E-mail body', 'woo-fortnox-hub'), 178 'desc' => __('Body text on the Fortnox mail containing the invoice. The variable {no} = document number. The variable {name} = customer name', 'woo-fortnox-hub'),178 'desc' => __('Body text on the Fortnox mail containing the invoice.', 'woo-fortnox-hub'), 179 179 'id' => 'fornox_invoice_email_body', 180 180 'css' => 'width:100%; height: 65px;', -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-fn-product-handler.php
r2640658 r2672287 838 838 if ($current_quantity != $disposable_quantity) { 839 839 $new_stocklevel = wc_update_product_stock($product, $disposable_quantity, 'set', true); 840 $this->trigger_stock_change_notifications($product, $new_stocklevel); 840 841 $changed = true; 841 842 WC_FH()->logger->add(sprintf('process_stocklevel: Changed stock level on WooCommerce product %s from %s to %s', $product_id, $current_quantity, $new_stocklevel)); … … 994 995 return $changed; 995 996 } 997 998 /** 999 * After stock change events, triggers emails and adds order notes. 1000 * 1001 * @since 3.5.0 1002 * @param WC_Order $order order object. 1003 * @param array $changes Array of changes. 1004 */ 1005 public function trigger_stock_change_notifications($product, $change_to) 1006 { 1007 1008 $no_stock_amount = absint(get_option('woocommerce_notify_no_stock_amount', 0)); 1009 $low_stock_amount = absint(wc_get_low_stock_amount($product)); 1010 1011 if ($change_to <= $no_stock_amount) { 1012 do_action('woocommerce_no_stock', $product); 1013 } elseif ($change_to <= $low_stock_amount) { 1014 do_action('woocommerce_low_stock', $product); 1015 } 1016 1017 } 1018 996 1019 } 997 1020 -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-invoice-status-handler.php
r2647366 r2672287 250 250 251 251 WC_FH()->logger->add(sprintf('maybe_bookkeep_invoice (%s): Booking Fortnox Invoice %s', $order_id, self::$fn_invoice['DocumentNumber'])); 252 252 253 } catch (Fortnox_API_Exception $e) { 253 254 254 $e->write_to_logs(); 255 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 256 } 255 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 256 } 257 257 258 } 258 259 … … 292 293 293 294 WC_FH()->logger->add(sprintf('maybe_external_print_invoice (%s): Did set Fortnox invoice %s as printed externally', $order_id, self::$fn_invoice['DocumentNumber'])); 295 294 296 } catch (Fortnox_API_Exception $e) { 295 296 297 $e->write_to_logs(); 297 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 298 } 298 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 299 } 300 299 301 } 300 302 … … 350 352 351 353 WC_FH()->logger->add(sprintf('maybe_email_invoice (%s): Emailed Fortnox Invoice %s to customer', $order_id, self::$fn_invoice['DocumentNumber'])); 354 352 355 } catch (Fortnox_API_Exception $e) { 353 354 356 $e->write_to_logs(); 355 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 356 } 357 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 358 } 359 357 360 } 358 361 … … 682 685 683 686 if (!$order_id) { 684 WC_FH()->logger->add(sprintf('process_changed_invoices (%s): Fortnox invoice %s did not contain any order information', $order_id, $fn_invoice_number));687 WC_FH()->logger->add(sprintf('process_changed_invoices: Fortnox invoice %s did not contain any order information', $fn_invoice_number)); 685 688 return; 686 689 } … … 722 725 723 726 WC_FH()->logger->add(sprintf('<- process_changed_invoices (%s): Finished processing Fortnox %s %s', $order_id, $is_credit ? 'credit invoice' : 'invoice', $fn_invoice_number)); 727 724 728 } catch (Fortnox_API_Exception $e) { 725 726 729 $e->write_to_logs(); 727 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing changes invoices for order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 728 } 729 } 730 Fortnox_Notice::add(sprintf(__("%s when processing Fortnox Invoice %s", 'woo-fortnox-hub'), $e->getMessage(), $fn_invoice_number)); 731 } 732 733 } 734 730 735 } 731 736 -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-invoice.php
r2658743 r2672287 39 39 } 40 40 41 $order = wc_get_order($order_id); 42 41 43 do_action('woo_fortnox_hub_create_customer', $order_id, true); 42 44 … … 78 80 } 79 81 80 $order = wc_get_order($order_id);81 82 82 $invoice_details = $this->get_details($order); 83 83 … … 118 118 } catch (Fortnox_API_Exception $e) { 119 119 $e->write_to_logs(); 120 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));120 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 121 121 do_action('fortnox_order_sync_failed', $e); 122 122 } catch (Fortnox_Exception $e) { 123 123 WC_FH()->logger->add($e->getMessage()); 124 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));124 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 125 125 do_action('fortnox_order_sync_failed', $e); 126 126 } 127 127 128 } 128 129 … … 137 138 138 139 $order = wc_get_order($order_id); 140 139 141 WC_FH()->logger->add(sprintf('cancelled_invoice (%s): Processing order cancellation', $order_id)); 140 142 … … 168 170 169 171 WC_FH()->fortnox->cancel_invoice($fn_invoice['DocumentNumber']); 172 170 173 } catch (Fortnox_API_Exception $e) { 171 172 174 $e->write_to_logs(); 173 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 174 175 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 175 176 do_action('fortnox_order_sync_failed', $e); 176 177 } 178 177 179 } 178 180 -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-lager.php
r2635282 r2672287 39 39 } 40 40 41 $order = wc_get_order($order_id); 42 41 43 $document_number = WCFH_Util::get_fortnox_invoice_number($order_id); 42 44 … … 76 78 } 77 79 78 $order = wc_get_order($order_id);79 80 80 $invoice_details = $this->get_details($order); 81 81 … … 109 109 110 110 WC_FH()->logger->add(json_encode($full_invoice, JSON_INVALID_UTF8_IGNORE)); 111 111 112 } catch (Fortnox_API_Exception $e) { 112 113 113 $e->write_to_logs(); 114 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));114 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 115 115 do_action('fortnox_order_sync_failed', $e); 116 116 } 117 117 118 } 118 119 … … 127 128 128 129 $order = wc_get_order($order_id); 130 129 131 WC_FH()->logger->add(sprintf('cancelled_lager (%s): Processing order cancellation', $order_id)); 130 132 … … 158 160 159 161 WC_FH()->fortnox->cancel_invoice($fn_invoice['DocumentNumber']); 162 160 163 } catch (Fortnox_API_Exception $e) { 161 162 164 $e->write_to_logs(); 163 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 164 165 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 165 166 do_action('fortnox_order_sync_failed', $e); 166 167 } 168 167 169 } 168 170 -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-order.php
r2658743 r2672287 46 46 } 47 47 48 $order = wc_get_order($order_id); 49 48 50 $document_number = WCFH_Util::get_fortnox_order_documentnumber($order_id); 49 51 … … 73 75 do_action('woo_fortnox_hub_create_customer', $order_id, true); 74 76 75 $order = wc_get_order($order_id);76 77 77 $order_details = $this->get_details($order); 78 78 … … 111 111 } catch (Fortnox_API_Exception $e) { 112 112 $e->write_to_logs(); 113 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));113 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 114 114 do_action('fortnox_order_sync_failed', $e); 115 115 } catch (Fortnox_Exception $e) { 116 116 WC_FH()->logger->add($e->getMessage()); 117 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));117 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 118 118 do_action('fortnox_order_sync_failed', $e); 119 119 } … … 155 155 WC_FH()->fortnox->cancel_order($fn_order['DocumentNumber']); 156 156 } 157 157 158 } catch (Fortnox_API_Exception $e) { 158 159 159 $e->write_to_logs(); 160 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));161 162 do_action('fortnox_order_sync_failed', $e);163 } 160 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 161 do_action('fortnox_order_sync_failed', $e); 162 } 163 164 164 } 165 165 … … 178 178 return; 179 179 } 180 181 $order = wc_get_order($order_id); 180 182 181 183 if ($fn_order_number = WCFH_Util::get_fortnox_order_documentnumber($order_id)) { … … 186 188 $message = sprintf('Fortnox order %s created Fortnox invoice %s', $fn_order_number, $fn_order['InvoiceReference']); 187 189 188 $order = wc_get_order($order_id);189 190 $order->set_status('completed', $message); 190 191 191 192 WC_FH()->logger->add(sprintf('finish_order (%s): %s', $order_id, $message)); 192 193 } 194 193 195 } catch (Fortnox_API_Exception $e) { 194 196 … … 201 203 202 204 $e->write_to_logs(); 203 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 204 do_action('fortnox_order_sync_failed', $e); 205 } 205 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 206 do_action('fortnox_order_sync_failed', $e); 207 208 } 209 206 210 } 207 211 -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-product-admin.php
r2635282 r2672287 85 85 86 86 $e->write_to_logs(); 87 Fortnox_Notice::add(sprintf(__(" Fortnox Hub:%s when manually syncing product %s", 'woo-fortnox-hub'), $e->getMessage(), $product_id));87 Fortnox_Notice::add(sprintf(__("%s when manually syncing product %s", 'woo-fortnox-hub'), $e->getMessage(), $product_id)); 88 88 } 89 89 -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-refund.php
r2640658 r2672287 29 29 public function fully_refunded_invoice($order_id, $refund_id) 30 30 { 31 31 32 if (!apply_filters('fortnox_hub_filter_woocommerce_order', true, 'fully_refunded_invoice', $order_id)) { 32 33 return; 33 34 } 35 36 $order = wc_get_order($order_id); 34 37 35 38 WC_FH()->logger->add(sprintf('fully_refunded_invoice (%s): Processing fully refund order %s', $order_id, $refund_id)); … … 57 60 return; 58 61 } 59 60 $order = wc_get_order($order_id);61 62 62 63 if (!$order->get_date_paid()) { … … 110 111 WC_FH()->logger->add(sprintf('fully_refunded_invoice (%s): Cancelled Fortnox order %s', $order_id, $order_number)); 111 112 } 113 112 114 } catch (Fortnox_API_Exception $e) { 113 115 $e->write_to_logs(); 114 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when refunding order %s fully", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 115 } 116 Fortnox_Notice::add(sprintf(__("%s when refunding order %s fully", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 117 } 118 116 119 } 117 120 … … 125 128 126 129 try { 130 131 $order = wc_get_order($refund_id); 132 127 133 $invoice_number = WCFH_Util::get_fortnox_invoice_number($order_id); 128 134 if (!$invoice_number) { … … 141 147 WC_FH()->logger->add(sprintf('partially_refunded_invoice (%s): Fortnox invoice %s have been booked to prepare for credit', $order_id, $invoice_number)); 142 148 } 143 144 $order = wc_get_order($refund_id);145 149 146 150 WC_FH()->fortnox->credit_invoice($invoice_number); … … 175 179 } catch (Fortnox_API_Exception $e) { 176 180 $e->write_to_logs(); 177 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when partally refunding order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 178 } 181 Fortnox_Notice::add(sprintf(__("%s when partally refunding order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 182 } 183 179 184 } 180 185 -
woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-wc-product-handler.php
r2658743 r2672287 599 599 $code = $e->getCode(); 600 600 $message = $e->getMessage(); 601 Fortnox_Notice::add(sprintf(__(' Fortnox Hub:%s when creating article from WooCommerce product %s using SKU "%s"', 'woo-fortnox-hub'), $message, $product_id, $article_number), 'error');601 Fortnox_Notice::add(sprintf(__('%s when creating article from WooCommerce product %s using SKU "%s"', 'woo-fortnox-hub'), $message, $product_id, $article_number), 'error'); 602 602 WC_FH()->logger->add(sprintf('get_or_create_article (%s): %s:%s when creating article with number "%s"', $product_id, $code, $message, $article_number)); 603 603 } catch (WC_Data_Exception $e) { 604 604 $code = $e->getCode(); 605 605 $message = $e->getMessage(); 606 Fortnox_Notice::add(sprintf(__(' Fortnox Hub:%s when creating article from WooCommerce product %s with new article number "%s" received from Fortnox', 'woo-fortnox-hub'), $message, $product_id, $article_number), 'error');606 Fortnox_Notice::add(sprintf(__('%s when creating article from WooCommerce product %s with new article number "%s" received from Fortnox', 'woo-fortnox-hub'), $message, $product_id, $article_number), 'error'); 607 607 WC_FH()->logger->add(sprintf('get_or_create_article (%s): %s when creating article with new article number "%s" received from Fortnox', $product_id, $message, $article_number)); 608 608 } … … 1171 1171 1172 1172 $e->write_to_logs(); 1173 Fortnox_Notice::add(sprintf(__(" Fortnox Hub:%s when syncing product %s", 'woo-fortnox-hub'), $e->getMessage(), $product_id));1173 Fortnox_Notice::add(sprintf(__("%s when syncing product %s", 'woo-fortnox-hub'), $e->getMessage(), $product_id)); 1174 1174 } 1175 1175 } -
woo-fortnox-hub/tags/5.2.2/includes/payment-handlers/klarna/class-woo-fortnox-hub-klarna-handler.php
r2635282 r2672287 215 215 216 216 $e->write_to_logs(); 217 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));217 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 218 218 219 219 } -
woo-fortnox-hub/tags/5.2.2/readme.txt
r2658743 r2672287 3 3 Tags: woocommerce, fortnox, integration, hub, accounting, zettle, klarna, paypal, stripe, swish 4 4 Requires at least: 4.9 5 Tested up to: 5. 85 Tested up to: 5.9 6 6 Requires PHP: 7.3 7 Stable tag: 5.2. 17 Stable tag: 5.2.2 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 34 34 35 35 == Changelog == 36 = 5.2.2 = 37 * Working with Wordpress 5.9 38 * Fix: Stockchange from Fortnox did not trigger low-/outof-stock emails. 39 * Fix: Order numbers are now printed instead of order id in Error messages. 40 * Fix: Faulty description of Fortnox e-mail body. 36 41 = 5.2.1 = 37 42 * Working with WooCommerce 6.1 -
woo-fortnox-hub/tags/5.2.2/woo-fortnox-hub.php
r2658743 r2672287 16 16 * Plugin URI: https://www.bjorntech.com/fortnox-hub?utm_source=wp-fortnox&utm_medium=plugin&utm_campaign=product 17 17 * Description: Sync your WooCommerce shop with Fortnox 18 * Version: 5.2. 118 * Version: 5.2.2 19 19 * Author: BjornTech 20 20 * Author URI: https://bjorntech.com?utm_source=wp-fortnox&utm_medium=plugin&utm_campaign=product … … 75 75 */ 76 76 const NAME = 'WooCommerce Fortnox Hub'; 77 const VERSION = '5.2. 1';77 const VERSION = '5.2.2'; 78 78 const CLIENT_ID = 'c8abuXyDQxt2'; 79 79 const SCRIPT_HANDLE = 'woo-fortnox-hub'; -
woo-fortnox-hub/trunk/includes/admin/class-fortnox-notices.php
r2635282 r2672287 92 92 { 93 93 $dismissable = $dismiss ? 'is-dismissible' : ''; 94 $date = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), date('U') + (get_option('gmt_offset') * HOUR_IN_SECONDS)); 95 $message = 'Fortnox: ' . $message; 94 96 echo '<div class="fortnox_notice ' . $dismissable . ' notice notice-' . $type . ' ' . $id . '" id="' . $id . '"><p>' . $message . '</p></div>'; 95 97 } -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-customer-handler.php
r2658743 r2672287 176 176 $settings[] = [ 177 177 'title' => __('E-mail body', 'woo-fortnox-hub'), 178 'desc' => __('Body text on the Fortnox mail containing the invoice. The variable {no} = document number. The variable {name} = customer name', 'woo-fortnox-hub'),178 'desc' => __('Body text on the Fortnox mail containing the invoice.', 'woo-fortnox-hub'), 179 179 'id' => 'fornox_invoice_email_body', 180 180 'css' => 'width:100%; height: 65px;', -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-fn-product-handler.php
r2640658 r2672287 838 838 if ($current_quantity != $disposable_quantity) { 839 839 $new_stocklevel = wc_update_product_stock($product, $disposable_quantity, 'set', true); 840 $this->trigger_stock_change_notifications($product, $new_stocklevel); 840 841 $changed = true; 841 842 WC_FH()->logger->add(sprintf('process_stocklevel: Changed stock level on WooCommerce product %s from %s to %s', $product_id, $current_quantity, $new_stocklevel)); … … 994 995 return $changed; 995 996 } 997 998 /** 999 * After stock change events, triggers emails and adds order notes. 1000 * 1001 * @since 3.5.0 1002 * @param WC_Order $order order object. 1003 * @param array $changes Array of changes. 1004 */ 1005 public function trigger_stock_change_notifications($product, $change_to) 1006 { 1007 1008 $no_stock_amount = absint(get_option('woocommerce_notify_no_stock_amount', 0)); 1009 $low_stock_amount = absint(wc_get_low_stock_amount($product)); 1010 1011 if ($change_to <= $no_stock_amount) { 1012 do_action('woocommerce_no_stock', $product); 1013 } elseif ($change_to <= $low_stock_amount) { 1014 do_action('woocommerce_low_stock', $product); 1015 } 1016 1017 } 1018 996 1019 } 997 1020 -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-invoice-status-handler.php
r2647366 r2672287 250 250 251 251 WC_FH()->logger->add(sprintf('maybe_bookkeep_invoice (%s): Booking Fortnox Invoice %s', $order_id, self::$fn_invoice['DocumentNumber'])); 252 252 253 } catch (Fortnox_API_Exception $e) { 253 254 254 $e->write_to_logs(); 255 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 256 } 255 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 256 } 257 257 258 } 258 259 … … 292 293 293 294 WC_FH()->logger->add(sprintf('maybe_external_print_invoice (%s): Did set Fortnox invoice %s as printed externally', $order_id, self::$fn_invoice['DocumentNumber'])); 295 294 296 } catch (Fortnox_API_Exception $e) { 295 296 297 $e->write_to_logs(); 297 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 298 } 298 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 299 } 300 299 301 } 300 302 … … 350 352 351 353 WC_FH()->logger->add(sprintf('maybe_email_invoice (%s): Emailed Fortnox Invoice %s to customer', $order_id, self::$fn_invoice['DocumentNumber'])); 354 352 355 } catch (Fortnox_API_Exception $e) { 353 354 356 $e->write_to_logs(); 355 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 356 } 357 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 358 } 359 357 360 } 358 361 … … 682 685 683 686 if (!$order_id) { 684 WC_FH()->logger->add(sprintf('process_changed_invoices (%s): Fortnox invoice %s did not contain any order information', $order_id, $fn_invoice_number));687 WC_FH()->logger->add(sprintf('process_changed_invoices: Fortnox invoice %s did not contain any order information', $fn_invoice_number)); 685 688 return; 686 689 } … … 722 725 723 726 WC_FH()->logger->add(sprintf('<- process_changed_invoices (%s): Finished processing Fortnox %s %s', $order_id, $is_credit ? 'credit invoice' : 'invoice', $fn_invoice_number)); 727 724 728 } catch (Fortnox_API_Exception $e) { 725 726 729 $e->write_to_logs(); 727 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing changes invoices for order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 728 } 729 } 730 Fortnox_Notice::add(sprintf(__("%s when processing Fortnox Invoice %s", 'woo-fortnox-hub'), $e->getMessage(), $fn_invoice_number)); 731 } 732 733 } 734 730 735 } 731 736 -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-invoice.php
r2658743 r2672287 39 39 } 40 40 41 $order = wc_get_order($order_id); 42 41 43 do_action('woo_fortnox_hub_create_customer', $order_id, true); 42 44 … … 78 80 } 79 81 80 $order = wc_get_order($order_id);81 82 82 $invoice_details = $this->get_details($order); 83 83 … … 118 118 } catch (Fortnox_API_Exception $e) { 119 119 $e->write_to_logs(); 120 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));120 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 121 121 do_action('fortnox_order_sync_failed', $e); 122 122 } catch (Fortnox_Exception $e) { 123 123 WC_FH()->logger->add($e->getMessage()); 124 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));124 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 125 125 do_action('fortnox_order_sync_failed', $e); 126 126 } 127 127 128 } 128 129 … … 137 138 138 139 $order = wc_get_order($order_id); 140 139 141 WC_FH()->logger->add(sprintf('cancelled_invoice (%s): Processing order cancellation', $order_id)); 140 142 … … 168 170 169 171 WC_FH()->fortnox->cancel_invoice($fn_invoice['DocumentNumber']); 172 170 173 } catch (Fortnox_API_Exception $e) { 171 172 174 $e->write_to_logs(); 173 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 174 175 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 175 176 do_action('fortnox_order_sync_failed', $e); 176 177 } 178 177 179 } 178 180 -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-lager.php
r2635282 r2672287 39 39 } 40 40 41 $order = wc_get_order($order_id); 42 41 43 $document_number = WCFH_Util::get_fortnox_invoice_number($order_id); 42 44 … … 76 78 } 77 79 78 $order = wc_get_order($order_id);79 80 80 $invoice_details = $this->get_details($order); 81 81 … … 109 109 110 110 WC_FH()->logger->add(json_encode($full_invoice, JSON_INVALID_UTF8_IGNORE)); 111 111 112 } catch (Fortnox_API_Exception $e) { 112 113 113 $e->write_to_logs(); 114 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));114 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 115 115 do_action('fortnox_order_sync_failed', $e); 116 116 } 117 117 118 } 118 119 … … 127 128 128 129 $order = wc_get_order($order_id); 130 129 131 WC_FH()->logger->add(sprintf('cancelled_lager (%s): Processing order cancellation', $order_id)); 130 132 … … 158 160 159 161 WC_FH()->fortnox->cancel_invoice($fn_invoice['DocumentNumber']); 162 160 163 } catch (Fortnox_API_Exception $e) { 161 162 164 $e->write_to_logs(); 163 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 164 165 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 165 166 do_action('fortnox_order_sync_failed', $e); 166 167 } 168 167 169 } 168 170 -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-order.php
r2658743 r2672287 46 46 } 47 47 48 $order = wc_get_order($order_id); 49 48 50 $document_number = WCFH_Util::get_fortnox_order_documentnumber($order_id); 49 51 … … 73 75 do_action('woo_fortnox_hub_create_customer', $order_id, true); 74 76 75 $order = wc_get_order($order_id);76 77 77 $order_details = $this->get_details($order); 78 78 … … 111 111 } catch (Fortnox_API_Exception $e) { 112 112 $e->write_to_logs(); 113 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));113 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 114 114 do_action('fortnox_order_sync_failed', $e); 115 115 } catch (Fortnox_Exception $e) { 116 116 WC_FH()->logger->add($e->getMessage()); 117 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));117 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 118 118 do_action('fortnox_order_sync_failed', $e); 119 119 } … … 155 155 WC_FH()->fortnox->cancel_order($fn_order['DocumentNumber']); 156 156 } 157 157 158 } catch (Fortnox_API_Exception $e) { 158 159 159 $e->write_to_logs(); 160 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));161 162 do_action('fortnox_order_sync_failed', $e);163 } 160 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 161 do_action('fortnox_order_sync_failed', $e); 162 } 163 164 164 } 165 165 … … 178 178 return; 179 179 } 180 181 $order = wc_get_order($order_id); 180 182 181 183 if ($fn_order_number = WCFH_Util::get_fortnox_order_documentnumber($order_id)) { … … 186 188 $message = sprintf('Fortnox order %s created Fortnox invoice %s', $fn_order_number, $fn_order['InvoiceReference']); 187 189 188 $order = wc_get_order($order_id);189 190 $order->set_status('completed', $message); 190 191 191 192 WC_FH()->logger->add(sprintf('finish_order (%s): %s', $order_id, $message)); 192 193 } 194 193 195 } catch (Fortnox_API_Exception $e) { 194 196 … … 201 203 202 204 $e->write_to_logs(); 203 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 204 do_action('fortnox_order_sync_failed', $e); 205 } 205 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 206 do_action('fortnox_order_sync_failed', $e); 207 208 } 209 206 210 } 207 211 -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-product-admin.php
r2635282 r2672287 85 85 86 86 $e->write_to_logs(); 87 Fortnox_Notice::add(sprintf(__(" Fortnox Hub:%s when manually syncing product %s", 'woo-fortnox-hub'), $e->getMessage(), $product_id));87 Fortnox_Notice::add(sprintf(__("%s when manually syncing product %s", 'woo-fortnox-hub'), $e->getMessage(), $product_id)); 88 88 } 89 89 -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-refund.php
r2640658 r2672287 29 29 public function fully_refunded_invoice($order_id, $refund_id) 30 30 { 31 31 32 if (!apply_filters('fortnox_hub_filter_woocommerce_order', true, 'fully_refunded_invoice', $order_id)) { 32 33 return; 33 34 } 35 36 $order = wc_get_order($order_id); 34 37 35 38 WC_FH()->logger->add(sprintf('fully_refunded_invoice (%s): Processing fully refund order %s', $order_id, $refund_id)); … … 57 60 return; 58 61 } 59 60 $order = wc_get_order($order_id);61 62 62 63 if (!$order->get_date_paid()) { … … 110 111 WC_FH()->logger->add(sprintf('fully_refunded_invoice (%s): Cancelled Fortnox order %s', $order_id, $order_number)); 111 112 } 113 112 114 } catch (Fortnox_API_Exception $e) { 113 115 $e->write_to_logs(); 114 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when refunding order %s fully", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 115 } 116 Fortnox_Notice::add(sprintf(__("%s when refunding order %s fully", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 117 } 118 116 119 } 117 120 … … 125 128 126 129 try { 130 131 $order = wc_get_order($refund_id); 132 127 133 $invoice_number = WCFH_Util::get_fortnox_invoice_number($order_id); 128 134 if (!$invoice_number) { … … 141 147 WC_FH()->logger->add(sprintf('partially_refunded_invoice (%s): Fortnox invoice %s have been booked to prepare for credit', $order_id, $invoice_number)); 142 148 } 143 144 $order = wc_get_order($refund_id);145 149 146 150 WC_FH()->fortnox->credit_invoice($invoice_number); … … 175 179 } catch (Fortnox_API_Exception $e) { 176 180 $e->write_to_logs(); 177 Fortnox_Notice::add(sprintf(__("Fortnox Hub: %s when partally refunding order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id)); 178 } 181 Fortnox_Notice::add(sprintf(__("%s when partally refunding order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 182 } 183 179 184 } 180 185 -
woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-wc-product-handler.php
r2658743 r2672287 599 599 $code = $e->getCode(); 600 600 $message = $e->getMessage(); 601 Fortnox_Notice::add(sprintf(__(' Fortnox Hub:%s when creating article from WooCommerce product %s using SKU "%s"', 'woo-fortnox-hub'), $message, $product_id, $article_number), 'error');601 Fortnox_Notice::add(sprintf(__('%s when creating article from WooCommerce product %s using SKU "%s"', 'woo-fortnox-hub'), $message, $product_id, $article_number), 'error'); 602 602 WC_FH()->logger->add(sprintf('get_or_create_article (%s): %s:%s when creating article with number "%s"', $product_id, $code, $message, $article_number)); 603 603 } catch (WC_Data_Exception $e) { 604 604 $code = $e->getCode(); 605 605 $message = $e->getMessage(); 606 Fortnox_Notice::add(sprintf(__(' Fortnox Hub:%s when creating article from WooCommerce product %s with new article number "%s" received from Fortnox', 'woo-fortnox-hub'), $message, $product_id, $article_number), 'error');606 Fortnox_Notice::add(sprintf(__('%s when creating article from WooCommerce product %s with new article number "%s" received from Fortnox', 'woo-fortnox-hub'), $message, $product_id, $article_number), 'error'); 607 607 WC_FH()->logger->add(sprintf('get_or_create_article (%s): %s when creating article with new article number "%s" received from Fortnox', $product_id, $message, $article_number)); 608 608 } … … 1171 1171 1172 1172 $e->write_to_logs(); 1173 Fortnox_Notice::add(sprintf(__(" Fortnox Hub:%s when syncing product %s", 'woo-fortnox-hub'), $e->getMessage(), $product_id));1173 Fortnox_Notice::add(sprintf(__("%s when syncing product %s", 'woo-fortnox-hub'), $e->getMessage(), $product_id)); 1174 1174 } 1175 1175 } -
woo-fortnox-hub/trunk/includes/payment-handlers/klarna/class-woo-fortnox-hub-klarna-handler.php
r2635282 r2672287 215 215 216 216 $e->write_to_logs(); 217 Fortnox_Notice::add(sprintf(__(" Fortnox Hub: %s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order_id));217 Fortnox_Notice::add(sprintf(__("%s when processing order %s", 'woo-fortnox-hub'), $e->getMessage(), $order->get_order_number())); 218 218 219 219 } -
woo-fortnox-hub/trunk/readme.txt
r2658743 r2672287 3 3 Tags: woocommerce, fortnox, integration, hub, accounting, zettle, klarna, paypal, stripe, swish 4 4 Requires at least: 4.9 5 Tested up to: 5. 85 Tested up to: 5.9 6 6 Requires PHP: 7.3 7 Stable tag: 5.2. 17 Stable tag: 5.2.2 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 34 34 35 35 == Changelog == 36 = 5.2.2 = 37 * Working with Wordpress 5.9 38 * Fix: Stockchange from Fortnox did not trigger low-/outof-stock emails. 39 * Fix: Order numbers are now printed instead of order id in Error messages. 40 * Fix: Faulty description of Fortnox e-mail body. 36 41 = 5.2.1 = 37 42 * Working with WooCommerce 6.1 -
woo-fortnox-hub/trunk/woo-fortnox-hub.php
r2658743 r2672287 16 16 * Plugin URI: https://www.bjorntech.com/fortnox-hub?utm_source=wp-fortnox&utm_medium=plugin&utm_campaign=product 17 17 * Description: Sync your WooCommerce shop with Fortnox 18 * Version: 5.2. 118 * Version: 5.2.2 19 19 * Author: BjornTech 20 20 * Author URI: https://bjorntech.com?utm_source=wp-fortnox&utm_medium=plugin&utm_campaign=product … … 75 75 */ 76 76 const NAME = 'WooCommerce Fortnox Hub'; 77 const VERSION = '5.2. 1';77 const VERSION = '5.2.2'; 78 78 const CLIENT_ID = 'c8abuXyDQxt2'; 79 79 const SCRIPT_HANDLE = 'woo-fortnox-hub';
Note: See TracChangeset
for help on using the changeset viewer.