Skip to content

Mbourza/pack_builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Pack Builder — WordPress Plugin

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.


Installation

  1. Upload the pack-builder folder to /wp-content/plugins/
  2. Activate the plugin from Plugins → Installed Plugins
  3. Go to Settings → Pack Builder to configure packs and prices
  4. Place [lens_pack_builder] on any page or post

Folder structure

pack-builder/
├── pack-builder.php   ← Main plugin file
└── assets/
    ├── lpb.css             ← Frontend styles
    └── lpb.js              ← Frontend logic

Admin Settings

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.

WooCommerce 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 lpbAddToCart is fired on the root element instead — useful for headless or custom checkout setups.

Hooks & Customisation

PHP filters

// Change products shown in the lens selector
add_filter( 'lpb_products_query', function( $args ) {
    $args['category'] = ['contact-lenses'];
    return $args;
});

JS event (no WooCommerce)

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
});

Requirements

  • WordPress 5.8+
  • PHP 7.4+
  • WooCommerce 6.0+ (optional but recommended)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors