You've already forked wc-composable-product
Implemented custom WooCommerce product type allowing customers to build their own product bundles by selecting from predefined sets of products. Features: - Custom "Composable Product" type with admin interface - Product selection by category, tag, or SKU - Configurable selection limits (global and per-product) - Dual pricing modes: fixed price or sum of selected products - Modern responsive frontend with Twig templates - AJAX add-to-cart functionality - Full internationalization support (.pot file) - WooCommerce settings integration - Comprehensive documentation Technical implementation: - PHP 8.3+ with PSR-4 autoloading - Twig 3.0 templating engine via Composer - Vanilla JavaScript with jQuery for frontend interactions - WordPress and WooCommerce hooks for seamless integration - Security: input sanitization, validation, and output escaping - Translation-ready with text domain 'wc-composable-product' Documentation: - README.md: Project overview and features - INSTALL.md: Installation and usage guide - IMPLEMENTATION.md: Technical architecture - CHANGELOG.md: Version history 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
109 lines
3.5 KiB
PHP
109 lines
3.5 KiB
PHP
<?php
|
|
/**
|
|
* Admin Settings
|
|
*
|
|
* @package WC_Composable_Product
|
|
*/
|
|
|
|
namespace WC_Composable_Product\Admin;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
/**
|
|
* Settings class
|
|
*/
|
|
class Settings extends \WC_Settings_Page {
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct() {
|
|
$this->id = 'composable_products';
|
|
$this->label = __('Composable Products', 'wc-composable-product');
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Get settings array
|
|
*
|
|
* @return array
|
|
*/
|
|
public function get_settings() {
|
|
$settings = [
|
|
[
|
|
'title' => __('Composable Products Settings', 'wc-composable-product'),
|
|
'type' => 'title',
|
|
'desc' => __('Configure default settings for composable products.', 'wc-composable-product'),
|
|
'id' => 'wc_composable_settings',
|
|
],
|
|
[
|
|
'title' => __('Default Selection Limit', 'wc-composable-product'),
|
|
'desc' => __('Default number of items customers can select.', 'wc-composable-product'),
|
|
'id' => 'wc_composable_default_limit',
|
|
'type' => 'number',
|
|
'default' => '5',
|
|
'custom_attributes' => [
|
|
'min' => '1',
|
|
'step' => '1',
|
|
],
|
|
'desc_tip' => true,
|
|
],
|
|
[
|
|
'title' => __('Default Pricing Mode', 'wc-composable-product'),
|
|
'desc' => __('How to calculate the price of composable products.', 'wc-composable-product'),
|
|
'id' => 'wc_composable_default_pricing',
|
|
'type' => 'select',
|
|
'default' => 'sum',
|
|
'options' => [
|
|
'sum' => __('Sum of selected products', 'wc-composable-product'),
|
|
'fixed' => __('Fixed price', 'wc-composable-product'),
|
|
],
|
|
'desc_tip' => true,
|
|
],
|
|
[
|
|
'title' => __('Show Product Images', 'wc-composable-product'),
|
|
'desc' => __('Display product images in the selection interface.', 'wc-composable-product'),
|
|
'id' => 'wc_composable_show_images',
|
|
'type' => 'checkbox',
|
|
'default' => 'yes',
|
|
],
|
|
[
|
|
'title' => __('Show Product Prices', 'wc-composable-product'),
|
|
'desc' => __('Display individual product prices in the selection interface.', 'wc-composable-product'),
|
|
'id' => 'wc_composable_show_prices',
|
|
'type' => 'checkbox',
|
|
'default' => 'yes',
|
|
],
|
|
[
|
|
'title' => __('Show Total Price', 'wc-composable-product'),
|
|
'desc' => __('Display the total price as customers make selections.', 'wc-composable-product'),
|
|
'id' => 'wc_composable_show_total',
|
|
'type' => 'checkbox',
|
|
'default' => 'yes',
|
|
],
|
|
[
|
|
'type' => 'sectionend',
|
|
'id' => 'wc_composable_settings',
|
|
],
|
|
];
|
|
|
|
return apply_filters('wc_composable_settings', $settings);
|
|
}
|
|
|
|
/**
|
|
* Output the settings
|
|
*/
|
|
public function output() {
|
|
$settings = $this->get_settings();
|
|
\WC_Admin_Settings::output_fields($settings);
|
|
}
|
|
|
|
/**
|
|
* Save settings
|
|
*/
|
|
public function save() {
|
|
$settings = $this->get_settings();
|
|
\WC_Admin_Settings::save_fields($settings);
|
|
}
|
|
}
|