Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/asadchaudhary79/wc-variation-bundle/archive/refs/heads/main.zipPlugin Overview
Variation Bundle Addon is a powerful WooCommerce plugin that allows you to create bundle products by adding multiple products (simple and variable) to product variations. This plugin enables merchants to create complex product bundles where customers can customize bundle contents by selecting variations and adjusting quantities on the frontend.
Plugin Information
- Plugin Name: Variation Bundle Addon
- Version: 1.0.0
- Author: Asad Chaudhary
- Text Domain: wc-variation-bundle-main
- Requires: WooCommerce (Active)
- Requires PHP: 7.2 or higher
- Requires WordPress: 5.0 or higher
Key Features
1. Variation-Based Bundling
- Works with WooCommerce variable products
- Each variation can have its own bundle of products
- Toggle bundle functionality on/off per product via sidebar metabox
2. Flexible Product Selection
- Add simple products to bundles
- Add variable products with specific variations
- Support for multiple products per bundle
- Set custom quantities for each bundle item
3. Advanced Pricing
- Automatic price calculation based on bundle items
- Optional bundle sale price override
- Support for regular and sale prices
- Real-time price updates on frontend
4. Frontend Customization
- Customers can change variations for variable products in bundles
- Adjust quantities for each bundle item
- Minimum quantity lock option (admin configurable)
- Real-time price calculation and display
- Beautiful, responsive UI for bundle selection
5. Cart & Order Integration
- Proper cart item data storage
- Bundle items displayed in cart
- Bundle contents shown in order details
- Email integration with bundle information
- PDF invoice support (WP Overnight plugin)
6. Admin Features
- Easy-to-use product selector with Select2
- Visual bundle management interface
- Edit and remove bundle items
- Settings page in WooCommerce settings
- Bundle sale price field (optional)
Installation
-
Upload Plugin:
- Copy the
wc-variation-bundle-mainfolder to your WordPresswp-content/plugins/directory - Or upload via WordPress admin: Plugins → Add New → Upload Plugin
- Copy the
-
Activate Plugin:
- Go to WordPress Admin → Plugins
- Find "Variation Bundle Addon"
- Click "Activate"
-
Verify Requirements:
- Ensure WooCommerce is installed and active
- Check that your PHP version is 7.2 or higher
Configuration
Step 1: Enable Bundle Settings
- Go to WooCommerce → Settings → Variation Bundle tab
- Enable "Enable Package Products" checkbox
- (Optional) Enable "Enable Bundle Sales Pricing" for custom bundle sale prices
- (Optional) Enable "Enable Minimum Bundle Quantity Lock" to prevent customers from reducing quantities below admin-set minimums
- Click "Save changes"
Step 2: Create a Variable Product
- Go to Products → Add New
- Set product type to "Variable product"
- Add product attributes (e.g., Size, Color)
- Create variations for your product
- In the product sidebar, toggle "Bundle Variation" to ON
- This enables bundle functionality for all variations of this product
Step 3: Add Bundle Products to Variations
- Edit your variable product
- Go to the Variations tab
- Expand a variation you want to add bundles to
- Scroll down to the "Package Products" section
- Click "Add Product" button
- In the popup:
- Select a product from the dropdown
- If it's a variable product, select a variation
- Set the quantity
- Click "ADD PRODUCT +"
- Repeat for all products you want in the bundle
- (Optional) Set a "Bundle Sale Price" if you want to override the calculated price
- Click "Save changes" or "Update"
How It Works
Admin Workflow
- Product Setup: Create a variable product and enable "Bundle Variation" toggle
- Variation Configuration: For each variation, add bundle products via the Package Products panel
- Price Management: Prices are automatically calculated, or you can set a custom bundle sale price
- Settings: Configure global settings in WooCommerce → Settings → Variation Bundle
Frontend Experience
- Product Page: Customer views the variable product
- Variation Selection: Customer selects a variation (e.g., Size: Large, Color: Red)
- Bundle Display: The bundle contents appear below the variation selector
- Customization:
- Customer can change variations for variable products in the bundle
- Customer can adjust quantities (subject to minimum quantity lock if enabled)
- Price Update: Total price updates in real-time based on selections
- Add to Cart: Bundle is added to cart with all selected items and quantities
Cart & Checkout
- Bundle items are displayed in cart with quantities
- Order details show complete bundle contents
- Email notifications include bundle information
- PDF invoices (if using WP Overnight plugin) show bundle contents
File Structure
wc-variation-bundle-main/
├── wc-variation-bundle.php # Main plugin file
├── README.md # This file
├── admin/
│ ├── class-wc-packages-admin.php # AJAX handlers, product loading
│ ├── class-wc-packages-settings.php # WooCommerce settings integration
│ └── class-wc-packages-variation-handler.php # Variation bundle management
├── includes/
│ ├── class-custom-product-template.php # Frontend bundle display
│ └── helpers.php # Helper functions and hooks
├── templates/
│ └── variation-packages-panel.php # Admin bundle management UI
└── assets/
├── admin.css # Admin styles
├── admin.js # Admin JavaScript
├── frontend.css # Frontend styles
└── frontend.js # Frontend JavaScript
Technical Details
Database Structure
Post Meta Keys:
is_variation:'yes'or'no'- Marks product as bundle-enabled_variation_bundels: Array of bundle items (stored per variation)bundle_sale_price: Custom bundle sale price (optional, per variation)
Bundle Data Format (_variation_bundels):
[
[
'product_id' => '123',
'variation_id' => '456', // or '0' for simple products
'quantity' => 2
],
// ... more items
]
Cart Item Data:
[
'is_bundle' => true,
'bundle_items' => [...],
'bundle_sale_price' => 99.99,
'bundle_total_price' => 99.99
]
WordPress Hooks Used
Actions:
woocommerce_product_after_variable_attributes- Adds bundle fields to variationswoocommerce_save_product_variation- Saves bundle datawoocommerce_variation_options_pricing- Adds bundle sale price fieldwoocommerce_single_variation- Displays bundle on frontendwoocommerce_checkout_create_order_line_item- Saves bundle to orderwoocommerce_after_order_itemmeta- Displays bundle in admin orderwoocommerce_order_item_meta_end- Displays bundle in order detailswp_ajax_add_bundle_to_cart- AJAX cart handlerwp_ajax_get_variation_price- AJAX price calculator
Filters:
woocommerce_settings_tabs_array- Adds settings tabwoocommerce_get_item_data- Displays bundle in cartwoocommerce_hidden_order_itemmeta- Hides internal bundle metawoocommerce_before_calculate_totals- Updates cart priceswf_pklist_alter_product_name- PDF invoice integration
AJAX Endpoints
get_woocommerce_products: Fetches all publishable products (simple & variable)get_product_variations: Fetches variations for a variable productupdate_package_product: Updates a bundle item (admin)delete_package_product: Removes a bundle item (admin)add_bundle_to_cart: Adds bundle to cart (frontend)get_variation_price: Calculates and returns bundle price (frontend)save_variation_bundle_meta: Saves bundle toggle status
External Dependencies
- jQuery: Included with WordPress
- Select2/selectWoo: Uses WooCommerce's built-in selectWoo library (compatible with Select2 API)
- Accounting.js (v0.4.1): Loaded from CDN for price formatting
Settings Options
WooCommerce Settings → Variation Bundle
-
Enable Package Products (
variation_bundle_enable_packages)- Default:
yes - Enables/disables all bundle functionality
- Default:
-
Enable Bundle Sales Pricing (
variation_bundle_enable_pricing)- Default:
no - Shows/hides bundle sale price field in variation settings
- When disabled, removes all existing bundle sale prices
- Default:
-
Enable Minimum Bundle Quantity Lock (
bundle_min_quantity_lock)- Default:
no - When enabled, prevents customers from reducing quantities below admin-set minimums
- Default:
Code Examples
Get Bundle Products for a Variation
$variation_id = 123;
$bundle_products = get_post_meta($variation_id, '_variation_bundels', true);
if (is_array($bundle_products)) {
foreach ($bundle_products as $item) {
$product_id = $item['product_id'];
$variation_id = $item['variation_id'] ?? '0';
$quantity = $item['quantity'] ?? 1;
$product = $variation_id !== '0'
? wc_get_product($variation_id)
: wc_get_product($product_id);
if ($product) {
echo $product->get_name() . ' × ' . $quantity;
}
}
}
Check if Product is Bundle-Enabled
$product_id = 123;
$is_bundle = get_post_meta($product_id, 'is_variation', true) === 'yes';
if ($is_bundle) {
// This product has bundle functionality enabled
}
Calculate Bundle Total Price
$variation_id = 123;
$bundle_products = get_post_meta($variation_id, '_variation_bundels', true);
$bundle_sale_price = get_post_meta($variation_id, 'bundle_sale_price', true);
$total_regular_price = 0;
foreach ($bundle_products as $item) {
$product = !empty($item['variation_id']) && $item['variation_id'] !== '0'
? wc_get_product($item['variation_id'])
: wc_get_product($item['product_id']);
if ($product) {
$quantity = $item['quantity'] ?? 1;
$total_regular_price += floatval($product->get_regular_price()) * $quantity;
}
}
// Use bundle sale price if set, otherwise use calculated price
$final_price = !empty($bundle_sale_price)
? floatval($bundle_sale_price)
: $total_regular_price;
Get Bundle Items from Cart Item
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
if (isset($cart_item['is_bundle']) && $cart_item['is_bundle']) {
$bundle_items = $cart_item['bundle_items'] ?? [];
foreach ($bundle_items as $bundle_item) {
$product_id = $bundle_item['product_id'];
$variation_id = $bundle_item['variation_id'] ?? 0;
$quantity = $bundle_item['quantity'];
// Process bundle item
}
}
}
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Internet Explorer 11+ (with polyfills)
Troubleshooting
Bundle Settings Not Appearing
Problem: Package Products section doesn't show in variation settings
Solutions:
- Verify "Bundle Variation" toggle is ON in product sidebar
- Check that "Enable Package Products" is enabled in WooCommerce Settings
- Clear browser cache
- Check browser console for JavaScript errors
- Ensure you're editing a variation, not the parent product
Products Not Loading in Selector
Problem: Product dropdown is empty or shows error
Solutions:
- Check that products are published (not draft)
- Verify AJAX is working (check browser console)
- Check user permissions (must be able to edit products)
- Check PHP error logs for server-side errors
- Verify nonce is valid (try refreshing the page)
Price Not Calculating Correctly
Problem: Bundle price is wrong or not updating
Solutions:
- Verify all bundle products have prices set
- Check that variations have prices if using variable products
- Clear WooCommerce transients: WooCommerce → Status → Tools → Clear transients
- Check browser console for JavaScript errors
- Verify bundle sale price is set correctly (if using custom price)
Bundle Not Adding to Cart
Problem: Clicking "Add to Cart" doesn't work
Solutions:
- Check browser console for JavaScript errors
- Verify AJAX endpoint is accessible
- Check that all required bundle items are selected
- Verify product/variation stock status
- Check WooCommerce cart functionality is working
Bundle Items Not Showing in Cart/Order
Problem: Cart shows bundle but not individual items
Solutions:
- Verify cart item data is being saved correctly
- Check that
display_bundle_items_cartfilter is active - Clear WooCommerce cache
- Check order meta data in database
- Verify theme compatibility (some themes override cart templates)
Development
Hooks for Developers
Customize Bundle Display:
add_filter('variation_bundle_display_item', function($item_html, $bundle_item, $variation_id) {
// Customize bundle item HTML
return $item_html;
}, 10, 3);
Modify Bundle Price Calculation:
add_filter('variation_bundle_calculate_price', function($price, $bundle_products, $variation_id) {
// Custom price calculation logic
return $price;
}, 10, 3);
Add Custom Bundle Data to Cart:
add_filter('variation_bundle_cart_item_data', function($cart_data, $bundle_items) {
// Add custom data to cart item
$cart_data['custom_field'] = 'value';
return $cart_data;
}, 10, 2);
Changelog
Version 1.0.0
- Initial release
- Variation-based bundle functionality
- Admin bundle management interface
- Frontend bundle customization
- Cart and order integration
- Email and PDF invoice support
- Settings page integration
- Bundle sale price override
- Minimum quantity lock feature
Support
For support, feature requests, or bug reports:
- Author: Asad Chaudhary
- Check the troubleshooting section above for common issues
- Review WordPress and WooCommerce error logs for detailed error messages
License
Contact the author for license information regarding this plugin.
Credits
Developed by Asad Chaudhary
Note: This plugin requires WooCommerce to be installed and active. Ensure WooCommerce is properly configured before using this plugin. The plugin integrates deeply with WooCommerce's variation system and cart functionality.