Plugin Directory

Changeset 3840331


Ignore:
Timestamp:
12/02/2026 02:55:40 PM (13 hours ago)
Author:
dominikshaim
Message:

Release 1.1.34: orders whose product or variation has been deleted send the purchase price their order line kept, so their margin and profit are no longer missing

Location:
trackless
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trackless/tags/1.1.34/includes/class-trackless-batch.php

    r3839077 r3840331  
    631631                $catId = 0;
    632632                $sku = '';
    633                 $cost = '';
    634633                if ($product) {
    635634                    $sku = $product->get_sku();
    … …  
    648647                        }
    649648                    }
    650                     $cost = self::wholesale_price($product, $item);
    651649                }
     650                // Also without the product: a line of an older order whose product or variation was deleted since
     651                // still carries the cost it kept when the order was placed (#272).
     652                $cost = self::wholesale_price($product, $item);
    652653
    653654                $outItems[] = array(
    … …  
    726727     * The `trackless_wholesale_price` filter gets the result and the product last, for a shop that stores cost
    727728     * elsewhere. Without a cost the price stays '' (never 0): the margin of the line is then unknown.
     729     * A line whose product or variation was deleted since ($product false, #272) has only what the line itself kept
     730     * when the order was placed, from the same two sources in the same order. The filter is not called for it: its
     731     * second argument has always been a product and a callback reads it.
    728732     */
    729733    protected static function wholesale_price($product, $item = null)
    … …  
    732736        if ($cost === '') {
    733737            $cost = self::native_cogs($product, $item);
     738        }
     739        if (!$product) {
     740            return $cost;
    734741        }
    735742
    … …  
    745752     * without its own takes its parent's the way each plugin does: SkyVerge the default cost of the variable product
    746753     * (`_wc_cog_cost_variable`; the parent's `_wc_cog_cost` is the lowest cost of its variations), WPFactory the parent's
    747      * `_alg_wc_cog_cost`.
     754     * `_alg_wc_cog_cost`. A deleted product ($product false, #272) has no meta: only the cost kept on the line.
    748755     */
    749756    protected static function addon_cost($product, $item)
    … …  
    756763                }
    757764            }
     765        }
     766        if (!$product) {
     767            return '';
    758768        }
    759769        $parentId = (int) $product->get_parent_id();
    … …  
    782792     * Only with the feature turned on: off, the methods return dummy zeros and log "doing it wrong" on every call.
    783793     * Below WooCommerce 9.5 the feature does not exist and the methods are missing.
     794     * A deleted product ($product false, #272) has no current value: only the value the line kept, and a line of
     795     * quantity 0 then stays without a price.
    784796     */
    785797    protected static function native_cogs($product, $item)
    … …  
    795807            }
    796808        }
    797         if (method_exists($product, 'get_cogs_total_value')) {
     809        if ($product && method_exists($product, 'get_cogs_total_value')) {
    798810            $unit = round((float) $product->get_cogs_total_value(), 6);
    799811            if ($unit > 0) {
  • trackless/tags/1.1.34/readme.txt

    r3839696 r3840331  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.1.33
     7Stable tag: 1.1.34
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    113113
    114114== Changelog ==
     115
     116= 1.1.34 =
     117* Orders whose product or variation has been deleted since now send the purchase price the order line kept when the order was placed (Cost of Goods Sold in WooCommerce, or the SkyVerge or WPFactory Cost of Goods plugin), so their margin and profit are no longer missing. A line that never kept a cost still has no margin.
    115118
    116119= 1.1.33 =
    … …  
    264267== Upgrade Notice ==
    265268
     269= 1.1.34 =
     270Orders whose product or variation has since been deleted keep the purchase price their order line stored, so their margin and profit are no longer missing.
     271
    266272= 1.1.33 =
    267273Margin also uses the purchase price from Cost of Goods Sold in WooCommerce 9.5 or newer. With a multi-currency plugin the reports stay in the shop's base currency. A cancelled, failed or refunded order no longer counts as a first purchase.
  • trackless/tags/1.1.34/trackless.php

    r3839077 r3840331  
    44 * Plugin URI: https://woomoduly.cz/produkt/trackless/
    55 * Description: Cookieless server-side analytics for WordPress. Traffic analytics on any site; with WooCommerce it also sends orders, revenue and margin to Trackless.
    6  * Version: 1.1.33
     6 * Version: 1.1.34
    77 * Requires PHP: 7.4
    88 * Requires at least: 6.2
    … …  
    2525}
    2626
    27 define('TRACKLESS_VERSION', '1.1.33');
     27define('TRACKLESS_VERSION', '1.1.34');
    2828define('TRACKLESS_FILE', __FILE__);
    2929define('TRACKLESS_DIR', plugin_dir_path(__FILE__));
  • trackless/trunk/includes/class-trackless-batch.php

    r3839077 r3840331  
    631631                $catId = 0;
    632632                $sku = '';
    633                 $cost = '';
    634633                if ($product) {
    635634                    $sku = $product->get_sku();
    … …  
    648647                        }
    649648                    }
    650                     $cost = self::wholesale_price($product, $item);
    651649                }
     650                // Also without the product: a line of an older order whose product or variation was deleted since
     651                // still carries the cost it kept when the order was placed (#272).
     652                $cost = self::wholesale_price($product, $item);
    652653
    653654                $outItems[] = array(
    … …  
    726727     * The `trackless_wholesale_price` filter gets the result and the product last, for a shop that stores cost
    727728     * elsewhere. Without a cost the price stays '' (never 0): the margin of the line is then unknown.
     729     * A line whose product or variation was deleted since ($product false, #272) has only what the line itself kept
     730     * when the order was placed, from the same two sources in the same order. The filter is not called for it: its
     731     * second argument has always been a product and a callback reads it.
    728732     */
    729733    protected static function wholesale_price($product, $item = null)
    … …  
    732736        if ($cost === '') {
    733737            $cost = self::native_cogs($product, $item);
     738        }
     739        if (!$product) {
     740            return $cost;
    734741        }
    735742
    … …  
    745752     * without its own takes its parent's the way each plugin does: SkyVerge the default cost of the variable product
    746753     * (`_wc_cog_cost_variable`; the parent's `_wc_cog_cost` is the lowest cost of its variations), WPFactory the parent's
    747      * `_alg_wc_cog_cost`.
     754     * `_alg_wc_cog_cost`. A deleted product ($product false, #272) has no meta: only the cost kept on the line.
    748755     */
    749756    protected static function addon_cost($product, $item)
    … …  
    756763                }
    757764            }
     765        }
     766        if (!$product) {
     767            return '';
    758768        }
    759769        $parentId = (int) $product->get_parent_id();
    … …  
    782792     * Only with the feature turned on: off, the methods return dummy zeros and log "doing it wrong" on every call.
    783793     * Below WooCommerce 9.5 the feature does not exist and the methods are missing.
     794     * A deleted product ($product false, #272) has no current value: only the value the line kept, and a line of
     795     * quantity 0 then stays without a price.
    784796     */
    785797    protected static function native_cogs($product, $item)
    … …  
    795807            }
    796808        }
    797         if (method_exists($product, 'get_cogs_total_value')) {
     809        if ($product && method_exists($product, 'get_cogs_total_value')) {
    798810            $unit = round((float) $product->get_cogs_total_value(), 6);
    799811            if ($unit > 0) {
  • trackless/trunk/readme.txt

    r3839696 r3840331  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.1.33
     7Stable tag: 1.1.34
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    113113
    114114== Changelog ==
     115
     116= 1.1.34 =
     117* Orders whose product or variation has been deleted since now send the purchase price the order line kept when the order was placed (Cost of Goods Sold in WooCommerce, or the SkyVerge or WPFactory Cost of Goods plugin), so their margin and profit are no longer missing. A line that never kept a cost still has no margin.
    115118
    116119= 1.1.33 =
    … …  
    264267== Upgrade Notice ==
    265268
     269= 1.1.34 =
     270Orders whose product or variation has since been deleted keep the purchase price their order line stored, so their margin and profit are no longer missing.
     271
    266272= 1.1.33 =
    267273Margin also uses the purchase price from Cost of Goods Sold in WooCommerce 9.5 or newer. With a multi-currency plugin the reports stay in the shop's base currency. A cancelled, failed or refunded order no longer counts as a first purchase.
  • trackless/trunk/trackless.php

    r3839077 r3840331  
    44 * Plugin URI: https://woomoduly.cz/produkt/trackless/
    55 * Description: Cookieless server-side analytics for WordPress. Traffic analytics on any site; with WooCommerce it also sends orders, revenue and margin to Trackless.
    6  * Version: 1.1.33
     6 * Version: 1.1.34
    77 * Requires PHP: 7.4
    88 * Requires at least: 6.2
    … …  
    2525}
    2626
    27 define('TRACKLESS_VERSION', '1.1.33');
     27define('TRACKLESS_VERSION', '1.1.34');
    2828define('TRACKLESS_FILE', __FILE__);
    2929define('TRACKLESS_DIR', plugin_dir_path(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.