A WooCommerce-compatible WordPress plugin that lets customers build custom lens packs (2, 3, 4, or 5 pairs) and choose any product from your store for each slot.
- Upload the
pack-builderfolder to/wp-content/plugins/ - Activate the plugin from Plugins → Installed Plugins
- Go to Settings → Pack Builder to configure packs and prices
- Place
[lens_pack_builder]on any page or post
pack-builder/
├── pack-builder.php ← Main plugin file
└── assets/
├── lpb.css ← Frontend styles
└── lpb.js ← Frontend logic
| Setting | Description |
|---|---|
| Pairs | 2 / 3 / 4 / 5 |
| Enabled | Toggle each pack on or off |
| Label | e.g. "Best Value 4 Pairs Pack" |
| Price | Set a flat price per pack |
| Currency Symbol | $ / € / £ etc. |
| Add to Cart Text | Button label |
| WooCommerce Product ID | The base WooCommerce product used for cart. Leave 0 to disable WC integration. |
- When a customer adds a pack, the plugin adds the configured WooCommerce product to the cart and overrides its price with the pack price.
- Each chosen lens is saved as order meta and shown in cart, checkout, and admin orders.
- If no product ID is set, a JavaScript custom event
lpbAddToCartis fired on the root element instead — useful for headless or custom checkout setups.
// Change products shown in the lens selector
add_filter( 'lpb_products_query', function( $args ) {
$args['category'] = ['contact-lenses'];
return $args;
});document.getElementById('lpb-root').addEventListener('lpbAddToCart', function(e) {
console.log(e.detail.pack); // { pairs, price, label }
console.log(e.detail.selections); // array of product objects
});- WordPress 5.8+
- PHP 7.4+
- WooCommerce 6.0+ (optional but recommended)