magdev c6a48d6404 Fix critical UI bugs in admin and frontend
Fixes three critical bugs reported in CLAUDE.md:

1. Admin rendering bug - Fixed CSS to prevent both General and Composable
   Options tabs from showing simultaneously on initial page load
   - Enhanced CSS specificity with !important flags
   - Added body.product-type-composable selectors for proper visibility control
   - Hides Composable Options tab by default, shows only when composable type selected

2. Frontend product selector not appearing - Fixed WooCommerce integration
   - Added hide_default_add_to_cart() method to Cart_Handler
   - Hooks woocommerce_is_purchasable filter to return false for composable products
   - This hides WooCommerce's default add-to-cart button
   - Allows our custom product selector to be the only interface

3. Localized price formatting - Implemented proper WooCommerce price formatting
   - Added wc_price Twig function in Plugin.php
   - Updated Product_Selector to pass formatted price HTML to template
   - Added price_format data to JavaScript localization
   - Implemented formatPrice() method in frontend.js
   - Supports all WooCommerce price formats (currency position, decimals, separators)
   - Template now uses {{ fixed_price_html|raw }} and {{ zero_price_html|raw }}
   - JavaScript dynamically formats prices using locale-specific settings

Technical improvements:
- Cart_Handler.php: +14 lines (hide_default_add_to_cart method)
- Plugin.php: +7 lines (wc_price function, price format localization)
- Product_Selector.php: +2 lines (formatted price HTML context)
- templates/product-selector.twig: Modified to use formatted price HTML
- assets/css/admin.css: +24 lines (enhanced tab visibility control)
- assets/js/frontend.js: +28 lines (formatPrice method with WooCommerce format support)

All PHP files pass lint checks. Frontend now properly displays localized prices
with correct currency symbols, decimal separators, and thousand separators for
all WooCommerce-supported locales (CHF for Switzerland, € for Europe, etc.).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-31 22:08:08 +01:00
2025-12-31 21:35:53 +01:00

WooCommerce Composable Products

Create composable products where customers can select a limited number of items from a configurable set of products.

Description

This plugin adds a new product type to WooCommerce that allows customers to build their own product bundles by selecting from a predefined set of simple or variable products. Think of it as a "build your own gift box" or "create your sticker pack" feature.

Key Features

  • Custom Product Type: New "Composable Product" type in WooCommerce
  • Flexible Selection: Define available products by category, tag, or SKU
  • Configurable Limits: Set global or per-product selection limits
  • Pricing Options: Fixed price or sum of selected products
  • Multi-language Support: Fully translatable with i18n support
  • Modern UI: Clean interface built with Twig templates and vanilla JavaScript

Requirements

  • PHP 8.3 or higher
  • WordPress 6.0 or higher
  • WooCommerce 8.0 or higher

Installation

  1. Upload the plugin files to /wp-content/plugins/wc-composable-product/
  2. Run composer install --no-dev in the plugin directory
  3. Activate the plugin through the 'Plugins' menu in WordPress
  4. Configure global settings under WooCommerce > Settings > Composable Products

Usage

Creating a Composable Product

  1. Go to Products > Add New
  2. Select "Composable Product" as the product type
  3. Configure product details:
    • Set the selection limit (or use global default)
    • Choose pricing mode (fixed or sum)
    • Define available products by category, tag, or SKU
  4. Publish the product

Global Settings

Navigate to WooCommerce > Settings > Composable Products to configure:

  • Default selection limit
  • Default pricing mode
  • Display options

Development

This project was created with AI assistance (Claude.AI) and follows WordPress and WooCommerce best practices.

Building from Source

composer install

Translation

Generate POT file:

wp i18n make-pot . languages/wc-composable-product.pot

License

GPL v3 or later - see LICENSE file for details

Author

Marco Graetsch

Support

For issues and feature requests, please use the GitHub issue tracker.

Description
User composable products for WooCommerce
Readme 1 MiB
Languages
PHP 72%
JavaScript 14.2%
CSS 8.1%
Twig 5.7%