Plugin Directory

Changeset 3757554


Ignore:
Timestamp:
10/20/2026 11:21:09 PM (2 weeks ago)
Author:
skyservers
Message:

Release 1.2.0

Location:
skyservers-promo-campaigns/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • skyservers-promo-campaigns/trunk/includes/class-skypc-frontend.php

    r3755119 r3757554  
    3131
    3232                add_action( 'woocommerce_checkout_create_order_line_item', array( __CLASS__, 'order_line_item' ), 10, 4 );
     33                add_action( 'woocommerce_checkout_create_order', array( __CLASS__, 'order_created' ), 20, 2 );
    3334
    3435                add_action( 'wp_enqueue_scripts', array( __CLASS__, 'assets' ) );
    … …  
    450451                        return;
    451452                }
    452                 $s    = SkyPC_Settings::get();
    453                 $base = self::money_text( $values['data'], SkyPC_Campaign::base_price( $values['data'] ) );
     453                $s           = SkyPC_Settings::get();
     454                $base_amount = SkyPC_Campaign::base_price( $values['data'] );
     455                $base        = self::money_text( $values['data'], $base_amount );
     456                $qty         = isset( $values['quantity'] ) ? max( 1, (int) $values['quantity'] ) : 1;
    454457                $item->add_meta_data(
    455458                        __( 'Campaign', 'skyservers-promo-campaigns' ),
    … …  
    462465                        true
    463466                );
     467                // Hidden, structured values for the reports screen.
    464468                $item->add_meta_data( '_skypc_campaign', $s['name'], true );
     469                $item->add_meta_data( '_skypc_base_price', wc_format_decimal( $base_amount, 2 ), true );
     470                $item->add_meta_data( '_skypc_price', wc_format_decimal( $p, 2 ), true );
     471                $item->add_meta_data( '_skypc_discount', wc_format_decimal( max( 0, $base_amount - $p ) * $qty, 2 ), true );
     472        }
     473
     474        /**
     475         * Order-level totals for the reports screen, written once when the order is created.
     476         * Runs after the line items exist; reads the cart so it uses the same prices the customer paid.
     477         */
     478        public static function order_created( $order, $data ) {
     479                if ( ! $order instanceof WC_Order || ! function_exists( 'WC' ) || ! WC()->cart ) {
     480                        return;
     481                }
     482                $discount = 0.0;
     483                $items    = 0;
     484                foreach ( WC()->cart->get_cart() as $cart_item ) {
     485                        $p = self::cart_line_price( $cart_item );
     486                        if ( null === $p ) {
     487                                continue;
     488                        }
     489                        $qty       = isset( $cart_item['quantity'] ) ? max( 1, (int) $cart_item['quantity'] ) : 1;
     490                        $discount += max( 0, SkyPC_Campaign::base_price( $cart_item['data'] ) - $p ) * $qty;
     491                        $items    += $qty;
     492                }
     493                if ( $items <= 0 ) {
     494                        return;
     495                }
     496                $s = SkyPC_Settings::get();
     497                $order->update_meta_data( '_skypc_campaign', $s['name'] );
     498                $order->update_meta_data( '_skypc_discount', wc_format_decimal( $discount, 2 ) );
     499                $order->update_meta_data( '_skypc_items', $items );
     500                $order->update_meta_data( '_skypc_percent', wc_format_decimal( $s['percent'], 2 ) );
     501                SkyPC_Reports::remember_campaign( $s['name'], time() );
    465502        }
    466503
  • skyservers-promo-campaigns/trunk/languages/skyservers-promo-campaigns-ro_RO.po

    r3755119 r3757554  
    4343msgstr "Se aplică peste prețul curent al produsului (prețul redus, dacă există). Nu se afișează clienților decât dacă bifezi opțiunea de mai jos."
    4444
     45#: includes/class-skypc-reports.php
     46msgid "Average discount per order"
     47msgstr "Reducere medie pe comandă"
     48
     49#: includes/class-skypc-reports.php
     50msgid "Average order value"
     51msgstr "Valoare medie comandă"
     52
    4553#: includes/class-skypc-admin.php
    4654msgid "B · 2 rows, price with a marker"
    … …  
    6371msgstr "C · clasic, plus etichetă"
    6472
    65 #: includes/class-skypc-frontend.php
     73#: includes/class-skypc-frontend.php includes/class-skypc-reports.php
    6674msgid "Campaign"
    6775msgstr "Campanie"
    6876
     77#: includes/class-skypc-reports.php
     78msgid "Campaign items"
     79msgstr "Bucăți din campanie"
     80
     81#: includes/class-skypc-reports.php
     82msgid "Campaign items sold"
     83msgstr "Bucăți vândute din campanie"
     84
    6985#: includes/class-skypc-admin.php
    7086msgid "Campaign name"
    … …  
    99115msgstr "Ora curentă a site-ului: %s."
    100116
     117#: includes/class-skypc-reports.php
     118msgid "Date"
     119msgstr "Dată"
     120
     121#: includes/class-skypc-reports.php
     122msgid "Day"
     123msgstr "Ziua"
     124
    101125#: includes/class-skypc-admin.php
    102126msgid "Discount"
    103127msgstr "Reducere"
    104128
     129#: includes/class-skypc-reports.php
     130msgid "Discount given"
     131msgstr "Reducere oferită"
     132
     133#: includes/class-skypc-reports.php
     134msgid "Discount given = the extra campaign discount, measured against the price each product had just before the campaign. Figures are cached for 10 minutes."
     135msgstr "Reducere oferită = extra reducerea campaniei, calculată față de prețul pe care îl avea fiecare produs chiar înainte de campanie. Cifrele se păstrează în cache 10 minute."
     136
    105137#: includes/class-skypc-settings.php
    106138msgid "Down to the nearest 10 cents (107.548 → 107.50)"
    … …  
    123155msgstr "Excluderi"
    124156
     157#: includes/class-skypc-reports.php
     158msgid "Export orders (CSV)"
     159msgstr "Exportă comenzile (CSV)"
     160
    125161#: includes/class-skypc-admin.php
    126162msgid "Extra discount"
    … …  
    135171msgstr "De exemplu produse-taxă adăugate automat lângă alte produse, care nu trebuie reduse."
    136172
     173#: includes/class-skypc-reports.php
     174msgid "From"
     175msgstr "De la"
     176
    137177#: includes/class-skypc-admin.php
    138178msgid "Hides the coupon field and removes coupons already applied."
    … …  
    195235msgstr "Fără bulină"
    196236
     237#: includes/class-skypc-reports.php
     238msgid "No campaign orders yet. Orders placed while a campaign is live appear here automatically."
     239msgstr "Încă nu există comenzi din campanii. Comenzile plasate cât timp o campanie e pornită apar aici automat."
     240
     241#: includes/class-skypc-reports.php
     242msgid "No orders match these filters."
     243msgstr "Nicio comandă nu se potrivește cu aceste filtre."
     244
    197245#: includes/class-skypc-admin.php
    198246msgid "ONLY for administrators and shop managers (preview mode)"
    … …  
    202250msgid "Off"
    203251msgstr "Oprită"
     252
     253#: includes/class-skypc-reports.php
     254msgid "Older orders added to the statistics: %s."
     255msgstr "Comenzi vechi adăugate la statistici: %s."
     256
     257#: includes/class-skypc-reports.php
     258msgid "Only needed once, for orders placed with plugin versions before 1.2. Reads the price note on each order line."
     259msgstr "E nevoie o singură dată, pentru comenzile plasate cu versiuni mai vechi de 1.2. Citește nota cu prețul de pe fiecare linie a comenzii."
     260
     261#: includes/class-skypc-reports.php
     262msgid "Order"
     263msgstr "Comandă"
     264
     265#: includes/class-skypc-reports.php
     266msgid "Order statuses"
     267msgstr "Statusuri comenzi"
     268
     269#: includes/class-skypc-reports.php
     270msgid "Order total"
     271msgstr "Total comandă"
     272
     273#: includes/class-skypc-reports.php
     274msgid "Orders"
     275msgstr "Comenzi"
    204276
    205277#: includes/class-skypc-frontend.php
    … …  
    215287msgstr "Suspendă cupoanele în campanie"
    216288
     289#: includes/class-skypc-reports.php
     290msgid "Per day"
     291msgstr "Pe zile"
     292
    217293#: includes/class-skypc-admin.php
    218294msgid "Period"
    … …  
    227303msgstr "Previzualizare"
    228304
     305#: includes/class-skypc-reports.php
     306msgid "Product"
     307msgstr "Produs"
     308
    229309#: includes/class-skypc-admin.php
    230310msgid "Products in these categories (and their subcategories) get no discount and no label."
    … …  
    235315msgstr "Campanii promo"
    236316
     317#: includes/class-skypc-reports.php
     318msgid "Promo reports"
     319msgstr "Rapoarte promo"
     320
     321#: includes/class-skypc-reports.php
     322msgid "Quantity"
     323msgstr "Cantitate"
     324
     325#: includes/class-skypc-reports.php
     326msgid "Rebuild statistics for older orders"
     327msgstr "Reconstruiește statisticile pentru comenzile vechi"
     328
     329#: includes/class-skypc-reports.php
     330msgid "Revenue"
     331msgstr "Încasări"
     332
     333#: includes/class-skypc-reports.php
     334msgid "Revenue (order totals)"
     335msgstr "Încasări (totalurile comenzilor)"
     336
    237337#: includes/class-skypc-admin.php
    238338msgid "Rounding"
    … …  
    254354msgid "Settings"
    255355msgstr "Setări"
     356
     357#: includes/class-skypc-reports.php
     358msgid "Show"
     359msgstr "Arată"
    256360
    257361#: includes/class-skypc-admin.php
    … …  
    303407msgstr "Început"
    304408
    305 #: includes/class-skypc-admin.php
     409#: includes/class-skypc-admin.php includes/class-skypc-reports.php
    306410msgid "Status"
    307411msgstr "Stare"
    … …  
    367471msgstr "Nu există încă nicio categorie de produse."
    368472
     473#: includes/class-skypc-reports.php
     474msgid "To"
     475msgstr "Până la"
     476
    369477#: includes/class-skypc-settings.php
    370478msgid "To 2 decimals (107.548 → 107.55)"
    371479msgstr "La 2 zecimale (107,548 → 107,55)"
    372480
     481#: includes/class-skypc-reports.php
     482msgid "Top products"
     483msgstr "Top produse"
     484
    373485#: includes/class-skypc-admin.php
    374486msgid "What the sale bubble shows on product cards (home page, categories, carousels, related products). The campaign price stays visible; only the bubble changes."
    … …  
    382494msgid "Yes"
    383495msgstr "Da"
     496
     497#: includes/class-skypc-reports.php
     498msgid "You are not allowed to do this."
     499msgstr "Nu ai voie să faci asta."
    384500
    385501#: includes/class-skypc-settings.php
  • skyservers-promo-campaigns/trunk/readme.txt

    r3755119 r3757554  
    66Requires PHP: 7.4
    77Requires Plugins: woocommerce
    8 Stable tag: 1.1.1
     8Stable tag: 1.2.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    3131* Three price layouts, three sizes and your own colours, all from the settings screen.
    3232* Product schema (structured data) carries the campaign price, so search engines see what shoppers see.
     33* Reports: orders, revenue, discount given, average order value, per-day breakdown and top products for each campaign, with CSV export.
    3334
    3435**Prices that always add up**
    … …  
    7778== Changelog ==
    7879
     80= 1.2.0 =
     81* New: WooCommerce → Promo reports. For each campaign: number of orders, revenue, discount given, average order value, average discount per order, items sold, a per-day table and the top products, filtered by period and order status, with CSV export.
     82* Orders now store the campaign discount per line and per order (hidden meta), so reports are exact.
     83* One-off tool to rebuild statistics for orders placed with earlier versions.
     84
    7985= 1.1.1 =
    8086* New: choose what the sale bubble shows on the product page and, separately, on product cards (home page, categories, carousels): the campaign label, the theme's usual bubble, or no bubble. The campaign price is always shown.
    … …  
    9096== Upgrade Notice ==
    9197
     98= 1.2.0 =
     99Adds the Promo reports screen. Orders placed with earlier versions appear there after you click “Rebuild statistics for older orders” once.
     100
    92101= 1.1.1 =
    93102Adds a choice of what the sale bubble shows on product cards and on the product page. Nothing changes until you pick a different option.
  • skyservers-promo-campaigns/trunk/skyservers-promo-campaigns.php

    r3755119 r3757554  
    44 * Plugin URI: https://www.sky-servers.com/skyservers-promo-campaigns/
    55 * Description: Scheduled promo campaigns for WooCommerce: extra discount in the cart, three prices shown, campaign label and strip, coupons paused.
    6  * Version: 1.1.1
     6 * Version: 1.2.0
    77 * Author: Sky Servers SRL
    88 * Author URI: https://www.sky-servers.com/
    … …  
    2222}
    2323
    24 define( 'SKYPC_VERSION', '1.1.1' );
     24define( 'SKYPC_VERSION', '1.2.0' );
    2525define( 'SKYPC_PATH', plugin_dir_path( __FILE__ ) );
    2626define( 'SKYPC_URL', plugin_dir_url( __FILE__ ) );
    … …  
    3030require_once SKYPC_PATH . 'includes/class-skypc-rules.php';
    3131require_once SKYPC_PATH . 'includes/class-skypc-format.php';
     32require_once SKYPC_PATH . 'includes/class-skypc-stats.php';
    3233require_once SKYPC_PATH . 'includes/class-skypc-settings.php';
    3334require_once SKYPC_PATH . 'includes/class-skypc-campaign.php';
    … …  
    3536require_once SKYPC_PATH . 'includes/class-skypc-frontend.php';
    3637require_once SKYPC_PATH . 'includes/class-skypc-admin.php';
     38require_once SKYPC_PATH . 'includes/class-skypc-reports.php';
    3739
    3840register_activation_hook( __FILE__, array( 'SkyPC_Settings', 'activate' ) );
    … …  
    5557                if ( is_admin() ) {
    5658                        SkyPC_Admin::init();
     59                        SkyPC_Reports::init();
    5760                }
    5861        }
Note: See TracChangeset for help on using the changeset viewer.