Plugin Directory

Changeset 3761245


Ignore:
Timestamp:
10/23/2026 09:09:10 AM (62 minutes ago)
Author:
molonidevteam
Message:

Update to version 4.0.14 from GitHub

Location:
moloni-on
Files:
2 added
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • moloni-on/tags/4.0.14/moloni-on.php

    r3754588 r3761245  
    55 *   Requires Plugins: woocommerce
    66 *   Description:  Simple invoicing integration with Moloni ON.
    7  *   Version:      4.0.13
     7 *   Version:      4.0.14
    88 *   Tested up to: 7.0
    99 *   WC tested up to: 10.7.0
  • moloni-on/tags/4.0.14/readme.txt

    r3754588 r3761245  
    33Requires Plugins: woocommerce
    44Tags: invoicing, orders
    5 Stable tag: 4.0.13
     5Stable tag: 4.0.14
    66Tested up to: 7.0
    77WC tested up to: 10.7.0
    … …  
    5959
    6060== Changelog ==
     61= 4.0.14=
     62* Install a single Moloni ON Product webhook instead of one per operation, so the plugin uses fewer webhooks from the plan's quota. Existing shops switch to it the next time they save the automation settings or reinstall the webhooks.
     63
    6164= 4.0.13=
    6265* Create the shipping and fee products with a fixed name, so they no longer keep the first order's shipping method or fee name forever.
  • moloni-on/tags/4.0.14/src/API/Queries/hooks.graphql

    r3675991 r3761245  
    1414            msg
    1515        }
     16        options
     17        {
     18            pagination
     19            {
     20                page
     21                qty
     22                count
     23            }
     24        }
    1625    }
    1726}
  • moloni-on/tags/4.0.14/src/Helpers/WebHooks.php

    r3487173 r3761245  
    2323     * Create hook in moloni
    2424     *
     25     * Omit $operation (or pass null) to receive every operation of the model in one hook.
     26     *
    2527     * @param string $model
    26      * @param string $operation
     28     * @param string|null $operation
    2729     *
    2830     * @throws APIExeption
    2931     */
    30     public static function createHook(string $model, string $operation)
     32    public static function createHook(string $model, ?string $operation = null)
    3133    {
    3234        if (!isset(self::$routes[$model])) {
    … …  
    4345            'model' => $model,
    4446            'url' => $url,
    45             'operation' => $operation
    4647        ];
     48
     49        if ($operation !== null) {
     50            $variables['data']['operation'] = $operation;
     51        }
    4752
    4853        Hooks::mutationHookCreate($variables);
    … …  
    5863        $ids = [];
    5964
     65        /** Filter by this site's URL — without it the query returns (and we'd delete) every hook of the company */
    6066        $variables = [
    61             'data' => [
     67            'options' => [
    6268                'search' => [
    6369                    'field' => 'url',
  • moloni-on/tags/4.0.14/src/Plugin.php

    r3569805 r3761245  
    293293            WebHooks::deleteHooks();
    294294
    295             if (Context::settings()->getInt('hook_stock_sync') === Boolean::YES) {
    296                 WebHooks::createHook('Product', 'stockChanged');
    297             }
    298 
    299             if (Context::settings()->getInt('hook_product_sync') === Boolean::YES) {
    300                 WebHooks::createHook('Product', 'create');
    301                 WebHooks::createHook('Product', 'update');
     295            if (
     296                Context::settings()->getInt('hook_stock_sync') === Boolean::YES ||
     297                Context::settings()->getInt('hook_product_sync') === Boolean::YES
     298            ) {
     299                WebHooks::createHook('Product');
    302300            }
    303301
    … …  
    354352            WebHooks::deleteHooks();
    355353
    356             if (isset($options['hook_stock_sync']) && (int)$options['hook_stock_sync'] === Boolean::YES) {
    357                 WebHooks::createHook('Product', 'stockChanged');
    358             }
    359 
    360             if (isset($options['hook_product_sync']) && (int)$options['hook_product_sync'] === Boolean::YES) {
    361                 WebHooks::createHook('Product', 'create');
    362                 WebHooks::createHook('Product', 'update');
     354            $hookStockSync = isset($options['hook_stock_sync']) && (int)$options['hook_stock_sync'] === Boolean::YES;
     355            $hookProductSync = isset($options['hook_product_sync']) && (int)$options['hook_product_sync'] === Boolean::YES;
     356
     357            if ($hookStockSync || $hookProductSync) {
     358                WebHooks::createHook('Product');
    363359            }
    364360        } catch (APIExeption $e) {
  • moloni-on/tags/4.0.14/src/WebHooks/Products.php

    r3511501 r3761245  
    7373            $productId = (int)sanitize_text_field($parameters['productId']);
    7474
    75             $this->fetchMoloniProduct($productId);
    76 
    77             //switch between operations
    78             switch ($parameters['operation']) {
     75            /**
     76             * One hook receives every Product operation. Each handler checks its own setting
     77             * before fetching the Moloni product, so a disabled sync costs no API call.
     78             * Other operations (e.g. delete) are acknowledged and ignored.
     79             */
     80            switch ($parameters['operation'] ?? '') {
    7981                case 'create':
    80                     $this->onCreate();
     82                    $this->onCreate($productId);
    8183                    break;
    8284                case 'update':
    83                     $this->onUpdate();
     85                    $this->onUpdate($productId);
    8486                    break;
    8587                case 'stockChanged':
    86                     $this->onStockUpdate();
     88                    $this->onStockUpdate($productId);
    8789                    break;
    8890            }
    … …  
    127129     * Create action
    128130     *
     131     * @param int $productId Moloni product id
     132     *
    129133     * @throws WebhookException
    130134     */
    131     private function onCreate()
     135    private function onCreate(int $productId)
    132136    {
    133137        if (!$this->shouldSyncProduct()) {
    134138            return;
    135139        }
     140
     141        $this->fetchMoloniProduct($productId);
    136142
    137143        $this->validateMoloniProduct();
    … …  
    175181     * On Moloni product update action
    176182     *
     183     * @param int $productId Moloni product id
     184     *
    177185     * @throws HelperException|WebhookException
    178186     */
    179     private function onUpdate()
     187    private function onUpdate(int $productId)
    180188    {
    181189        if (!$this->shouldSyncProduct()) {
    182190            return;
    183191        }
     192
     193        $this->fetchMoloniProduct($productId);
    184194
    185195        $this->validateMoloniProduct();
    … …  
    237247     * On Moloni stock update
    238248     *
     249     * @param int $productId Moloni product id
     250     *
    239251     * @throws HelperException|WebhookException
    240252     */
    241     private function onStockUpdate()
     253    private function onStockUpdate(int $productId)
    242254    {
    243255        if (!$this->shouldSyncStock()) {
    244256            return;
    245257        }
     258
     259        $this->fetchMoloniProduct($productId);
    246260
    247261        $this->validateMoloniProduct();
  • moloni-on/tags/4.0.14/vendor/composer/installed.php

    r3754588 r3761245  
    22    'root' => array(
    33        'name' => 'moloni/woocommerce-dev',
    4         'pretty_version' => 'v4.0.13',
    5         'version' => '4.0.13.0',
    6         'reference' => '18091161cfb0f7b4d3aca78ab0a4c56e4ea165c6',
     4        'pretty_version' => 'v4.0.14',
     5        'version' => '4.0.14.0',
     6        'reference' => '776d7f8f79f81afe54a9122788f74c3297243b69',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
    … …  
    1212    'versions' => array(
    1313        'moloni/woocommerce-dev' => array(
    14             'pretty_version' => 'v4.0.13',
    15             'version' => '4.0.13.0',
    16             'reference' => '18091161cfb0f7b4d3aca78ab0a4c56e4ea165c6',
     14            'pretty_version' => 'v4.0.14',
     15            'version' => '4.0.14.0',
     16            'reference' => '776d7f8f79f81afe54a9122788f74c3297243b69',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • moloni-on/trunk/moloni-on.php

    r3754588 r3761245  
    55 *   Requires Plugins: woocommerce
    66 *   Description:  Simple invoicing integration with Moloni ON.
    7  *   Version:      4.0.13
     7 *   Version:      4.0.14
    88 *   Tested up to: 7.0
    99 *   WC tested up to: 10.7.0
  • moloni-on/trunk/readme.txt

    r3754588 r3761245  
    33Requires Plugins: woocommerce
    44Tags: invoicing, orders
    5 Stable tag: 4.0.13
     5Stable tag: 4.0.14
    66Tested up to: 7.0
    77WC tested up to: 10.7.0
    … …  
    5959
    6060== Changelog ==
     61= 4.0.14=
     62* Install a single Moloni ON Product webhook instead of one per operation, so the plugin uses fewer webhooks from the plan's quota. Existing shops switch to it the next time they save the automation settings or reinstall the webhooks.
     63
    6164= 4.0.13=
    6265* Create the shipping and fee products with a fixed name, so they no longer keep the first order's shipping method or fee name forever.
  • moloni-on/trunk/src/API/Queries/hooks.graphql

    r3675991 r3761245  
    1414            msg
    1515        }
     16        options
     17        {
     18            pagination
     19            {
     20                page
     21                qty
     22                count
     23            }
     24        }
    1625    }
    1726}
  • moloni-on/trunk/src/Helpers/WebHooks.php

    r3487173 r3761245  
    2323     * Create hook in moloni
    2424     *
     25     * Omit $operation (or pass null) to receive every operation of the model in one hook.
     26     *
    2527     * @param string $model
    26      * @param string $operation
     28     * @param string|null $operation
    2729     *
    2830     * @throws APIExeption
    2931     */
    30     public static function createHook(string $model, string $operation)
     32    public static function createHook(string $model, ?string $operation = null)
    3133    {
    3234        if (!isset(self::$routes[$model])) {
    … …  
    4345            'model' => $model,
    4446            'url' => $url,
    45             'operation' => $operation
    4647        ];
     48
     49        if ($operation !== null) {
     50            $variables['data']['operation'] = $operation;
     51        }
    4752
    4853        Hooks::mutationHookCreate($variables);
    … …  
    5863        $ids = [];
    5964
     65        /** Filter by this site's URL — without it the query returns (and we'd delete) every hook of the company */
    6066        $variables = [
    61             'data' => [
     67            'options' => [
    6268                'search' => [
    6369                    'field' => 'url',
  • moloni-on/trunk/src/Plugin.php

    r3569805 r3761245  
    293293            WebHooks::deleteHooks();
    294294
    295             if (Context::settings()->getInt('hook_stock_sync') === Boolean::YES) {
    296                 WebHooks::createHook('Product', 'stockChanged');
    297             }
    298 
    299             if (Context::settings()->getInt('hook_product_sync') === Boolean::YES) {
    300                 WebHooks::createHook('Product', 'create');
    301                 WebHooks::createHook('Product', 'update');
     295            if (
     296                Context::settings()->getInt('hook_stock_sync') === Boolean::YES ||
     297                Context::settings()->getInt('hook_product_sync') === Boolean::YES
     298            ) {
     299                WebHooks::createHook('Product');
    302300            }
    303301
    … …  
    354352            WebHooks::deleteHooks();
    355353
    356             if (isset($options['hook_stock_sync']) && (int)$options['hook_stock_sync'] === Boolean::YES) {
    357                 WebHooks::createHook('Product', 'stockChanged');
    358             }
    359 
    360             if (isset($options['hook_product_sync']) && (int)$options['hook_product_sync'] === Boolean::YES) {
    361                 WebHooks::createHook('Product', 'create');
    362                 WebHooks::createHook('Product', 'update');
     354            $hookStockSync = isset($options['hook_stock_sync']) && (int)$options['hook_stock_sync'] === Boolean::YES;
     355            $hookProductSync = isset($options['hook_product_sync']) && (int)$options['hook_product_sync'] === Boolean::YES;
     356
     357            if ($hookStockSync || $hookProductSync) {
     358                WebHooks::createHook('Product');
    363359            }
    364360        } catch (APIExeption $e) {
  • moloni-on/trunk/src/WebHooks/Products.php

    r3511501 r3761245  
    7373            $productId = (int)sanitize_text_field($parameters['productId']);
    7474
    75             $this->fetchMoloniProduct($productId);
    76 
    77             //switch between operations
    78             switch ($parameters['operation']) {
     75            /**
     76             * One hook receives every Product operation. Each handler checks its own setting
     77             * before fetching the Moloni product, so a disabled sync costs no API call.
     78             * Other operations (e.g. delete) are acknowledged and ignored.
     79             */
     80            switch ($parameters['operation'] ?? '') {
    7981                case 'create':
    80                     $this->onCreate();
     82                    $this->onCreate($productId);
    8183                    break;
    8284                case 'update':
    83                     $this->onUpdate();
     85                    $this->onUpdate($productId);
    8486                    break;
    8587                case 'stockChanged':
    86                     $this->onStockUpdate();
     88                    $this->onStockUpdate($productId);
    8789                    break;
    8890            }
    … …  
    127129     * Create action
    128130     *
     131     * @param int $productId Moloni product id
     132     *
    129133     * @throws WebhookException
    130134     */
    131     private function onCreate()
     135    private function onCreate(int $productId)
    132136    {
    133137        if (!$this->shouldSyncProduct()) {
    134138            return;
    135139        }
     140
     141        $this->fetchMoloniProduct($productId);
    136142
    137143        $this->validateMoloniProduct();
    … …  
    175181     * On Moloni product update action
    176182     *
     183     * @param int $productId Moloni product id
     184     *
    177185     * @throws HelperException|WebhookException
    178186     */
    179     private function onUpdate()
     187    private function onUpdate(int $productId)
    180188    {
    181189        if (!$this->shouldSyncProduct()) {
    182190            return;
    183191        }
     192
     193        $this->fetchMoloniProduct($productId);
    184194
    185195        $this->validateMoloniProduct();
    … …  
    237247     * On Moloni stock update
    238248     *
     249     * @param int $productId Moloni product id
     250     *
    239251     * @throws HelperException|WebhookException
    240252     */
    241     private function onStockUpdate()
     253    private function onStockUpdate(int $productId)
    242254    {
    243255        if (!$this->shouldSyncStock()) {
    244256            return;
    245257        }
     258
     259        $this->fetchMoloniProduct($productId);
    246260
    247261        $this->validateMoloniProduct();
  • moloni-on/trunk/vendor/composer/installed.php

    r3754588 r3761245  
    22    'root' => array(
    33        'name' => 'moloni/woocommerce-dev',
    4         'pretty_version' => 'v4.0.13',
    5         'version' => '4.0.13.0',
    6         'reference' => '18091161cfb0f7b4d3aca78ab0a4c56e4ea165c6',
     4        'pretty_version' => 'v4.0.14',
     5        'version' => '4.0.14.0',
     6        'reference' => '776d7f8f79f81afe54a9122788f74c3297243b69',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
    … …  
    1212    'versions' => array(
    1313        'moloni/woocommerce-dev' => array(
    14             'pretty_version' => 'v4.0.13',
    15             'version' => '4.0.13.0',
    16             'reference' => '18091161cfb0f7b4d3aca78ab0a4c56e4ea165c6',
     14            'pretty_version' => 'v4.0.14',
     15            'version' => '4.0.14.0',
     16            'reference' => '776d7f8f79f81afe54a9122788f74c3297243b69',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.