Leven BOGO Promotion
BOGO Promotion is a custom WordPress plugin designed by enigmart. It enables advanced "Buy One Get One" (BOGO) promotional offers for WooCommerce stores, allowing flexible configuration of free products, eligible categories, and promotional rules. The plugin is optimized for performance and seamless integration with existing shop workflows.
by Sharkbytes.gr · github.com/enigmart/wp-woocommerce-bogo-plugin
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/enigmart/wp-woocommerce-bogo-plugin/archive/refs/heads/master.zipBOGO Promotion Plugin
A custom WordPress plugin for WooCommerce that implements sophisticated "Buy One Get One" (BOGO) promotional offers specifically designed for nail polish and beauty products.
🎯 Plugin Purpose
This plugin creates intelligent BOGO promotions with the following features:
- Automatic free product addition when qualifying items are in cart
- Time-based promotion activation with configurable start/end dates
- Product-specific rules based on SKU patterns and categories
- Smart cart management that prevents duplicate free items
- User-friendly notifications and promotional banners
🛠️ Technical Requirements
System Requirements
- WordPress: 5.0 or higher
- WooCommerce: 4.0 or higher
- PHP: 7.2 or higher
- MySQL: 5.6 or higher
Dependencies
- WooCommerce plugin (required)
- WordPress Hooks API
- WooCommerce Cart & Session APIs
🚀 Installation
- Upload the plugin folder to
/wp-content/plugins/ - Activate the plugin through the WordPress admin panel
- Navigate to WooCommerce > BOGO Προσφορές for configuration
⚙️ Configuration & Customization
1. Product Categories & SKUs
The plugin works with predefined product groups defined in includes/class-leven-bogo.php:
// Nail polish SKU patterns
private $nail_polish_skus = array('00960', '01331', '01332');
// Crystal top/base products
private $crystal_top_base_pro = array('01534', '00962');
// Premium products (12€ category)
private $top_12euro = array('01591', '01592', '01593', ...);
To modify product groups:
- Edit the arrays in the constructor of
Leven_BOGOclass - Add new SKU patterns or remove existing ones
- Update the logic in
is_nail_polish()and related methods
2. Promotion Timing
Configure promotion periods:
private $promo_start = '2025-07-13 22:00:00';
private $promo_end = '2025-07-15 23:59:59';
To change promotion dates:
- Modify the
$promo_startand$promo_endvariables - Use MySQL datetime format (YYYY-MM-DD HH:MM:SS)
- The
is_promo_active()method handles timezone conversion
3. BOGO Rules Logic
The main promotion logic is in the apply_bogo_discounts() method:
- Rule 1: Buy nail polish → Get cheapest nail polish free
- Rule 2: Buy crystal top/base → Get matching product free
- Rule 3: Buy premium products → Get specific free items
To customize rules:
- Modify the conditional logic in
apply_bogo_discounts() - Adjust the
find_cheapest_eligible_product()method - Update the
get_free_product_for_premium()method
4. User Interface Elements
Promotional Banners
- Location:
add_promotion_banner()method - Styling:
/assets/css/bogo-styles.css - Customization: Edit HTML structure and CSS classes
Cart Notifications
- Discount labels: Modified via
show_discount_label()filter - Info messages: Added through
add_cart_info()action - Text strings: Translatable via WordPress i18n functions
5. Admin Interface
Basic admin panel available at WooCommerce > BOGO Προσφορές:
public function render_admin_page() {
// Currently basic - can be extended
echo '<div class="wrap">';
echo '<h1>Leven BOGO Προσφορές</h1>';
echo '<p>Ρυθμίσεις για τις προσφορές 1+1</p>';
echo '</div>';
}
To enhance admin interface:
- Add form fields for dynamic configuration
- Implement settings save/load functionality
- Create product selection interfaces
🔧 Key Methods & Hooks
Core Methods
apply_bogo_discounts()- Main promotion logicis_promo_active()- Time-based activation checkfind_cheapest_eligible_product()- Product selection logicadd_free_product_to_cart()- Cart manipulation
WordPress Hooks Used
woocommerce_before_calculate_totals- Apply discountswoocommerce_cart_item_price- Show discount labelswoocommerce_before_cart- Display bannerswp_enqueue_scripts- Load assets
🎨 Styling & Assets
CSS Structure
- Main styles:
/assets/css/bogo-styles.css - Banner styling: Responsive design with mobile support
- Cart labels: Integrated with WooCommerce styling
JavaScript Features
- Dynamic updates:
/assets/js/bogo-scripts.js - Cart interaction: Real-time promotion feedback
- AJAX compatibility: Works with WooCommerce AJAX cart
🐛 Debugging & Development
Debug Mode
When WP_DEBUG is enabled:
- Debug information displayed in admin/frontend footer
- Detailed logging of promotion logic
- Cart state inspection tools
Development Notes
- All text strings are translatable (text domain:
leven-bogo) - Follows WordPress coding standards
- Compatible with WooCommerce hooks and filters
- Optimized for performance with minimal database queries
📝 Customization Examples
Adding New Product Categories
// In class constructor, add new array
private $new_category_skus = array('12345', '67890');
// In apply_bogo_discounts(), add new logic
if ($this->is_new_category($product_sku)) {
// Your BOGO logic here
}
Modifying Promotion Messages
// In show_discount_label() method
$discount_text = __('🎁 ΔΩΡΕΑΝ (Προσφορά 1+1)', 'leven-bogo');
// Change to your preferred message
Extending Admin Interface
// In render_admin_page() method
// Add settings forms, product selectors, date pickers, etc.
📋 File Structure
leven-bogo-promotion/
├── leven-bogo-promotion.php # Main plugin file
├── includes/
│ └── class-leven-bogo.php # Core functionality
├── assets/
│ ├── css/
│ │ └── bogo-styles.css # Styling
│ └── js/
│ └── bogo-scripts.js # JavaScript
└── README.md # This file
🔒 Security Notes
- Direct file access prevention implemented
- WooCommerce dependency checks
- Proper WordPress nonce usage (when forms are added)
- Sanitized input/output handling
📞 Support & Maintenance
For technical support or feature requests:
- Review the code comments for implementation details
- Test changes in a staging environment first
- Backup your site before making modifications
- Monitor WooCommerce compatibility with updates
Version: 1.0.0
Author: enigmart
Text Domain: leven-bogo
License: Proprietary