Changeset 3841635
- Timestamp:
- 12/03/2026 06:06:37 AM (less than one hour ago)
- Location:
- copperquill-card-price-sync
- Files:
-
- 17 added
- 10 edited
-
tags/0.2.0 (added)
-
tags/0.2.0/copperquill-card-price-sync.php (added)
-
tags/0.2.0/includes (added)
-
tags/0.2.0/includes/class-cqps-admin.php (added)
-
tags/0.2.0/includes/class-cqps-fetcher.php (added)
-
tags/0.2.0/includes/class-cqps-guide-stream.php (added)
-
tags/0.2.0/includes/class-cqps-mapping.php (added)
-
tags/0.2.0/includes/class-cqps-planner.php (added)
-
tags/0.2.0/includes/class-cqps-pricing.php (added)
-
tags/0.2.0/includes/class-cqps-product-fields.php (added)
-
tags/0.2.0/includes/class-cqps-settings-schema.php (added)
-
tags/0.2.0/includes/class-cqps-store.php (added)
-
tags/0.2.0/includes/class-cqps-sync.php (added)
-
tags/0.2.0/includes/class-cqps-tier-free.php (added)
-
tags/0.2.0/includes/interface-cqps-tier.php (added)
-
tags/0.2.0/readme.txt (added)
-
tags/0.2.0/uninstall.php (added)
-
trunk/copperquill-card-price-sync.php (modified) (2 diffs)
-
trunk/includes/class-cqps-admin.php (modified) (1 diff)
-
trunk/includes/class-cqps-fetcher.php (modified) (1 diff)
-
trunk/includes/class-cqps-guide-stream.php (modified) (2 diffs)
-
trunk/includes/class-cqps-mapping.php (modified) (5 diffs)
-
trunk/includes/class-cqps-planner.php (modified) (1 diff)
-
trunk/includes/class-cqps-product-fields.php (modified) (1 diff)
-
trunk/includes/class-cqps-settings-schema.php (modified) (1 diff)
-
trunk/includes/class-cqps-sync.php (modified) (1 diff)
-
trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
copperquill-card-price-sync/trunk/copperquill-card-price-sync.php
r3839103 r3841635 2 2 /** 3 3 * 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.24 * 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 6 6 * Requires at least: 6.4 7 7 * Requires PHP: 8.0 … … 19 19 defined( 'ABSPATH' ) || exit; 20 20 21 define( 'CQPS_VERSION', '0. 1.2' );21 define( 'CQPS_VERSION', '0.2.0' ); 22 22 define( 'CQPS_FILE', __FILE__ ); 23 23 define( 'CQPS_DIR', plugin_dir_path( __FILE__ ) ); -
copperquill-card-price-sync/trunk/includes/class-cqps-admin.php
r3839103 r3841635 196 196 echo '<table class="form-table">'; 197 197 $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 ) { 199 199 $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>'; 200 200 } -
copperquill-card-price-sync/trunk/includes/class-cqps-fetcher.php
r3839103 r3841635 114 114 return array( 'ok' => false, 'msg' => 'catalog: HTTP ' . $code . ' or file too small' ); 115 115 } 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 ) ); 117 117 if ( ! $scan['ok'] ) { 118 118 self::drop( $tmp ); -
copperquill-card-price-sync/trunk/includes/class-cqps-guide-stream.php
r3839103 r3841635 13 13 final class CQPS_Guide_Stream { 14 14 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 */ 16 22 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 ), 18 26 ); 19 27 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). */ 21 29 const CATALOG_MIN_ROWS = 80000; 22 30 … … 49 57 public static function scan_names( $path, $wanted = null, $min_rows = null, $chunk = self::CHUNK ) { 50 58 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]; 51 64 } 52 65 -
copperquill-card-price-sync/trunk/includes/class-cqps-mapping.php
r3839103 r3841635 7 7 * 8 8 * 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] 10 10 * e.g. CM-372373, mtg-cm-12345-foil, PKM:CM:550123:RH, CM12345-NM-DE 11 11 * The trailing free part lets merchants keep condition/language suffixes; it is ignored here. … … 66 66 } 67 67 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'; 69 69 70 70 /** … … 83 83 $game = null; 84 84 if ( ! empty( $m[1] ) ) { 85 $game = 'MTG' === strtoupper( $m[1] ) ? 'mtg' : 'pokemon';85 $game = self::sku_game( $m[1] ); 86 86 } 87 87 $foil = null; … … 102 102 * Is a SKU foil suffix valid for the game? Cardmarket's Pokemon guide "-holo" columns are the 103 103 * 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. 105 105 * 106 106 * @param string|null $suffix Suffix from parse_sku. … … 138 138 } 139 139 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 140 149 private static function meta_game( $v ) { 141 150 $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; 143 152 } 144 153 -
copperquill-card-price-sync/trunk/includes/class-cqps-planner.php
r3839103 r3841635 43 43 } 44 44 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 45 63 private static function one( array $it, array $prices, array $s, $cap, &$mapped, array $names ) { 46 64 $meta = isset( $it['meta'] ) ? (array) $it['meta'] : array(); -
copperquill-card-price-sync/trunk/includes/class-cqps-product-fields.php
r3839103 r3841635 61 61 'options' => array( 62 62 '' => __( '(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!', 64 66 ), 65 67 ) -
copperquill-card-price-sync/trunk/includes/class-cqps-settings-schema.php
r3839103 r3841635 11 11 final class CQPS_Settings_Schema { 12 12 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). 14 14 const REFERENCES = array( 'trend', 'avg30', 'low' ); 15 15 const ROUNDINGS = array( 'none', 'step', 'charm' ); -
copperquill-card-price-sync/trunk/includes/class-cqps-sync.php
r3839103 r3841635 147 147 $prices[ $g ] = $scan['rows']; 148 148 } 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 ) ); 154 158 $run_id = gmdate( 'YmdHis' ) . '-' . wp_generate_password( 6, false, false ); 155 159 -
copperquill-card-price-sync/trunk/readme.txt
r3839697 r3841635 1 1 === Copperquill Card Price Sync for WooCommerce === 2 2 Contributors: mercuriocreations 3 Tags: woocommerce, cardmarket, magic the gathering, mtg, tcg3 Tags: woocommerce, cardmarket, pokemon, yugioh, mtg 4 4 Requires at least: 6.4 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.0 7 Stable tag: 0. 1.27 Stable tag: 0.2.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Sync WooCommerce prices for Magic : The Gathering singles from Cardmarket's public price guide. Free, no API key, unlimited products.11 Sync WooCommerce prices for Magic, Pokémon and Yu-Gi-Oh! singles from Cardmarket's public price guide. Free, no API key. 12 12 13 13 == Description == 14 14 15 15 For 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 17 Games: 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. 16 18 17 19 Safety first, because a wrong price is a real loss: … … 20 22 * Changes larger than your threshold (default 30%) are held for one-click approval. 21 23 * 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. 22 25 * Per-product lock, floor and ceiling. Products on sale are skipped. 23 26 * Foil prices never fall back to non-foil prices. 24 27 * Every applied, held, approved and rejected change is in the change log. 25 28 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 gamesare skipped.29 Mapping: 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. 27 30 28 31 Free and unlimited: every feature above, for any number of products, run on demand from the admin screen. 29 32 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 MTGprices 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.33 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 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. 31 34 32 35 == Installation == 33 36 34 37 1. 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` .38 2. 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. 39 3. 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`. 37 40 4. Click "Fetch guides now", then "Run preview (dry run)" on the "Preview & sync" tab. Review the planned changes and click "Apply prices now". 38 41 … … 45 48 = Can the plugin change anything on Cardmarket? = 46 49 47 No. It is read-only towards Cardmarket: it makes twoplain 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.50 No. 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. 48 51 49 52 = Which price can I base my prices on? = 50 53 51 Trend , 30-day average or lowest listing, chosen in WooCommerce > Card Price Sync. Foil products use the foil figure of the same reference.54 Trend (the default), 30-day average or lowest listing, chosen in WooCommerce > Card Price Sync. Foil products use the foil figure of the same reference. 52 55 53 56 = Which games are supported? = 54 57 55 Magic: The Gathering singles only. Products for other games are skipped and never repriced. 58 Magic: 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 60 Foil 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 66 Cardmarket's guide has no card-condition split. Condition multipliers are optional and default to 1.0. 56 67 57 68 = What stops a wrong price from being written? = … … 69 80 == External services == 70 81 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.82 This 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. 72 83 73 84 The plugin contains no tracking or telemetry. 74 85 75 Not affiliated with or endorsed by Cardmarket (Sammelkartenmarkt GmbH & Co. KG), or Wizards of the Coast.86 Not 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. 76 87 77 88 == Screenshots == … … 82 93 83 94 == 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. 84 102 85 103 = 0.1.2 =
Note:
See TracChangeset
for help on using the changeset viewer.