WooCommerce Conditional Product Add-ons
A lightweight, fast, and professional WooCommerce plugin that allows you to add conditional product add-ons to your products with custom pricing and smart shipping calculations.
by XboxHacker · github.com/xboxhacker/wc-conditional-product-addons · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/xboxhacker/wc-conditional-product-addons/archive/refs/heads/main.zipReadme
WooCommerce Conditional Product Add-ons
A lightweight, fast, and professional WooCommerce plugin that allows you to add conditional product add-ons to your products with custom pricing and smart shipping calculations.
Features
✅ Conditional Logic - Show/hide add-ons based on product variation attributes ✅ Custom Pricing - Set custom prices for add-ons or use original product prices ✅ Smart Shipping - Automatically uses the largest dimensional package for shipping calculations ✅ Weight Totaling - Sums up weights of all products in cart ✅ Individual Cart Items - Each product (main + add-ons) added as separate cart items ✅ Variation Support - Full support for variable products with attribute-based conditions ✅ Clean UI - Modern, responsive interface matching your example ✅ Lightweight & Fast - Optimized code with minimal overhead
Installation
-
Upload the Plugin
- Upload the
wc-conditional-product-addonsfolder to/wp-content/plugins/ - Or zip the folder and upload via WordPress admin (Plugins > Add New > Upload Plugin)
- Upload the
-
Activate
- Go to Plugins in your WordPress admin
- Find "WooCommerce Conditional Product Add-ons"
- Click "Activate"
-
Requirements
- WordPress 5.8 or higher
- WooCommerce 5.0 or higher
- PHP 7.4 or higher
Usage
Setting Up Add-ons
-
Edit a Product
- Go to Products > Edit any product
- Scroll down to the "Product Add-ons" meta box
-
Add Product Add-ons
- Click "+ Add Product Add-on"
- Search and select the product you want to add as an add-on
- Choose pricing:
- Check "Use Original Product Price" to use the add-on product's regular price
- OR enter a "Custom Add-on Price" to override the price
-
Set Conditional Logic (Optional - For Variable Products Only)
- Click "+ Add Condition"
- Select an attribute (e.g., "Size")
- Select a value (e.g., "10 inch")
- Example: Only show the 10" subwoofer add-on when the 10" enclosure variation is selected
-
Save
- Publish or Update the product
How It Works for Customers
-
Product Page
- Customers see the main product with its variations (if applicable)
- Below the add-to-cart button, they see "Add Components to Complete Your System:"
- Available add-ons are displayed as checkboxes with names and prices
-
Conditional Display
- If the main product is variable, add-ons with conditions only appear when matching variations are selected
- Example: Select "10 inch" enclosure → 10" subwoofer checkbox appears
-
Adding to Cart
- Customer selects desired add-ons
- Clicks "Add to Cart"
- Main product AND each selected add-on are added as separate cart items
- Custom prices (if set) are applied to add-ons
-
Shipping Calculation
- The plugin automatically:
- Sums the weight of all products
- Uses the largest dimensional package among all products
- Passes this data to your shipping plugin for accurate rate calculations
- The plugin automatically:
Example Use Case
Selling Subwoofer Enclosures with Add-ons:
Main Product: Bronco Subwoofer Enclosure (Variable Product)
- Variations: 8" Box, 10" Box, 12" Box
Add-on Products:
- Rear Panel Speaker Grill - $50.00 (always available)
- Kicker 10" CompRT Sub - $159.95 (only with 10" or 12" box)
- Kicker Key500.1 Mono Amp - $269.95 (always available)
- Kicker Amp Remote Control Knob - $39.95 (only when amp is selected)
Setup:
- Create the main enclosure product with variations
- Add each add-on product in the "Product Add-ons" section
- Set conditions:
- 10" Subwoofer: Show when attribute_size = "10-inch" OR "12-inch"
- Rear Grill: No conditions (always shown)
- Amp: No conditions (always shown)
- Remote Knob: No conditions (but you could make it conditional on amp if desired)
Advanced Features
Drag & Drop Reordering
- Reorder add-ons by dragging the handle (☰) icon
- Order determines display order on the frontend
Custom Prices vs Original Prices
- Use Original Price: Add-on uses its regular WooCommerce product price
- Custom Price: Override with a special bundle/add-on price
Smart Shipping Integration
The plugin stores shipping data in the session:
WC()->session->get('wcca_shipping_dimensions')
This includes:
length: Maximum length among all productswidth: Maximum width among all productsheight: Maximum height among all productsweight: Sum of all product weights
Your shipping plugin can access this data for accurate calculations.
Styling & Customization
Custom CSS
Add custom styles to match your theme:
/* Change add-on wrapper background */
.wcca-addons-wrapper {
background: #ffffff;
border: 2px solid #000;
}
/* Style checked add-ons */
.wcca-addon-item:has(.wcca-addon-checkbox:checked) {
border-color: #your-brand-color;
background: #your-light-color;
}
Template Overrides
Copy templates from plugins/wc-conditional-product-addons/templates/ to your-theme/woocommerce/wcca/ to customize:
frontend-addons.php- Main add-ons displayadmin-addon-meta-box.php- Admin interfaceadmin-addon-row.php- Individual add-on configurationadmin-condition-row.php- Condition rule display
Hooks & Filters
Filters
Modify add-on display:
add_filter('wcca_addon_display_price', function($price, $addon, $product) {
// Modify the displayed price
return $price;
}, 10, 3);
Modify shipping dimensions:
add_filter('wcca_shipping_dimensions', function($dimensions, $package) {
// Customize dimension calculations
return $dimensions;
}, 10, 2);
Actions
After add-on is added to cart:
add_action('wcca_addon_added_to_cart', function($addon_product_id, $cart_item_key, $parent_key) {
// Custom logic after add-on is added
}, 10, 3);
Troubleshooting
Add-ons Not Showing
- Ensure WooCommerce is active
- Check that add-on products exist and are published
- For variable products, verify variation attributes match condition settings
Prices Not Updating
- Clear WooCommerce cart cache
- Check if "Use Original Price" is correctly set
- Verify custom price is a valid number
Conditional Logic Not Working
- Ensure attribute names match exactly (case-sensitive)
- Check that variation has the required attribute
- Verify JavaScript is loading (check browser console for errors)
Shipping Issues
- Ensure your shipping plugin supports custom dimensions
- Verify products have dimensions and weights set
- Check if shipping plugin is reading from
WC()->session->get('wcca_shipping_dimensions')
Support
For support, feature requests, or bug reports:
- Check the documentation above
- Review the code comments for developer guidance
- Contact your developer or WordPress support
Changelog
Version 1.0.0
- Initial release
- Conditional product add-ons
- Custom pricing support
- Smart shipping calculations
- Variable product support
- Drag & drop reordering
- Responsive design
Credits
Developed for William's Jeep aftermarket business.
License
This plugin is proprietary software. All rights reserved.