CLAUDE.md 3.0 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What This Is

A WooCommerce extension plugin ("QDR - Studiou WC Custom Reports") that adds custom reporting pages under the WooCommerce admin menu. Currently provides a "Product Categories and Variants Summary" report with CSV export. Requires WordPress 6.8.1+, PHP 8.2+, WooCommerce 9.0+.

Development Environment

This is a WordPress plugin — there is no build step, linter, or test runner. Development is done by deploying to a WordPress installation with WooCommerce active. Enable WP_DEBUG in wp-config.php to see debug logging (prefixed [Studiou Debug] and [Studiou WC Custom Reports]).

Architecture

Autoloading convention: Classes prefixed StudiouWC_ are autoloaded from includes/. The class StudiouWC_Foo_Bar maps to includes/class-foo-bar.php. This is implemented via spl_autoload_register in the main plugin file.

Wiring: StudiouWC_Main is the entry point — it instantiates all services and registers WordPress/WooCommerce hooks. Dependencies flow via constructor injection: DB_Manager and Settings_Manager are created first, then passed into Admin_View and Export_Handler.

Dual query paths (HPOS): DB_Manager contains two versions of every SQL query — one for WooCommerce HPOS (High-Performance Order Storage using wc_orders table) and one for the legacy wp_posts-based order storage. The is_hpos_enabled() method selects the path at runtime. When modifying queries, both paths must be updated.

Report extensibility: New report types are added through Report_Factory. The current only type is product_categories_summary. To add a new type: create a report class, register it in Report_Factory::create_report(), add DB methods in DB_Manager, and add the option to the view dropdown in Admin_View.

Settings: Stored as a single WordPress option (studiou_wc_custom_reports_settings) managed by Settings_Manager. Settings are saved via AJAX (wp_ajax_studiou_save_settings). Default statuses include the custom status wc-to-print.

Property/variant columns: The report dynamically generates columns based on WooCommerce product attribute taxonomies (e.g., pa_format). The selected attribute is configured in settings as default_property. Property values are resolved from attribute_pa_{property} post meta on variation products.

Key Constants

Defined in studiou-wc-custom-reports.php:

  • STUDIOU_WC_CUSTOM_REPORTS_TEXT_DOMAIN'studiou-wc-custom-reports'
  • STUDIOU_WC_CUSTOM_REPORTS_VERSION — current version string

Internationalization

Text domain: studiou-wc-custom-reports. Translation files go in languages/. Czech translation (cs_CZ) exists. All user-facing strings use __() / _e() with the text domain constant.

Admin Pages

  • WooCommerce > Custom Reports (studiou-custom-reports) — main report page with filters and data table
  • WooCommerce > Custom Report Settings (studiou-reports-settings) — configuration page for defaults