This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a WordPress plugin that extends WooCommerce functionality to manage print orders sent to third-party providers. It adds custom order statuses ("Prepare to Printing" and "In Printing"), bulk actions, CSV export/import capabilities, and tracking fields specific to the printing workflow.
Plugin Details:
studiou-wc-ord-print-statusesBug Fix: Empty prod_var_type column in CSV export
Fixed an issue where the prod_var_type column was always empty in the "Prepare to Printing Export" CSV file.
Root Cause:
The SQL query in Studiou_DB_Manager::get_orders_for_printing() was incorrectly using the wc_product_attributes_lookup table to retrieve product variation attributes. This table stores product-level attribute data (for parent products), not the specific attribute values for individual variations.
Solution:
Modified the query (lines 55-65 in includes/class-db-manager.php) to:
wp_postmeta table instead of wc_product_attributes_lookupwp_terms using the slug field (matching against meta_value) instead of term_idHPOS Compatibility Declaration
Added explicit HPOS (High-Performance Order Storage) compatibility declaration to prevent WooCommerce warnings.
Solution:
Added before_woocommerce_init hook in the main plugin file to declare compatibility with WooCommerce custom order tables using FeaturesUtil::declare_compatibility().
Files Changed:
includes/class-db-manager.php - Updated LEFT JOIN logic for product_variations_attr and product_variations_name tablesstudiou-wc-ord-print-statuses.php - Added HPOS compatibility declarationImpact:
prod_var_type column in exported CSV files now correctly displays the Format attribute value (e.g., "A4", "A5") for each product variationTested On:
The plugin uses a manager-based architecture where the main plugin class (Studiou_WC_Ord_Print_Statuses) initializes specialized manager classes that handle distinct concerns:
Order_Status_Manager (includes/class-order-status-manager.php)
wc-to-print and wc-in-printOrder_Fields_Manager (includes/class-order-fields-manager.php)
to_print_date, in_print_date, external_ref_ord_no, external_ref_ord_deliveredBulk_Actions_Manager (includes/class-bulk-actions-manager.php)
Custom_Columns_Manager (includes/class-custom-columns-manager.php)
Import_Manager (includes/class-import-manager.php)
Order_Search_Manager (includes/class-order-search-manager.php)
Studiou_DB_Manager (includes/class-db-manager.php)
The export query in Studiou_DB_Manager::get_orders_for_printing() performs a complex join across:
wp_wc_orders (order data)wp_wc_order_product_lookup (order products)wp_posts (products and variations)wp_postmeta (product variation attributes - specifically 'attribute_pa_format')wp_terms and wp_term_taxonomy (product categories and variation attribute values)wp_postmeta (product images via '_thumbnail_id' meta)This query extracts: order number, product category, product name, variation name, variation type, image URL, quantity, and customer email.
to_print_date - Timestamp when order moved to "Prepare to Printing" statusin_print_date - Timestamp when order moved to "In Printing" statusexternal_ref_ord_no - External order number from print providerexternal_ref_ord_date - Date from external print providerexternal_ref_ord_delivered - Delivery timestampThe plugin includes a simple logging utility (includes/utils-log.php):
UtilsLog::log($message) - Logs to WordPress error log when WP_DEBUG is enabledwp-content/debug.log if WP_DEBUG_LOG is enabledAll managers register their hooks in constructors. Common patterns:
add_action('init', ...) - Register post statusesadd_filter('wc_order_statuses', ...) - Modify WooCommerce status listsadd_filter('bulk_actions-woocommerce_page_wc-orders', ...) - Add bulk actionsadd_action('woocommerce_admin_order_data_after_order_details', ...) - Display custom fieldsWhen testing status changes:
WP_DEBUG in wp-config.php to see log outputExport Format (Prepare to Printing):
order_no, prod_cat, prod_name, prod_var, prod_var_type, prod_img_url, qty, emailInPrint Protocol Import Format:
order_no, externalorder, externalorderdateDelivered Protocol Import Format:
order_noThe plugin supports internationalization:
studiou-wc-ord-print-statuseslanguages/ directory__(), _e(), _n_noop(), _x() functions for all user-facing stringsHPOS Compatibility: The plugin is fully compatible with WooCommerce High-Performance Order Storage (HPOS)
woocommerce_page_wc-orders hooks for HPOS compatibility{$wpdb->prefix}wc_orders table (HPOS custom table) in SQL querieswc_get_order() which works with both HPOS and legacy systemsFeaturesUtil::declare_compatibility('custom_order_tables', ...)Status Slug Naming: Custom statuses use wc- prefix internally but display without prefix (wc-to-print vs "Prepare to Printing")
CSV Output: The prepare_to_printing_export bulk action terminates with exit after outputting CSV headers, preventing further PHP execution
Database Queries: Direct SQL queries use $wpdb->prepare() implicitly through intval() for order IDs. Always sanitize inputs when modifying database operations.
Admin Menu: Import functionality is added as a submenu under WooCommerce admin menu, requires manage_woocommerce capability