Plugin Directory

Changeset 3807287


Ignore:
Timestamp:
11/17/2026 11:50:07 AM (less than one hour ago)
Author:
symmetriahr
Message:

Update to version 2.2.19 from GitHub

Location:
kigocloud-for-woocommerce
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • kigocloud-for-woocommerce/tags/2.2.19/CHANGELOG.md

    r3807119 r3807287  
    44The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
    55and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
     6
     7## [2.2.19] - 2026-11-17
     8
     9### Fixed
     10- Bazna cijena on variable products. A variable product has no `_kigo_anchor_price` of its own and its SKU is usually not in the price list, and when all variations have the same price WooCommerce shows no variation price, so the base price appeared nowhere on the page. `anchor_price_html()` now reads the visible variations (`variations_anchor()`: meta, then the price list by the variation's SKU, the parent's SKU when the variation has none, or GTIN, one meta cache query) and prints one amount or lowest – highest, with the reference day when all variations share it; otherwise the product's own base price as before (`own_anchor()`). New `Woo_KigoCloud_Pricelist::anchor_for_codes($sku, $gtin)`, which `anchor_for()` uses.
    611
    712## [2.2.18] - 2026-11-17
  • kigocloud-for-woocommerce/tags/2.2.19/includes/class-woo-kigocloud-pricelist.php

    r3807119 r3807287  
    763763    public static function anchor_for($product)
    764764    {
     765        $gtin = is_callable(array($product, 'get_global_unique_id')) ? (string) $product->get_global_unique_id() : '';
     766
     767        return self::anchor_for_codes((string) $product->get_sku(), $gtin);
     768    }
     769
     770    /**
     771     * Base price from Kigo.Cloud for an SKU, then a GTIN/EAN.
     772     *
     773     * @param string $sku
     774     * @param string $gtin
     775     * @return array|null array(price, date) or null when there is none
     776     */
     777    public static function anchor_for_codes($sku, $gtin)
     778    {
    765779        if (self::$anchor_index === null) {
    766780            $index = get_option(self::OPTION_ANCHOR, null);
    … …  
    770784            return null;
    771785        }
    772         $sku = self::anchor_key($product->get_sku());
     786        $sku = self::anchor_key($sku);
    773787        if ($sku !== '' && isset(self::$anchor_index['ref'][$sku])) {
    774788            return self::$anchor_index['ref'][$sku];
    775789        }
    776         if (is_callable(array($product, 'get_global_unique_id'))) {
    777             $gtin = self::anchor_key($product->get_global_unique_id());
    778             if ($gtin !== '' && isset(self::$anchor_index['barcode'][$gtin])) {
    779                 return self::$anchor_index['barcode'][$gtin];
    780             }
     790        $gtin = self::anchor_key($gtin);
     791        if ($gtin !== '' && isset(self::$anchor_index['barcode'][$gtin])) {
     792            return self::$anchor_index['barcode'][$gtin];
    781793        }
    782794
  • kigocloud-for-woocommerce/tags/2.2.19/includes/class-woo-kigocloud.php

    r3807119 r3807287  
    4646     * @since 1.0.0
    4747     */
    48     const PLUGIN_VERSION = '2.2.18';
     48    const PLUGIN_VERSION = '2.2.19';
    4949
    5050    /**
  • kigocloud-for-woocommerce/tags/2.2.19/kigocloud-for-woocommerce.php

    r3807119 r3807287  
    1111 * Plugin URI:        https://www.kigocloud.com/fiskalizacija-web-trgovine/
    1212 * Description:       Croatian fiscalization for WooCommerce: every order becomes a fiscalized invoice in Kigo.Cloud, with R1 invoices, the invoice PDF for the customer and stock sync. Without WooCommerce it publishes the Kigo.Cloud price list (cjenik) on any WordPress site.
    13  * Version:           2.2.18
     13 * Version:           2.2.19
    1414 * Requires at least: 5.5
    1515 * Requires PHP:      7.2
    … …  
    2727}
    2828
    29 define( 'WOO_KIGOCLOUD_PLUGIN_NAME_VERSION', '2.2.18' );
     29define( 'WOO_KIGOCLOUD_PLUGIN_NAME_VERSION', '2.2.19' );
    3030define( 'WOO_KIGOCLOUD_PLUGIN_FILE', __FILE__ );
    3131define( 'WOO_KIGOCLOUD_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • kigocloud-for-woocommerce/tags/2.2.19/public/class-woo-kigocloud-public.php

    r3805644 r3807287  
    9696     * HTML is returned unchanged.
    9797     *
     98     * A variable product shows the base prices of its variations: one amount
     99     * when they are all the same (WooCommerce then shows no variation price
     100     * when one is selected, so this is the only line on the page), otherwise
     101     * the lowest and the highest, like the price range above it.
     102     *
    98103     * @param string     $price_html
    99104     * @param WC_Product $product
    … …  
    109114            return $price_html;
    110115        }
    111         $anchor = $product->get_meta('_kigo_anchor_price', true);
    112         $date   = $product->get_meta('_kigo_anchor_price_date', true);
    113         if ($anchor === '' || $anchor === null || !is_numeric($anchor)) {
    114             $listed = class_exists('Woo_KigoCloud_Pricelist') ? Woo_KigoCloud_Pricelist::anchor_for($product) : null;
    115             if ($listed === null) {
    116                 return $price_html;
    117             }
    118             $anchor = $listed[0];
    119             $date   = $listed[1];
    120         }
    121         if ((float) $anchor < 0) {
     116        $found = null;
     117        if ($product->is_type('variable')) {
     118            $found = $this->variations_anchor($product);
     119        }
     120        if ($found === null) {
     121            $found = $this->own_anchor($product);
     122        }
     123        if ($found === null) {
    122124            return $price_html;
    123125        }
     126        list($anchor, $date, $highest) = $found;
    124127        // "Bazna cijena (10. 9. 2026.): 12,00 €", the name the Pravilnik o
    125128        // isticanju bazne cijene proizvoda (NN 132/2026) gives it and Kigo.Cloud
    … …  
    136139        // must not reach the anchor price, only the line's own style does.
    137140        $amount = trim(wp_strip_all_tags(wc_price((float) $anchor)));
     141        if ($highest !== null && (float) $highest !== (float) $anchor) {
     142            $amount .= ' – ' . trim(wp_strip_all_tags(wc_price((float) $highest)));
     143        }
    138144
    139145        // Themes lay the price out as flex rows, absolutely positioned boxes of a
    … …  
    172178
    173179    /**
     180     * Base price of the product or variation itself: its meta from KigoCloud,
     181     * otherwise the price list by SKU or GTIN.
     182     *
     183     * @param WC_Product $product
     184     * @return array|null array(price, date, null)
     185     */
     186    private function own_anchor($product)
     187    {
     188        $anchor = $product->get_meta('_kigo_anchor_price', true);
     189        $date   = $product->get_meta('_kigo_anchor_price_date', true);
     190        if ($anchor === '' || $anchor === null || !is_numeric($anchor)) {
     191            $listed = class_exists('Woo_KigoCloud_Pricelist') ? Woo_KigoCloud_Pricelist::anchor_for($product) : null;
     192            if ($listed === null) {
     193                return null;
     194            }
     195            $anchor = $listed[0];
     196            $date   = $listed[1];
     197        }
     198        if ((float) $anchor < 0) {
     199            return null;
     200        }
     201
     202        return array($anchor, $date, null);
     203    }
     204
     205    /**
     206     * Base prices of the visible variations of a variable product, read the
     207     * same way as for a single variation (meta, then the price list by the
     208     * variation's SKU, which WooCommerce takes from the parent when the
     209     * variation has none, or GTIN). One meta query for all variations.
     210     *
     211     * @param WC_Product $product variable product
     212     * @return array|null array(lowest, date when all are of the same day, highest)
     213     */
     214    private function variations_anchor($product)
     215    {
     216        $ids = array_map('intval', (array) $product->get_visible_children());
     217        if (empty($ids)) {
     218            return null;
     219        }
     220        update_meta_cache('post', $ids);
     221        $prices = array();
     222        $dates  = array();
     223        foreach ($ids as $id) {
     224            $anchor = get_post_meta($id, '_kigo_anchor_price', true);
     225            $date   = get_post_meta($id, '_kigo_anchor_price_date', true);
     226            if ($anchor === '' || !is_numeric($anchor)) {
     227                $sku = (string) get_post_meta($id, '_sku', true);
     228                if ($sku === '') {
     229                    $sku = (string) $product->get_sku();
     230                }
     231                $listed = class_exists('Woo_KigoCloud_Pricelist')
     232                    ? Woo_KigoCloud_Pricelist::anchor_for_codes($sku, (string) get_post_meta($id, '_global_unique_id', true))
     233                    : null;
     234                if ($listed === null) {
     235                    continue;
     236                }
     237                $anchor = $listed[0];
     238                $date   = $listed[1];
     239            }
     240            if ((float) $anchor < 0) {
     241                continue;
     242            }
     243            $prices[] = (float) $anchor;
     244            $dates[(string) $date] = true;
     245        }
     246        if (empty($prices)) {
     247            return null;
     248        }
     249
     250        return array(min($prices), count($dates) === 1 ? (string) key($dates) : '', max($prices));
     251    }
     252
     253    /**
    174254     * Is this the price of the product the page is about (its summary or one of
    175255     * its variations), as opposed to a product card or widget on the page?
  • kigocloud-for-woocommerce/tags/2.2.19/readme.txt

    r3807119 r3807287  
    55Tested up to: 7.1
    66Requires PHP: 7.2
    7 Stable tag: 2.2.18
     7Stable tag: 2.2.19
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    133133== Changelog ==
    134134
     135= 2.2.19 =
     136* Bazna cijena on variable products. When all variations had the same price, WooCommerce showed no variation price, so the base price appeared nowhere on the product page. The price of a variable product now carries the base prices of its variations: one amount when they are the same, otherwise the lowest and the highest, with the reference day when all are of the same day.
     137
    135138= 2.2.18 =
    136139* The price list is published only under the file names the Pravilnik prescribes (OIB, sales point, ROBA or USLUGE, storage number and time). The extra copies cjenik-roba.csv, cjenik-roba.xml, cjenik-usluge.csv and cjenik-usluge.xml of 2.2.17 are removed. The page with [kigo_cjenik] is the place of the price list on your site: its buttons and the Price list tab link the current files under their prescribed names, and a changed price list always comes to that page.
    … …  
    283286== Upgrade Notice ==
    284287
     288= 2.2.19 =
     289Bazna cijena is also shown on variable products.
     290
    285291= 2.2.18 =
    286292The price list is published only under the prescribed file names.
  • kigocloud-for-woocommerce/trunk/CHANGELOG.md

    r3807119 r3807287  
    44The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
    55and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
     6
     7## [2.2.19] - 2026-11-17
     8
     9### Fixed
     10- Bazna cijena on variable products. A variable product has no `_kigo_anchor_price` of its own and its SKU is usually not in the price list, and when all variations have the same price WooCommerce shows no variation price, so the base price appeared nowhere on the page. `anchor_price_html()` now reads the visible variations (`variations_anchor()`: meta, then the price list by the variation's SKU, the parent's SKU when the variation has none, or GTIN, one meta cache query) and prints one amount or lowest – highest, with the reference day when all variations share it; otherwise the product's own base price as before (`own_anchor()`). New `Woo_KigoCloud_Pricelist::anchor_for_codes($sku, $gtin)`, which `anchor_for()` uses.
    611
    712## [2.2.18] - 2026-11-17
  • kigocloud-for-woocommerce/trunk/includes/class-woo-kigocloud-pricelist.php

    r3807119 r3807287  
    763763    public static function anchor_for($product)
    764764    {
     765        $gtin = is_callable(array($product, 'get_global_unique_id')) ? (string) $product->get_global_unique_id() : '';
     766
     767        return self::anchor_for_codes((string) $product->get_sku(), $gtin);
     768    }
     769
     770    /**
     771     * Base price from Kigo.Cloud for an SKU, then a GTIN/EAN.
     772     *
     773     * @param string $sku
     774     * @param string $gtin
     775     * @return array|null array(price, date) or null when there is none
     776     */
     777    public static function anchor_for_codes($sku, $gtin)
     778    {
    765779        if (self::$anchor_index === null) {
    766780            $index = get_option(self::OPTION_ANCHOR, null);
    … …  
    770784            return null;
    771785        }
    772         $sku = self::anchor_key($product->get_sku());
     786        $sku = self::anchor_key($sku);
    773787        if ($sku !== '' && isset(self::$anchor_index['ref'][$sku])) {
    774788            return self::$anchor_index['ref'][$sku];
    775789        }
    776         if (is_callable(array($product, 'get_global_unique_id'))) {
    777             $gtin = self::anchor_key($product->get_global_unique_id());
    778             if ($gtin !== '' && isset(self::$anchor_index['barcode'][$gtin])) {
    779                 return self::$anchor_index['barcode'][$gtin];
    780             }
     790        $gtin = self::anchor_key($gtin);
     791        if ($gtin !== '' && isset(self::$anchor_index['barcode'][$gtin])) {
     792            return self::$anchor_index['barcode'][$gtin];
    781793        }
    782794
  • kigocloud-for-woocommerce/trunk/includes/class-woo-kigocloud.php

    r3807119 r3807287  
    4646     * @since 1.0.0
    4747     */
    48     const PLUGIN_VERSION = '2.2.18';
     48    const PLUGIN_VERSION = '2.2.19';
    4949
    5050    /**
  • kigocloud-for-woocommerce/trunk/kigocloud-for-woocommerce.php

    r3807119 r3807287  
    1111 * Plugin URI:        https://www.kigocloud.com/fiskalizacija-web-trgovine/
    1212 * Description:       Croatian fiscalization for WooCommerce: every order becomes a fiscalized invoice in Kigo.Cloud, with R1 invoices, the invoice PDF for the customer and stock sync. Without WooCommerce it publishes the Kigo.Cloud price list (cjenik) on any WordPress site.
    13  * Version:           2.2.18
     13 * Version:           2.2.19
    1414 * Requires at least: 5.5
    1515 * Requires PHP:      7.2
    … …  
    2727}
    2828
    29 define( 'WOO_KIGOCLOUD_PLUGIN_NAME_VERSION', '2.2.18' );
     29define( 'WOO_KIGOCLOUD_PLUGIN_NAME_VERSION', '2.2.19' );
    3030define( 'WOO_KIGOCLOUD_PLUGIN_FILE', __FILE__ );
    3131define( 'WOO_KIGOCLOUD_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • kigocloud-for-woocommerce/trunk/public/class-woo-kigocloud-public.php

    r3805644 r3807287  
    9696     * HTML is returned unchanged.
    9797     *
     98     * A variable product shows the base prices of its variations: one amount
     99     * when they are all the same (WooCommerce then shows no variation price
     100     * when one is selected, so this is the only line on the page), otherwise
     101     * the lowest and the highest, like the price range above it.
     102     *
    98103     * @param string     $price_html
    99104     * @param WC_Product $product
    … …  
    109114            return $price_html;
    110115        }
    111         $anchor = $product->get_meta('_kigo_anchor_price', true);
    112         $date   = $product->get_meta('_kigo_anchor_price_date', true);
    113         if ($anchor === '' || $anchor === null || !is_numeric($anchor)) {
    114             $listed = class_exists('Woo_KigoCloud_Pricelist') ? Woo_KigoCloud_Pricelist::anchor_for($product) : null;
    115             if ($listed === null) {
    116                 return $price_html;
    117             }
    118             $anchor = $listed[0];
    119             $date   = $listed[1];
    120         }
    121         if ((float) $anchor < 0) {
     116        $found = null;
     117        if ($product->is_type('variable')) {
     118            $found = $this->variations_anchor($product);
     119        }
     120        if ($found === null) {
     121            $found = $this->own_anchor($product);
     122        }
     123        if ($found === null) {
    122124            return $price_html;
    123125        }
     126        list($anchor, $date, $highest) = $found;
    124127        // "Bazna cijena (10. 9. 2026.): 12,00 €", the name the Pravilnik o
    125128        // isticanju bazne cijene proizvoda (NN 132/2026) gives it and Kigo.Cloud
    … …  
    136139        // must not reach the anchor price, only the line's own style does.
    137140        $amount = trim(wp_strip_all_tags(wc_price((float) $anchor)));
     141        if ($highest !== null && (float) $highest !== (float) $anchor) {
     142            $amount .= ' – ' . trim(wp_strip_all_tags(wc_price((float) $highest)));
     143        }
    138144
    139145        // Themes lay the price out as flex rows, absolutely positioned boxes of a
    … …  
    172178
    173179    /**
     180     * Base price of the product or variation itself: its meta from KigoCloud,
     181     * otherwise the price list by SKU or GTIN.
     182     *
     183     * @param WC_Product $product
     184     * @return array|null array(price, date, null)
     185     */
     186    private function own_anchor($product)
     187    {
     188        $anchor = $product->get_meta('_kigo_anchor_price', true);
     189        $date   = $product->get_meta('_kigo_anchor_price_date', true);
     190        if ($anchor === '' || $anchor === null || !is_numeric($anchor)) {
     191            $listed = class_exists('Woo_KigoCloud_Pricelist') ? Woo_KigoCloud_Pricelist::anchor_for($product) : null;
     192            if ($listed === null) {
     193                return null;
     194            }
     195            $anchor = $listed[0];
     196            $date   = $listed[1];
     197        }
     198        if ((float) $anchor < 0) {
     199            return null;
     200        }
     201
     202        return array($anchor, $date, null);
     203    }
     204
     205    /**
     206     * Base prices of the visible variations of a variable product, read the
     207     * same way as for a single variation (meta, then the price list by the
     208     * variation's SKU, which WooCommerce takes from the parent when the
     209     * variation has none, or GTIN). One meta query for all variations.
     210     *
     211     * @param WC_Product $product variable product
     212     * @return array|null array(lowest, date when all are of the same day, highest)
     213     */
     214    private function variations_anchor($product)
     215    {
     216        $ids = array_map('intval', (array) $product->get_visible_children());
     217        if (empty($ids)) {
     218            return null;
     219        }
     220        update_meta_cache('post', $ids);
     221        $prices = array();
     222        $dates  = array();
     223        foreach ($ids as $id) {
     224            $anchor = get_post_meta($id, '_kigo_anchor_price', true);
     225            $date   = get_post_meta($id, '_kigo_anchor_price_date', true);
     226            if ($anchor === '' || !is_numeric($anchor)) {
     227                $sku = (string) get_post_meta($id, '_sku', true);
     228                if ($sku === '') {
     229                    $sku = (string) $product->get_sku();
     230                }
     231                $listed = class_exists('Woo_KigoCloud_Pricelist')
     232                    ? Woo_KigoCloud_Pricelist::anchor_for_codes($sku, (string) get_post_meta($id, '_global_unique_id', true))
     233                    : null;
     234                if ($listed === null) {
     235                    continue;
     236                }
     237                $anchor = $listed[0];
     238                $date   = $listed[1];
     239            }
     240            if ((float) $anchor < 0) {
     241                continue;
     242            }
     243            $prices[] = (float) $anchor;
     244            $dates[(string) $date] = true;
     245        }
     246        if (empty($prices)) {
     247            return null;
     248        }
     249
     250        return array(min($prices), count($dates) === 1 ? (string) key($dates) : '', max($prices));
     251    }
     252
     253    /**
    174254     * Is this the price of the product the page is about (its summary or one of
    175255     * its variations), as opposed to a product card or widget on the page?
  • kigocloud-for-woocommerce/trunk/readme.txt

    r3807119 r3807287  
    55Tested up to: 7.1
    66Requires PHP: 7.2
    7 Stable tag: 2.2.18
     7Stable tag: 2.2.19
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    133133== Changelog ==
    134134
     135= 2.2.19 =
     136* Bazna cijena on variable products. When all variations had the same price, WooCommerce showed no variation price, so the base price appeared nowhere on the product page. The price of a variable product now carries the base prices of its variations: one amount when they are the same, otherwise the lowest and the highest, with the reference day when all are of the same day.
     137
    135138= 2.2.18 =
    136139* The price list is published only under the file names the Pravilnik prescribes (OIB, sales point, ROBA or USLUGE, storage number and time). The extra copies cjenik-roba.csv, cjenik-roba.xml, cjenik-usluge.csv and cjenik-usluge.xml of 2.2.17 are removed. The page with [kigo_cjenik] is the place of the price list on your site: its buttons and the Price list tab link the current files under their prescribed names, and a changed price list always comes to that page.
    … …  
    283286== Upgrade Notice ==
    284287
     288= 2.2.19 =
     289Bazna cijena is also shown on variable products.
     290
    285291= 2.2.18 =
    286292The price list is published only under the prescribed file names.
Note: See TracChangeset for help on using the changeset viewer.