fix: licensing table creation, consistent meta keys, checkout virtual detection
1. License table auto-creation: - Added ensure_tables() check on plugins_loaded - Tables created automatically if missing 2. Consistent licensing meta keys: - ProductsController now uses _woonoow_licensing_enabled - Matches LicensingModule and LicenseManager 3. Checkout virtual-only detection: - Added needs_shipping to Cart interface - Checkout uses cart.needs_shipping from WooCommerce API - Fallback to item-level virtual/downloadable check 4. Login redirect for logged-in users added previously
This commit is contained in:
@@ -96,7 +96,7 @@ class LicenseManager {
|
||||
if (!$product) continue;
|
||||
|
||||
// Check if product has licensing enabled
|
||||
$licensing_enabled = get_post_meta($product_id, '_licensing_enabled', true);
|
||||
$licensing_enabled = get_post_meta($product_id, '_woonoow_licensing_enabled', true);
|
||||
if ($licensing_enabled !== 'yes') continue;
|
||||
|
||||
// Check if license already exists for this order item
|
||||
|
||||
@@ -37,10 +37,25 @@ class LicensingModule {
|
||||
*/
|
||||
public static function maybe_init_manager() {
|
||||
if (ModuleRegistry::is_enabled('licensing')) {
|
||||
// Ensure tables exist
|
||||
self::ensure_tables();
|
||||
LicenseManager::init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure database tables exist
|
||||
*/
|
||||
private static function ensure_tables() {
|
||||
global $wpdb;
|
||||
$table = $wpdb->prefix . 'woonoow_licenses';
|
||||
|
||||
// Check if table exists
|
||||
if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
|
||||
LicenseManager::create_tables();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle module enable
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user