Plugin Directory

Changeset 2672287


Ignore:
Timestamp:
02/03/2022 02:39:21 PM (4 years ago)
Author:
bjorntech
Message:

tagging version 5.2.2

Location:
woo-fortnox-hub
Files:
26 edited
1 copied

Legend:

Unmodified
Added
Removed
  • woo-fortnox-hub/tags/5.2.2/includes/admin/class-fortnox-notices.php

    r2635282 r2672287  
    9292        {
    9393            $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;
    9496            echo '<div class="fortnox_notice ' . $dismissable . ' notice notice-' . $type . ' ' . $id . '" id="' . $id . '"><p>' . $message . '</p></div>';
    9597        }
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-customer-handler.php

    r2658743 r2672287  
    176176                    $settings[] = [
    177177                        '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'),
    179179                        'id' => 'fornox_invoice_email_body',
    180180                        'css' => 'width:100%; height: 65px;',
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-fn-product-handler.php

    r2640658 r2672287  
    838838            if ($current_quantity != $disposable_quantity) {
    839839                $new_stocklevel = wc_update_product_stock($product, $disposable_quantity, 'set', true);
     840                $this->trigger_stock_change_notifications($product, $new_stocklevel);
    840841                $changed = true;
    841842                WC_FH()->logger->add(sprintf('process_stocklevel: Changed stock level on WooCommerce product %s from %s to %s', $product_id, $current_quantity, $new_stocklevel));
     
    994995            return $changed;
    995996        }
     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
    9961019    }
    9971020
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-invoice-status-handler.php

    r2647366 r2672287  
    250250
    251251                WC_FH()->logger->add(sprintf('maybe_bookkeep_invoice (%s): Booking Fortnox Invoice %s', $order_id, self::$fn_invoice['DocumentNumber']));
     252
    252253            } catch (Fortnox_API_Exception $e) {
    253 
    254254                $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
    257258        }
    258259
     
    292293
    293294                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
    294296            } catch (Fortnox_API_Exception $e) {
    295 
    296297                $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
    299301        }
    300302
     
    350352
    351353                WC_FH()->logger->add(sprintf('maybe_email_invoice (%s): Emailed Fortnox Invoice %s to customer', $order_id, self::$fn_invoice['DocumentNumber']));
     354
    352355            } catch (Fortnox_API_Exception $e) {
    353 
    354356                $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
    357360        }
    358361
     
    682685
    683686                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));
    685688                    return;
    686689                }
     
    722725
    723726                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
    724728            } catch (Fortnox_API_Exception $e) {
    725 
    726729                $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
    730735    }
    731736
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-invoice.php

    r2658743 r2672287  
    3939                }
    4040
     41                $order = wc_get_order($order_id);
     42
    4143                do_action('woo_fortnox_hub_create_customer', $order_id, true);
    4244
     
    7880                }
    7981
    80                 $order = wc_get_order($order_id);
    81 
    8282                $invoice_details = $this->get_details($order);
    8383
     
    118118            } catch (Fortnox_API_Exception $e) {
    119119                $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()));
    121121                do_action('fortnox_order_sync_failed', $e);
    122122            } catch (Fortnox_Exception $e) {
    123123                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()));
    125125                do_action('fortnox_order_sync_failed', $e);
    126126            }
     127
    127128        }
    128129
     
    137138
    138139                $order = wc_get_order($order_id);
     140
    139141                WC_FH()->logger->add(sprintf('cancelled_invoice (%s): Processing order cancellation', $order_id));
    140142
     
    168170
    169171                WC_FH()->fortnox->cancel_invoice($fn_invoice['DocumentNumber']);
     172
    170173            } catch (Fortnox_API_Exception $e) {
    171 
    172174                $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()));
    175176                do_action('fortnox_order_sync_failed', $e);
    176177            }
     178
    177179        }
    178180
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-lager.php

    r2635282 r2672287  
    3939                }
    4040
     41                $order = wc_get_order($order_id);
     42
    4143                $document_number = WCFH_Util::get_fortnox_invoice_number($order_id);
    4244
     
    7678                }
    7779
    78                 $order = wc_get_order($order_id);
    79 
    8080                $invoice_details = $this->get_details($order);
    8181
     
    109109
    110110                WC_FH()->logger->add(json_encode($full_invoice, JSON_INVALID_UTF8_IGNORE));
     111
    111112            } catch (Fortnox_API_Exception $e) {
    112 
    113113                $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()));
    115115                do_action('fortnox_order_sync_failed', $e);
    116116            }
     117
    117118        }
    118119
     
    127128
    128129                $order = wc_get_order($order_id);
     130
    129131                WC_FH()->logger->add(sprintf('cancelled_lager (%s): Processing order cancellation', $order_id));
    130132
     
    158160
    159161                WC_FH()->fortnox->cancel_invoice($fn_invoice['DocumentNumber']);
     162
    160163            } catch (Fortnox_API_Exception $e) {
    161 
    162164                $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()));
    165166                do_action('fortnox_order_sync_failed', $e);
    166167            }
     168
    167169        }
    168170
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-order.php

    r2658743 r2672287  
    4646                }
    4747
     48                $order = wc_get_order($order_id);
     49
    4850                $document_number = WCFH_Util::get_fortnox_order_documentnumber($order_id);
    4951
     
    7375                do_action('woo_fortnox_hub_create_customer', $order_id, true);
    7476
    75                 $order = wc_get_order($order_id);
    76 
    7777                $order_details = $this->get_details($order);
    7878
     
    111111            } catch (Fortnox_API_Exception $e) {
    112112                $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()));
    114114                do_action('fortnox_order_sync_failed', $e);
    115115            } catch (Fortnox_Exception $e) {
    116116                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()));
    118118                do_action('fortnox_order_sync_failed', $e);
    119119            }
     
    155155                    WC_FH()->fortnox->cancel_order($fn_order['DocumentNumber']);
    156156                }
     157
    157158            } catch (Fortnox_API_Exception $e) {
    158 
    159159                $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
    164164        }
    165165
     
    178178                    return;
    179179                }
     180
     181                $order = wc_get_order($order_id);
    180182
    181183                if ($fn_order_number = WCFH_Util::get_fortnox_order_documentnumber($order_id)) {
     
    186188                    $message = sprintf('Fortnox order %s created Fortnox invoice %s', $fn_order_number, $fn_order['InvoiceReference']);
    187189
    188                     $order = wc_get_order($order_id);
    189190                    $order->set_status('completed', $message);
    190191
    191192                    WC_FH()->logger->add(sprintf('finish_order (%s): %s', $order_id, $message));
    192193                }
     194
    193195            } catch (Fortnox_API_Exception $e) {
    194196
     
    201203
    202204                $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
    206210        }
    207211
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-product-admin.php

    r2635282 r2672287  
    8585
    8686                $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));
    8888            }
    8989
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-refund.php

    r2640658 r2672287  
    2929        public function fully_refunded_invoice($order_id, $refund_id)
    3030        {
     31
    3132            if (!apply_filters('fortnox_hub_filter_woocommerce_order', true, 'fully_refunded_invoice', $order_id)) {
    3233                return;
    3334            }
     35
     36            $order = wc_get_order($order_id);
    3437
    3538            WC_FH()->logger->add(sprintf('fully_refunded_invoice (%s): Processing fully refund order %s', $order_id, $refund_id));
     
    5760                        return;
    5861                    }
    59 
    60                     $order = wc_get_order($order_id);
    6162
    6263                    if (!$order->get_date_paid()) {
     
    110111                    WC_FH()->logger->add(sprintf('fully_refunded_invoice (%s): Cancelled Fortnox order %s', $order_id, $order_number));
    111112                }
     113
    112114            } catch (Fortnox_API_Exception $e) {
    113115                $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
    116119        }
    117120
     
    125128
    126129            try {
     130
     131                $order = wc_get_order($refund_id);
     132
    127133                $invoice_number = WCFH_Util::get_fortnox_invoice_number($order_id);
    128134                if (!$invoice_number) {
     
    141147                    WC_FH()->logger->add(sprintf('partially_refunded_invoice (%s): Fortnox invoice %s have been booked to prepare for credit', $order_id, $invoice_number));
    142148                }
    143 
    144                 $order = wc_get_order($refund_id);
    145149
    146150                WC_FH()->fortnox->credit_invoice($invoice_number);
     
    175179            } catch (Fortnox_API_Exception $e) {
    176180                $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
    179184        }
    180185
  • woo-fortnox-hub/tags/5.2.2/includes/class-woo-fortnox-hub-wc-product-handler.php

    r2658743 r2672287  
    599599                        $code = $e->getCode();
    600600                        $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');
    602602                        WC_FH()->logger->add(sprintf('get_or_create_article (%s): %s:%s when creating article with number "%s"', $product_id, $code, $message, $article_number));
    603603                    } catch (WC_Data_Exception $e) {
    604604                        $code = $e->getCode();
    605605                        $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');
    607607                        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));
    608608                    }
     
    11711171
    11721172                $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));
    11741174            }
    11751175        }
  • woo-fortnox-hub/tags/5.2.2/includes/payment-handlers/klarna/class-woo-fortnox-hub-klarna-handler.php

    r2635282 r2672287  
    215215
    216216                $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()));
    218218
    219219            }
  • woo-fortnox-hub/tags/5.2.2/readme.txt

    r2658743 r2672287  
    33Tags: woocommerce, fortnox, integration, hub, accounting, zettle, klarna, paypal, stripe, swish
    44Requires at least: 4.9
    5 Tested up to: 5.8
     5Tested up to: 5.9
    66Requires PHP: 7.3
    7 Stable tag: 5.2.1
     7Stable tag: 5.2.2
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3434
    3535== 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.
    3641= 5.2.1 =
    3742* Working with WooCommerce 6.1
  • woo-fortnox-hub/tags/5.2.2/woo-fortnox-hub.php

    r2658743 r2672287  
    1616 * Plugin URI:        https://www.bjorntech.com/fortnox-hub?utm_source=wp-fortnox&utm_medium=plugin&utm_campaign=product
    1717 * Description:       Sync your WooCommerce shop with Fortnox
    18  * Version:           5.2.1
     18 * Version:           5.2.2
    1919 * Author:            BjornTech
    2020 * Author URI:        https://bjorntech.com?utm_source=wp-fortnox&utm_medium=plugin&utm_campaign=product
     
    7575         */
    7676        const NAME = 'WooCommerce Fortnox Hub';
    77         const VERSION = '5.2.1';
     77        const VERSION = '5.2.2';
    7878        const CLIENT_ID = 'c8abuXyDQxt2';
    7979        const SCRIPT_HANDLE = 'woo-fortnox-hub';
  • woo-fortnox-hub/trunk/includes/admin/class-fortnox-notices.php

    r2635282 r2672287  
    9292        {
    9393            $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;
    9496            echo '<div class="fortnox_notice ' . $dismissable . ' notice notice-' . $type . ' ' . $id . '" id="' . $id . '"><p>' . $message . '</p></div>';
    9597        }
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-customer-handler.php

    r2658743 r2672287  
    176176                    $settings[] = [
    177177                        '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'),
    179179                        'id' => 'fornox_invoice_email_body',
    180180                        'css' => 'width:100%; height: 65px;',
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-fn-product-handler.php

    r2640658 r2672287  
    838838            if ($current_quantity != $disposable_quantity) {
    839839                $new_stocklevel = wc_update_product_stock($product, $disposable_quantity, 'set', true);
     840                $this->trigger_stock_change_notifications($product, $new_stocklevel);
    840841                $changed = true;
    841842                WC_FH()->logger->add(sprintf('process_stocklevel: Changed stock level on WooCommerce product %s from %s to %s', $product_id, $current_quantity, $new_stocklevel));
     
    994995            return $changed;
    995996        }
     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
    9961019    }
    9971020
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-invoice-status-handler.php

    r2647366 r2672287  
    250250
    251251                WC_FH()->logger->add(sprintf('maybe_bookkeep_invoice (%s): Booking Fortnox Invoice %s', $order_id, self::$fn_invoice['DocumentNumber']));
     252
    252253            } catch (Fortnox_API_Exception $e) {
    253 
    254254                $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
    257258        }
    258259
     
    292293
    293294                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
    294296            } catch (Fortnox_API_Exception $e) {
    295 
    296297                $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
    299301        }
    300302
     
    350352
    351353                WC_FH()->logger->add(sprintf('maybe_email_invoice (%s): Emailed Fortnox Invoice %s to customer', $order_id, self::$fn_invoice['DocumentNumber']));
     354
    352355            } catch (Fortnox_API_Exception $e) {
    353 
    354356                $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
    357360        }
    358361
     
    682685
    683686                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));
    685688                    return;
    686689                }
     
    722725
    723726                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
    724728            } catch (Fortnox_API_Exception $e) {
    725 
    726729                $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
    730735    }
    731736
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-invoice.php

    r2658743 r2672287  
    3939                }
    4040
     41                $order = wc_get_order($order_id);
     42
    4143                do_action('woo_fortnox_hub_create_customer', $order_id, true);
    4244
     
    7880                }
    7981
    80                 $order = wc_get_order($order_id);
    81 
    8282                $invoice_details = $this->get_details($order);
    8383
     
    118118            } catch (Fortnox_API_Exception $e) {
    119119                $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()));
    121121                do_action('fortnox_order_sync_failed', $e);
    122122            } catch (Fortnox_Exception $e) {
    123123                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()));
    125125                do_action('fortnox_order_sync_failed', $e);
    126126            }
     127
    127128        }
    128129
     
    137138
    138139                $order = wc_get_order($order_id);
     140
    139141                WC_FH()->logger->add(sprintf('cancelled_invoice (%s): Processing order cancellation', $order_id));
    140142
     
    168170
    169171                WC_FH()->fortnox->cancel_invoice($fn_invoice['DocumentNumber']);
     172
    170173            } catch (Fortnox_API_Exception $e) {
    171 
    172174                $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()));
    175176                do_action('fortnox_order_sync_failed', $e);
    176177            }
     178
    177179        }
    178180
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-lager.php

    r2635282 r2672287  
    3939                }
    4040
     41                $order = wc_get_order($order_id);
     42
    4143                $document_number = WCFH_Util::get_fortnox_invoice_number($order_id);
    4244
     
    7678                }
    7779
    78                 $order = wc_get_order($order_id);
    79 
    8080                $invoice_details = $this->get_details($order);
    8181
     
    109109
    110110                WC_FH()->logger->add(json_encode($full_invoice, JSON_INVALID_UTF8_IGNORE));
     111
    111112            } catch (Fortnox_API_Exception $e) {
    112 
    113113                $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()));
    115115                do_action('fortnox_order_sync_failed', $e);
    116116            }
     117
    117118        }
    118119
     
    127128
    128129                $order = wc_get_order($order_id);
     130
    129131                WC_FH()->logger->add(sprintf('cancelled_lager (%s): Processing order cancellation', $order_id));
    130132
     
    158160
    159161                WC_FH()->fortnox->cancel_invoice($fn_invoice['DocumentNumber']);
     162
    160163            } catch (Fortnox_API_Exception $e) {
    161 
    162164                $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()));
    165166                do_action('fortnox_order_sync_failed', $e);
    166167            }
     168
    167169        }
    168170
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-order.php

    r2658743 r2672287  
    4646                }
    4747
     48                $order = wc_get_order($order_id);
     49
    4850                $document_number = WCFH_Util::get_fortnox_order_documentnumber($order_id);
    4951
     
    7375                do_action('woo_fortnox_hub_create_customer', $order_id, true);
    7476
    75                 $order = wc_get_order($order_id);
    76 
    7777                $order_details = $this->get_details($order);
    7878
     
    111111            } catch (Fortnox_API_Exception $e) {
    112112                $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()));
    114114                do_action('fortnox_order_sync_failed', $e);
    115115            } catch (Fortnox_Exception $e) {
    116116                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()));
    118118                do_action('fortnox_order_sync_failed', $e);
    119119            }
     
    155155                    WC_FH()->fortnox->cancel_order($fn_order['DocumentNumber']);
    156156                }
     157
    157158            } catch (Fortnox_API_Exception $e) {
    158 
    159159                $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
    164164        }
    165165
     
    178178                    return;
    179179                }
     180
     181                $order = wc_get_order($order_id);
    180182
    181183                if ($fn_order_number = WCFH_Util::get_fortnox_order_documentnumber($order_id)) {
     
    186188                    $message = sprintf('Fortnox order %s created Fortnox invoice %s', $fn_order_number, $fn_order['InvoiceReference']);
    187189
    188                     $order = wc_get_order($order_id);
    189190                    $order->set_status('completed', $message);
    190191
    191192                    WC_FH()->logger->add(sprintf('finish_order (%s): %s', $order_id, $message));
    192193                }
     194
    193195            } catch (Fortnox_API_Exception $e) {
    194196
     
    201203
    202204                $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
    206210        }
    207211
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-product-admin.php

    r2635282 r2672287  
    8585
    8686                $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));
    8888            }
    8989
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-refund.php

    r2640658 r2672287  
    2929        public function fully_refunded_invoice($order_id, $refund_id)
    3030        {
     31
    3132            if (!apply_filters('fortnox_hub_filter_woocommerce_order', true, 'fully_refunded_invoice', $order_id)) {
    3233                return;
    3334            }
     35
     36            $order = wc_get_order($order_id);
    3437
    3538            WC_FH()->logger->add(sprintf('fully_refunded_invoice (%s): Processing fully refund order %s', $order_id, $refund_id));
     
    5760                        return;
    5861                    }
    59 
    60                     $order = wc_get_order($order_id);
    6162
    6263                    if (!$order->get_date_paid()) {
     
    110111                    WC_FH()->logger->add(sprintf('fully_refunded_invoice (%s): Cancelled Fortnox order %s', $order_id, $order_number));
    111112                }
     113
    112114            } catch (Fortnox_API_Exception $e) {
    113115                $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
    116119        }
    117120
     
    125128
    126129            try {
     130
     131                $order = wc_get_order($refund_id);
     132
    127133                $invoice_number = WCFH_Util::get_fortnox_invoice_number($order_id);
    128134                if (!$invoice_number) {
     
    141147                    WC_FH()->logger->add(sprintf('partially_refunded_invoice (%s): Fortnox invoice %s have been booked to prepare for credit', $order_id, $invoice_number));
    142148                }
    143 
    144                 $order = wc_get_order($refund_id);
    145149
    146150                WC_FH()->fortnox->credit_invoice($invoice_number);
     
    175179            } catch (Fortnox_API_Exception $e) {
    176180                $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
    179184        }
    180185
  • woo-fortnox-hub/trunk/includes/class-woo-fortnox-hub-wc-product-handler.php

    r2658743 r2672287  
    599599                        $code = $e->getCode();
    600600                        $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');
    602602                        WC_FH()->logger->add(sprintf('get_or_create_article (%s): %s:%s when creating article with number "%s"', $product_id, $code, $message, $article_number));
    603603                    } catch (WC_Data_Exception $e) {
    604604                        $code = $e->getCode();
    605605                        $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');
    607607                        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));
    608608                    }
     
    11711171
    11721172                $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));
    11741174            }
    11751175        }
  • woo-fortnox-hub/trunk/includes/payment-handlers/klarna/class-woo-fortnox-hub-klarna-handler.php

    r2635282 r2672287  
    215215
    216216                $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()));
    218218
    219219            }
  • woo-fortnox-hub/trunk/readme.txt

    r2658743 r2672287  
    33Tags: woocommerce, fortnox, integration, hub, accounting, zettle, klarna, paypal, stripe, swish
    44Requires at least: 4.9
    5 Tested up to: 5.8
     5Tested up to: 5.9
    66Requires PHP: 7.3
    7 Stable tag: 5.2.1
     7Stable tag: 5.2.2
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3434
    3535== 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.
    3641= 5.2.1 =
    3742* Working with WooCommerce 6.1
  • woo-fortnox-hub/trunk/woo-fortnox-hub.php

    r2658743 r2672287  
    1616 * Plugin URI:        https://www.bjorntech.com/fortnox-hub?utm_source=wp-fortnox&utm_medium=plugin&utm_campaign=product
    1717 * Description:       Sync your WooCommerce shop with Fortnox
    18  * Version:           5.2.1
     18 * Version:           5.2.2
    1919 * Author:            BjornTech
    2020 * Author URI:        https://bjorntech.com?utm_source=wp-fortnox&utm_medium=plugin&utm_campaign=product
     
    7575         */
    7676        const NAME = 'WooCommerce Fortnox Hub';
    77         const VERSION = '5.2.1';
     77        const VERSION = '5.2.2';
    7878        const CLIENT_ID = 'c8abuXyDQxt2';
    7979        const SCRIPT_HANDLE = 'woo-fortnox-hub';
Note: See TracChangeset for help on using the changeset viewer.