You've already forked wc-tier-and-package-prices
Fixed critical class redeclaration errors affecting all plugin functionality in version 1.1.12. All plugin component classes now properly guarded. **CRITICAL FIXES:** - Plugin completely non-functional in v1.1.12 (no settings, no frontend, no backend) - Fatal errors for WC_TPP_Admin, WC_TPP_Product_Meta, WC_TPP_Frontend, WC_TPP_Cart, WC_TPP_Settings classes - All classes now wrapped in class_exists() checks **Files Modified:** - includes/class-wc-tpp-admin.php - includes/class-wc-tpp-product-meta.php - includes/class-wc-tpp-frontend.php - includes/class-wc-tpp-cart.php - includes/class-wc-tpp-settings.php **Technical Details:** - Completes comprehensive redeclaration protection started in v1.1.9-1.1.12 - All 2 functions, 4 constants, and 6 classes now protected - Plugin activates successfully and all features functional - Settings page, product meta boxes, frontend display, cart integration all working 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
149 lines
5.4 KiB
PHP
149 lines
5.4 KiB
PHP
<?php
|
|
/**
|
|
* WooCommerce Settings Integration
|
|
*
|
|
* Adds Tier & Package Prices settings to WooCommerce Settings > Advanced tab
|
|
*
|
|
* @package WC_Tier_Package_Prices
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
if (!class_exists('WC_Settings_Page')) {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* WC_TPP_Settings class
|
|
*/
|
|
if (!class_exists('WC_TPP_Settings')) {
|
|
class WC_TPP_Settings extends WC_Settings_Page {
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct() {
|
|
$this->id = 'tier_package_prices';
|
|
$this->label = __('Tier & Package Prices', 'wc-tier-package-prices');
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Get sections
|
|
*
|
|
* @return array
|
|
*/
|
|
public function get_sections() {
|
|
$sections = array(
|
|
'' => __('General', 'wc-tier-package-prices'),
|
|
);
|
|
|
|
return apply_filters('woocommerce_get_sections_' . $this->id, $sections);
|
|
}
|
|
|
|
/**
|
|
* Get settings array
|
|
*
|
|
* @param string $current_section Current section name.
|
|
* @return array
|
|
*/
|
|
public function get_settings($current_section = '') {
|
|
$settings = array();
|
|
|
|
if ('' === $current_section) {
|
|
$settings = array(
|
|
array(
|
|
'title' => __('Tier & Package Prices Settings', 'wc-tier-package-prices'),
|
|
'type' => 'title',
|
|
'desc' => __('Configure tier pricing and package pricing options for your WooCommerce products.', 'wc-tier-package-prices'),
|
|
'id' => 'wc_tpp_settings',
|
|
),
|
|
|
|
array(
|
|
'title' => __('Enable Tier Pricing', 'wc-tier-package-prices'),
|
|
'desc' => __('Enable tier pricing for products', 'wc-tier-package-prices'),
|
|
'id' => 'wc_tpp_enable_tier_pricing',
|
|
'default' => 'yes',
|
|
'type' => 'checkbox',
|
|
'desc_tip' => __('Allow quantity-based pricing tiers. Customers get discounted prices when buying in larger quantities.', 'wc-tier-package-prices'),
|
|
),
|
|
|
|
array(
|
|
'title' => __('Enable Package Pricing', 'wc-tier-package-prices'),
|
|
'desc' => __('Enable fixed-price packages for products', 'wc-tier-package-prices'),
|
|
'id' => 'wc_tpp_enable_package_pricing',
|
|
'default' => 'yes',
|
|
'type' => 'checkbox',
|
|
'desc_tip' => __('Allow fixed-price packages with specific quantities. For example: 10 pieces for $50, 25 pieces for $100.', 'wc-tier-package-prices'),
|
|
),
|
|
|
|
array(
|
|
'title' => __('Display Pricing Table', 'wc-tier-package-prices'),
|
|
'desc' => __('Show tier and package pricing table on product pages', 'wc-tier-package-prices'),
|
|
'id' => 'wc_tpp_display_table',
|
|
'default' => 'yes',
|
|
'type' => 'checkbox',
|
|
'desc_tip' => __('Display the pricing table to customers on product pages.', 'wc-tier-package-prices'),
|
|
),
|
|
|
|
array(
|
|
'title' => __('Display Position', 'wc-tier-package-prices'),
|
|
'desc' => __('Choose where to display the pricing table on product pages.', 'wc-tier-package-prices'),
|
|
'id' => 'wc_tpp_display_position',
|
|
'default' => 'after_add_to_cart',
|
|
'type' => 'select',
|
|
'class' => 'wc-enhanced-select',
|
|
'css' => 'min-width:300px;',
|
|
'desc_tip' => true,
|
|
'options' => array(
|
|
'before_add_to_cart' => __('Before Add to Cart Button', 'wc-tier-package-prices'),
|
|
'after_add_to_cart' => __('After Add to Cart Button', 'wc-tier-package-prices'),
|
|
'after_price' => __('After Price', 'wc-tier-package-prices'),
|
|
),
|
|
),
|
|
|
|
array(
|
|
'title' => __('Restrict to Package Quantities', 'wc-tier-package-prices'),
|
|
'desc' => __('Limit quantities to defined package sizes only', 'wc-tier-package-prices'),
|
|
'id' => 'wc_tpp_restrict_package_quantities',
|
|
'default' => 'no',
|
|
'type' => 'checkbox',
|
|
'desc_tip' => __('When enabled, customers can only purchase products in the exact quantities defined in packages. The quantity input field will be hidden and replaced with package selection buttons.', 'wc-tier-package-prices'),
|
|
),
|
|
|
|
array(
|
|
'type' => 'sectionend',
|
|
'id' => 'wc_tpp_settings',
|
|
),
|
|
);
|
|
}
|
|
|
|
return apply_filters('woocommerce_get_settings_' . $this->id, $settings, $current_section);
|
|
}
|
|
|
|
/**
|
|
* Output the settings
|
|
*/
|
|
public function output() {
|
|
$settings = $this->get_settings();
|
|
WC_Admin_Settings::output_fields($settings);
|
|
}
|
|
|
|
/**
|
|
* Save settings
|
|
*/
|
|
public function save() {
|
|
$settings = $this->get_settings();
|
|
WC_Admin_Settings::save_fields($settings);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (class_exists('WC_TPP_Settings')) {
|
|
return new WC_TPP_Settings();
|
|
}
|
|
return null;
|