You've already forked wc-composable-product
Initial implementation of WooCommerce Composable Products plugin
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>
This commit is contained in:
79
wc-composable-product.php
Normal file
79
wc-composable-product.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* Author: Marco Graetsch
|
||||
* Author URI: https://example.com
|
||||
* License: GPL v3 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
* Text Domain: wc-composable-product
|
||||
* Domain Path: /languages
|
||||
* Requires at least: 6.0
|
||||
* Requires PHP: 8.3
|
||||
* WC requires at least: 8.0
|
||||
* WC tested up to: 10.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
// Define plugin constants
|
||||
define('WC_COMPOSABLE_PRODUCT_VERSION', '1.0.0');
|
||||
define('WC_COMPOSABLE_PRODUCT_FILE', __FILE__);
|
||||
define('WC_COMPOSABLE_PRODUCT_PATH', plugin_dir_path(__FILE__));
|
||||
define('WC_COMPOSABLE_PRODUCT_URL', plugin_dir_url(__FILE__));
|
||||
define('WC_COMPOSABLE_PRODUCT_BASENAME', plugin_basename(__FILE__));
|
||||
|
||||
// Load Composer autoloader
|
||||
if (file_exists(WC_COMPOSABLE_PRODUCT_PATH . 'vendor/autoload.php')) {
|
||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'vendor/autoload.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if WooCommerce is active
|
||||
*/
|
||||
function wc_composable_product_check_woocommerce() {
|
||||
if (!class_exists('WooCommerce')) {
|
||||
add_action('admin_notices', function() {
|
||||
?>
|
||||
<div class="notice notice-error">
|
||||
<p><?php esc_html_e('WooCommerce Composable Products requires WooCommerce to be installed and active.', 'wc-composable-product'); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the plugin
|
||||
*/
|
||||
function wc_composable_product_init() {
|
||||
if (!wc_composable_product_check_woocommerce()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load text domain
|
||||
load_plugin_textdomain('wc-composable-product', false, dirname(WC_COMPOSABLE_PRODUCT_BASENAME) . '/languages');
|
||||
|
||||
// Initialize main plugin class
|
||||
WC_Composable_Product\Plugin::instance();
|
||||
}
|
||||
add_action('plugins_loaded', 'wc_composable_product_init');
|
||||
|
||||
/**
|
||||
* Activation hook
|
||||
*/
|
||||
function wc_composable_product_activate() {
|
||||
if (!class_exists('WooCommerce')) {
|
||||
deactivate_plugins(WC_COMPOSABLE_PRODUCT_BASENAME);
|
||||
wp_die(
|
||||
esc_html__('This plugin requires WooCommerce to be installed and active.', 'wc-composable-product'),
|
||||
esc_html__('Plugin Activation Error', 'wc-composable-product'),
|
||||
array('back_link' => true)
|
||||
);
|
||||
}
|
||||
}
|
||||
register_activation_hook(__FILE__, 'wc_composable_product_activate');
|
||||
Reference in New Issue
Block a user