From a581ef42e61034dea3344dc31e4852aa3591f9bd Mon Sep 17 00:00:00 2001 From: magdev Date: Wed, 31 Dec 2025 16:31:21 +0100 Subject: [PATCH] Fix fatal error and ensure WooCommerce settings tab integration (v1.0.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed critical bug preventing plugin activation and improved initialization sequence. Bug Fix: - Fixed fatal error: "Class 'WC_Settings_Page' not found" in Settings.php:15 - Root cause: Plugin initialized on 'plugins_loaded' before WooCommerce classes loaded - Changed initialization hook from 'plugins_loaded' to 'woocommerce_loaded' - Settings class now extends WC_Settings_Page without errors Settings Integration: - Settings page properly integrates as "Composable Products" tab in WooCommerce > Settings - Tab appears after WooCommerce core tabs (Products, Shipping, etc.) - All settings fields render correctly: - Default Selection Limit (number input) - Default Pricing Mode (select dropdown) - Display options (checkboxes for images, prices, total) Technical Details: - Using woocommerce_loaded hook ensures WC_Settings_Page class is available - Prevents race condition during plugin initialization - Settings class registration via woocommerce_get_settings_pages filter works correctly - No breaking changes to existing functionality Version bumped to 1.0.1 with updated CHANGELOG.md documenting the fix. Tested: Plugin now activates without errors and settings tab appears correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- CHANGELOG.md | 14 ++++++++++++++ wc-composable-product.php | 7 ++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb94560..84aa1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.1] - 2024-12-31 + +### Fixed + +- Fatal error "Class WC_Settings_Page not found" during plugin activation +- Changed initialization hook from `plugins_loaded` to `woocommerce_loaded` to ensure WooCommerce classes are available before plugin initialization +- Settings page now correctly integrates as a tab in WooCommerce > Settings + +### Technical + +- Plugin now waits for `woocommerce_loaded` action before initializing +- Prevents race condition where WooCommerce classes weren't loaded yet +- Settings tab appears correctly in WooCommerce settings interface + ## [1.0.0] - 2024-12-31 ### Added diff --git a/wc-composable-product.php b/wc-composable-product.php index e7aec01..8ef84af 100644 --- a/wc-composable-product.php +++ b/wc-composable-product.php @@ -3,7 +3,7 @@ * Plugin Name: WooCommerce Composable Products * Plugin URI: https://github.com/magdev/wc-composable-product * Description: Create composable products where customers select a limited number of items from a configurable set - * Version: 1.0.0 + * Version: 1.0.1 * Author: Marco Graetsch * Author URI: https://example.com * License: GPL v3 or later @@ -19,7 +19,7 @@ defined('ABSPATH') || exit; // Define plugin constants -define('WC_COMPOSABLE_PRODUCT_VERSION', '1.0.0'); +define('WC_COMPOSABLE_PRODUCT_VERSION', '1.0.1'); define('WC_COMPOSABLE_PRODUCT_FILE', __FILE__); define('WC_COMPOSABLE_PRODUCT_PATH', plugin_dir_path(__FILE__)); define('WC_COMPOSABLE_PRODUCT_URL', plugin_dir_url(__FILE__)); @@ -61,7 +61,8 @@ function wc_composable_product_init() { // Initialize main plugin class WC_Composable_Product\Plugin::instance(); } -add_action('plugins_loaded', 'wc_composable_product_init'); +// Use woocommerce_loaded to ensure WooCommerce classes are available +add_action('woocommerce_loaded', 'wc_composable_product_init'); /** * Activation hook