Plugin Directory

Changeset 3841635


Ignore:
Timestamp:
12/03/2026 06:06:37 AM (less than one hour ago)
Author:
mercuriocreations
Message:

Release 0.2.0: update trunk and tags/0.2.0

Location:
copperquill-card-price-sync
Files:
17 added
10 edited

Legend:

Unmodified
Added
Removed
  • copperquill-card-price-sync/trunk/copperquill-card-price-sync.php

    r3839103 r3841635  
    22/**
    33 * Plugin Name:          Copperquill Card Price Sync for WooCommerce
    4  * Description:          Prices Magic: The Gathering singles from Cardmarket's public price guide files, with a card-name guard, with margin, floor/ceiling, rounding, dry-run preview, approval holds and an audit log.
    5  * Version:              0.1.2
     4 * Description:          Prices Magic: The Gathering, Pokémon and Yu-Gi-Oh! singles from Cardmarket's public price guide files, with a card-name guard, with margin, floor/ceiling, rounding, dry-run preview, approval holds and an audit log.
     5 * Version:              0.2.0
    66 * Requires at least:    6.4
    77 * Requires PHP:         8.0
    … …  
    1919defined( 'ABSPATH' ) || exit;
    2020
    21 define( 'CQPS_VERSION', '0.1.2' );
     21define( 'CQPS_VERSION', '0.2.0' );
    2222define( 'CQPS_FILE', __FILE__ );
    2323define( 'CQPS_DIR', plugin_dir_path( __FILE__ ) );
  • copperquill-card-price-sync/trunk/includes/class-cqps-admin.php

    r3839103 r3841635  
    196196                echo '<table class="form-table">';
    197197                $g = '';
    198                 foreach ( array( 'mtg' => 'Magic: The Gathering' ) as $k => $label ) {
     198                foreach ( array( 'mtg' => 'Magic: The Gathering', 'pokemon' => 'Pokémon', 'yugioh' => 'Yu-Gi-Oh!' ) as $k => $label ) {
    199199                        $g .= '<label><input type="checkbox" name="games[]" value="' . esc_attr( $k ) . '"' . checked( in_array( $k, $s['games'], true ), true, false ) . '> ' . esc_html( $label ) . '</label><br>';
    200200                }
  • copperquill-card-price-sync/trunk/includes/class-cqps-fetcher.php

    r3839103 r3841635  
    114114                        return array( 'ok' => false, 'msg' => 'catalog: HTTP ' . $code . ' or file too small' );
    115115                }
    116                 $scan = CQPS_Guide_Stream::scan_names( $tmp, null );
     116                $scan = CQPS_Guide_Stream::scan_names( $tmp, null, CQPS_Guide_Stream::catalog_min_rows( $game ) );
    117117                if ( ! $scan['ok'] ) {
    118118                        self::drop( $tmp );
  • copperquill-card-price-sync/trunk/includes/class-cqps-guide-stream.php

    r3839103 r3841635  
    1313final class CQPS_Guide_Stream {
    1414
    15         /** Cardmarket game id => [guide file number, foil column suffix, minimum plausible row count]. */
     15        /**
     16         * Game key => [file number (price_guide_N and products_singles_N), foil column suffix,
     17         * minimum plausible guide rows, minimum plausible catalog rows]. Measured 2026-12-02:
     18         * 1 = Magic (125,554 singles), 3 = Yu-Gi-Oh! ("Yugioh Single", 88,399 singles; low-foil and
     19         * avg-foil are always null), 6 = Pokemon ("Pokémon Single", 75,994 singles; -holo = reverse holo).
     20         * Guide id spaces are disjoint (0 overlap measured between all three guides).
     21         */
    1622        const GAMES = array(
    17                 'mtg' => array( 1, '-foil', 50000 ),
     23                'mtg'     => array( 1, '-foil', 50000, 80000 ),
     24                'pokemon' => array( 6, '-holo', 60000, 60000 ),
     25                'yugioh'  => array( 3, '-foil', 70000, 70000 ),
    1826        );
    1927
    20         /** Catalog (product list) sanity floor: MTG had 125,554 singles on 2026-11-29. */
     28        /** Catalog sanity floor used when a caller passes none (MTG). */
    2129        const CATALOG_MIN_ROWS = 80000;
    2230
    … …  
    4957        public static function scan_names( $path, $wanted = null, $min_rows = null, $chunk = self::CHUNK ) {
    5058                return self::stream( $path, '"products"', $wanted, null === $min_rows ? self::CATALOG_MIN_ROWS : (int) $min_rows, $chunk, null );
     59        }
     60
     61        /** Catalog plausibility floor (rows) for a game. */
     62        public static function catalog_min_rows( $game ) {
     63                return self::GAMES[ $game ][3];
    5164        }
    5265
  • copperquill-card-price-sync/trunk/includes/class-cqps-mapping.php

    r3839103 r3841635  
    77 *
    88 * SKU grammar (case-insensitive, separators - _ : or none before the id):
    9  *   [MTG|PKM|POKEMON <sep>] CM <sep>? <idProduct 1-9 digits> [<sep> FOIL|F|HOLO|RH|REVERSE|NF|NONFOIL] [<sep> anything-else]
     9 *   [MTG|PKM|POKEMON|YGO <sep>] CM <sep>? <idProduct 1-9 digits> [<sep> FOIL|F|HOLO|RH|REVERSE|NF|NONFOIL] [<sep> anything-else]
    1010 *   e.g. CM-372373, mtg-cm-12345-foil, PKM:CM:550123:RH, CM12345-NM-DE
    1111 * The trailing free part lets merchants keep condition/language suffixes; it is ignored here.
    … …  
    6666        }
    6767
    68         const SKU_RE = '/^(?:(MTG|PKM|POKEMON)[-_:])?CM[-_:]?(\d{1,9})(?:[-_:](FOIL|F|HOLO|RH|REVERSE|NF|NONFOIL))?(?:[-_:][A-Z0-9][A-Z0-9_:-]*)?$/i';
     68        const SKU_RE = '/^(?:(MTG|PKM|POKEMON|YGO)[-_:])?CM[-_:]?(\d{1,9})(?:[-_:](FOIL|F|HOLO|RH|REVERSE|NF|NONFOIL))?(?:[-_:][A-Z0-9][A-Z0-9_:-]*)?$/i';
    6969
    7070        /**
    … …  
    8383                $game = null;
    8484                if ( ! empty( $m[1] ) ) {
    85                         $game = 'MTG' === strtoupper( $m[1] ) ? 'mtg' : 'pokemon';
     85                        $game = self::sku_game( $m[1] );
    8686                }
    8787                $foil   = null;
    … …  
    102102         * Is a SKU foil suffix valid for the game? Cardmarket's Pokemon guide "-holo" columns are the
    103103         * REVERSE-holo price (holo rares are separate products), so Pokemon accepts only RH/REVERSE and
    104          * MTG only FOIL/F. HOLO is ambiguous for both -> invalid. NF/NONFOIL is valid everywhere.
     104         * MTG and Yu-Gi-Oh! only FOIL/F. HOLO is ambiguous for both -> invalid. NF/NONFOIL is valid everywhere.
    105105         *
    106106         * @param string|null $suffix Suffix from parse_sku.
    … …  
    138138        }
    139139
     140        /** SKU prefix -> game key. */
     141        private static function sku_game( $prefix ) {
     142                $p = strtoupper( $prefix );
     143                if ( 'MTG' === $p ) {
     144                        return 'mtg';
     145                }
     146                return 'YGO' === $p ? 'yugioh' : 'pokemon';
     147        }
     148
    140149        private static function meta_game( $v ) {
    141150                $v = strtolower( trim( (string) $v ) );
    142                 return in_array( $v, array( 'mtg', 'pokemon' ), true ) ? $v : null;
     151                return in_array( $v, array( 'mtg', 'pokemon', 'yugioh' ), true ) ? $v : null;
    143152        }
    144153
  • copperquill-card-price-sync/trunk/includes/class-cqps-planner.php

    r3839103 r3841635  
    4343        }
    4444
     45        /**
     46         * Merge per-game catalog names (game => idProduct => name) into the one map the name guard reads.
     47         * An id listed in two games' catalogs is dropped, so the guard holds it as name_unknown.
     48         */
     49        public static function merge_names( array $per_game ) {
     50                $out = array();
     51                $dup = array();
     52                foreach ( $per_game as $rows ) {
     53                        foreach ( $rows as $id => $name ) {
     54                                if ( array_key_exists( $id, $out ) ) {
     55                                        $dup[ $id ] = true;
     56                                }
     57                                $out[ $id ] = $name;
     58                        }
     59                }
     60                return array_diff_key( $out, $dup );
     61        }
     62
    4563        private static function one( array $it, array $prices, array $s, $cap, &$mapped, array $names ) {
    4664                $meta = isset( $it['meta'] ) ? (array) $it['meta'] : array();
  • copperquill-card-price-sync/trunk/includes/class-cqps-product-fields.php

    r3839103 r3841635  
    6161                                'options' => array(
    6262                                        ''    => __( '(detect from id)', 'copperquill-card-price-sync' ),
    63                                         'mtg' => 'Magic: The Gathering',
     63                                        'mtg'     => 'Magic: The Gathering',
     64                                        'pokemon' => 'Pokémon',
     65                                        'yugioh'  => 'Yu-Gi-Oh!',
    6466                                ),
    6567                        )
  • copperquill-card-price-sync/trunk/includes/class-cqps-settings-schema.php

    r3839103 r3841635  
    1111final class CQPS_Settings_Schema {
    1212
    13         const GAMES      = array( 'mtg' ); // MVP is MTG-only (scope of case 317, 2026-11-30).
     13        const GAMES      = array( 'mtg', 'pokemon', 'yugioh' ); // Games with a guide and catalog (case 357, 0.2.0).
    1414        const REFERENCES = array( 'trend', 'avg30', 'low' );
    1515        const ROUNDINGS  = array( 'none', 'step', 'charm' );
  • copperquill-card-price-sync/trunk/includes/class-cqps-sync.php

    r3839103 r3841635  
    147147                        $prices[ $g ] = $scan['rows'];
    148148                }
    149                 $cat = CQPS_Guide_Stream::scan_names( CQPS_Store::catalog_path( 'mtg' ), $wanted );
    150                 if ( ! $cat['ok'] ) {
    151                         return self::err( 'Cached Cardmarket product catalog is missing or invalid (' . $cat['error'] . '): fetch guides again.' );
    152                 }
    153                 $plan   = CQPS_Planner::plan( $items, $prices, $s, cqps_tier(), $cat['rows'] );
     149                $names_by_game = array();
     150                foreach ( $s['games'] as $g ) {
     151                        $cat = CQPS_Guide_Stream::scan_names( CQPS_Store::catalog_path( $g ), $wanted, CQPS_Guide_Stream::catalog_min_rows( $g ) );
     152                        if ( ! $cat['ok'] ) {
     153                                return self::err( 'Cached ' . $g . ' product catalog is missing or invalid (' . $cat['error'] . '): fetch guides again.' );
     154                        }
     155                        $names_by_game[ $g ] = $cat['rows'];
     156                }
     157                $plan   = CQPS_Planner::plan( $items, $prices, $s, cqps_tier(), CQPS_Planner::merge_names( $names_by_game ) );
    154158                $run_id = gmdate( 'YmdHis' ) . '-' . wp_generate_password( 6, false, false );
    155159
  • copperquill-card-price-sync/trunk/readme.txt

    r3839697 r3841635  
    11=== Copperquill Card Price Sync for WooCommerce ===
    22Contributors: mercuriocreations
    3 Tags: woocommerce, cardmarket, magic the gathering, mtg, tcg
     3Tags: woocommerce, cardmarket, pokemon, yugioh, mtg
    44Requires at least: 6.4
    55Tested up to: 7.1
    66Requires PHP: 8.0
    7 Stable tag: 0.1.2
     7Stable tag: 0.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Sync WooCommerce prices for Magic: The Gathering singles from Cardmarket's public price guide. Free, no API key, unlimited products.
     11Sync WooCommerce prices for Magic, Pokémon and Yu-Gi-Oh! singles from Cardmarket's public price guide. Free, no API key.
    1212
    1313== Description ==
    1414
    1515For trading-card shops running WooCommerce. Map each product (or variation) to its Cardmarket product id, choose a reference price (trend, 30-day average or lowest), add your margin, and the plugin computes new prices with your floor, ceiling and rounding rules.
     16
     17Games: Magic: The Gathering, Pokémon and Yu-Gi-Oh!. Each game is switched on separately under Games in the settings. Magic is on by default; tick Pokémon or Yu-Gi-Oh! to price those too.
    1618
    1719Safety first, because a wrong price is a real loss:
    … …  
    2022* Changes larger than your threshold (default 30%) are held for one-click approval.
    2123* Unmapped or ambiguous products are never touched (id conflicts between SKU and meta are held).
     24* A card-name check against Cardmarket's product list: a product whose title does not match its Cardmarket id is held.
    2225* Per-product lock, floor and ceiling. Products on sale are skipped.
    2326* Foil prices never fall back to non-foil prices.
    2427* Every applied, held, approved and rejected change is in the change log.
    2528
    26 Mapping: set "Cardmarket product id" on the product, or use SKUs such as `CM-372373` or `CM-372373-FOIL`. This release prices Magic: The Gathering only; SKUs for other games are skipped.
     29Mapping: set "Cardmarket product id" on the product, or use SKUs such as `CM-372373`, `CM-372373-FOIL` (Magic), `YGO-CM-101788-FOIL` (Yu-Gi-Oh!) or `PKM-CM-550123-RH` (Pokémon). Products for games that are not switched on are skipped.
    2730
    2831Free and unlimited: every feature above, for any number of products, run on demand from the admin screen.
    2932
    30 Pro (optional add-on, EUR 9 per month, https://mercuriocreations.com/woo-cm-repricer): runs the same sync automatically once or twice a day, with the same preview gate and approval holds as manual runs, so your MTG prices follow Cardmarket's guide without a click. Pro is sold separately and is not on WordPress.org. The free plugin is fully functional without it.
     33Pro (optional add-on, EUR 9 per month, https://mercuriocreations.com/woo-cm-repricer): runs the same sync automatically once or twice a day, with the same preview gate and approval holds as manual runs, so your prices follow Cardmarket's guide without a click. Pro is sold separately and is not on WordPress.org. The free plugin is fully functional without it.
    3134
    3235== Installation ==
    3336
    34371. Install and activate WooCommerce, then this plugin.
    35 2. Go to WooCommerce > Card Price Sync and choose your reference price, margin, rounding, floor and ceiling.
    36 3. Map products: fill in "Cardmarket product id" on each product, or use SKUs like `CM-372373` / `CM-372373-FOIL`.
     382. Go to WooCommerce > Card Price Sync, tick the games you sell (Magic is on by default), and choose your reference price, margin, rounding, floor and ceiling.
     393. Map products: fill in "Cardmarket product id" on each product, or use SKUs like `CM-372373` / `CM-372373-FOIL`, `YGO-CM-101788-FOIL` or `PKM-CM-550123-RH`.
    37404. Click "Fetch guides now", then "Run preview (dry run)" on the "Preview & sync" tab. Review the planned changes and click "Apply prices now".
    3841
    … …  
    4548= Can the plugin change anything on Cardmarket? =
    4649
    47 No. It is read-only towards Cardmarket: it makes two plain download requests for public Cardmarket files and never sends data to Cardmarket or to any Cardmarket account. Prices change only on your own WooCommerce products, and only when you click "Apply prices now" or approve a held change.
     50No. It is read-only towards Cardmarket: it makes plain download requests for public Cardmarket files and never sends data to Cardmarket or to any Cardmarket account. Prices change only on your own WooCommerce products, and only when you click "Apply prices now" or approve a held change.
    4851
    4952= Which price can I base my prices on? =
    5053
    51 Trend, 30-day average or lowest listing, chosen in WooCommerce > Card Price Sync. Foil products use the foil figure of the same reference.
     54Trend (the default), 30-day average or lowest listing, chosen in WooCommerce > Card Price Sync. Foil products use the foil figure of the same reference.
    5255
    5356= Which games are supported? =
    5457
    55 Magic: The Gathering singles only. Products for other games are skipped and never repriced.
     58Magic: The Gathering, Pokémon and Yu-Gi-Oh! singles. Each game is switched on under Games in the settings. Products for games that are not switched on, or that have no Cardmarket id, are skipped and never repriced.
     59
     60Foil works differently per game, because Cardmarket's guide does:
     61
     62* Magic and Yu-Gi-Oh!: Foil uses Cardmarket's foil price.
     63* Pokémon: Foil uses Cardmarket's reverse-holo price, the foil-type price Cardmarket publishes for Pokémon.
     64* Yu-Gi-Oh!: the guide has no lowest-listing foil price, so a Yu-Gi-Oh! foil product set to "lowest" is held, not priced. The 30-day average foil price is missing for most Yu-Gi-Oh! foil entries, so with that reference many foil products are held too. Trend (the default) has a foil price for most entries.
     65
     66Cardmarket's guide has no card-condition split. Condition multipliers are optional and default to 1.0.
    5667
    5768= What stops a wrong price from being written? =
    … …  
    6980== External services ==
    7081
    71 This plugin downloads two public Cardmarket files when you click "Fetch guides now" or run a preview/sync: the Magic price guide `https://downloads.s3.cardmarket.com/productCatalog/priceGuide/price_guide_1.json` and the Magic product list `https://downloads.s3.cardmarket.com/productCatalog/productList/products_singles_1.json` (card names, used only to check that each product's Cardmarket id matches its title). Each request is a plain HTTPS file download, and like any web request it carries standard HTTP metadata: your server's IP address and the User-Agent header "CopperquillCardPriceSync/0.1.1 (WordPress)". The plugin sends no cookies, account, API key or login, and no data about your site, products, orders or customers. Cardmarket guide prices are never shown on your storefront; only the price you configure (guide x your margin/rounding rules) is written to your products. Service provider: Sammelkartenmarkt GmbH & Co. KG (Cardmarket), https://www.cardmarket.com. Binding terms: the German General Terms and Conditions (Allgemeine Geschaeftsbedingungen) of Sammelkartenmarkt GmbH & Co. KG. The English page https://www.cardmarket.com/en/Policies/GeneralTermsAndConditions is a non-binding translation. Privacy policy (English): https://www.cardmarket.com/en/Policies/PrivacyPolicy.
     82This plugin downloads public Cardmarket files when you click "Fetch guides now" or run a preview/sync, for each game you have switched on. For each game there are two files, both under `https://downloads.s3.cardmarket.com/productCatalog/`: the price guide (`priceGuide/price_guide_N.json`) and the product list (`productList/products_singles_N.json`, card names, used only to check that each product's Cardmarket id matches its title). N is 1 for Magic, 6 for Pokémon and 3 for Yu-Gi-Oh!. Each request is a plain HTTPS file download, and like any web request it carries standard HTTP metadata: your server's IP address and the User-Agent header "CopperquillCardPriceSync/0.2.0 (WordPress)". The plugin sends no cookies, account, API key or login, and no data about your site, products, orders or customers. Cardmarket guide prices are never shown on your storefront; only the price you configure (guide x your margin/rounding rules) is written to your products. Service provider: Sammelkartenmarkt GmbH & Co. KG (Cardmarket), https://www.cardmarket.com. Binding terms: the German General Terms and Conditions (Allgemeine Geschaeftsbedingungen) of Sammelkartenmarkt GmbH & Co. KG. The English page https://www.cardmarket.com/en/Policies/GeneralTermsAndConditions is a non-binding translation. Privacy policy (English): https://www.cardmarket.com/en/Policies/PrivacyPolicy.
    7283
    7384The plugin contains no tracking or telemetry.
    7485
    75 Not affiliated with or endorsed by Cardmarket (Sammelkartenmarkt GmbH & Co. KG), or Wizards of the Coast.
     86Not affiliated with or endorsed by Cardmarket (Sammelkartenmarkt GmbH & Co. KG), The Pokémon Company, Konami or Wizards of the Coast. Magic: The Gathering, Pokémon and Yu-Gi-Oh! are trademarks of their respective owners and are named here only to identify the games.
    7687
    7788== Screenshots ==
    … …  
    8293
    8394== Changelog ==
     95
     96= 0.2.0 =
     97* New games: Pokémon and Yu-Gi-Oh! singles, switched on separately under Games. Magic stays the default, so existing sites see no change until a game is ticked.
     98* New SKU prefixes: `PKM-` (Pokémon, foil suffix RH or REVERSE) and `YGO-` (Yu-Gi-Oh!, foil suffix FOIL or F).
     99* The game-mismatch check and the card-name check cover all three games.
     100* Foil rules per game are stated in the FAQ.
     101* Readme: external services list the files for each game; trademark notice names the games' owners.
    84102
    85103= 0.1.2 =
Note: See TracChangeset for help on using the changeset viewer.