# Tracknow WooCommerce Settings Configuration

## Issue Resolution Summary

The Tracknow WooCommerce plugin settings were not displaying properly in the WooCommerce settings page. This has been resolved by updating the settings configuration.

## Changes Made

### 1. Updated WooCommerce Settings Class

**File:** `admin/class-tracknow-for-woocommerce-wc-settings.php`

**Changes:**

- Fixed tab ID: `'tracknow-for-woocommerce'` → `'tracknowfwc'`
- Fixed prefix: `'tracknow_for_woocommerce_'` → `'woocommerce_tracknowfwc_'`
- Updated label: `'Tracknow'` → `'Tracknow'`

```php
// Before
$this->id = 'tracknow-for-woocommerce';
$this->label = __('Tracknow', 'tracknow-for-woocommerce');
$prefix = 'tracknow_for_woocommerce_';

// After
$this->id = 'tracknowfwc';
$this->label = __('Tracknow', 'tracknow-for-woocommerce');
$prefix = 'woocommerce_tracknowfwc_';
```

### 2. Settings Integration

The settings array is properly loaded from `admin/partials/tracknow-for-woocommerce-settings-main.php` which contains all the settings including the new database logging option.

## Current Settings Available

Now all these settings should appear in **WooCommerce → Settings → Tracknow**:

1. ✅ **Namespace** - Text field for affiliate system namespace
2. ✅ **Default Campaign ID** - Number field for default campaign
3. ✅ **Active** - Checkbox to activate tracking system
4. ✅ **Include Client Personal Info** - Checkbox for personal info tracking
5. ✅ **Enable Lifetime Tracking** - Checkbox for customer lifetime tracking
6. ✅ **Custom Coupon Meta Key** - Text field for custom coupon handling
7. ✅ **Coupon Contains Filter** - Text field for coupon filtering
8. ✅ **Thank You Page Pixel** - Checkbox for thank you page tracking
9. ✅ **Enable Debug Logs** - Checkbox for error_log debugging
10. ✅ **Enable Debug Logging to Database** - Checkbox for database logging (NEW)
11. ✅ **API Key** - Text field for API authentication
12. ✅ **Auto Approve on Completed** - Checkbox for auto-approval
13. ✅ **Auto Decline on Cancelled** - Checkbox for auto-decline

## Setting Storage Format

All settings are stored with the prefix `woocommerce_tracknowfwc_`:

- Namespace: `woocommerce_tracknowfwc_tracknow_namespace`
- Unified Debug Logging: `woocommerce_tracknowfwc_debug_logs` (enables both error_log and database logging)
- Debug Logs: `woocommerce_tracknowfwc_debug_logs`
- Active: `woocommerce_tracknowfwc_active`
- API Key: `woocommerce_tracknowfwc_api_key`
- etc.

## Access Settings

**URL:** `wp-admin/admin.php?page=wc-settings&tab=tracknowfwc`
**Path:** WooCommerce → Settings → Tracknow tab

## Database Logging Integration

The new "Enable Debug Logging to Database" setting controls whether the advanced logging system (with pagination, filtering, CSV export, migration) is active:

- **Enabled**: Logs are written to database with full features
- **Disabled**: Database logging is skipped (only error_log if that setting is enabled)
- **System events**: Always logged regardless of setting (plugin activation, etc.)

## Validation and Error Handling

The settings include validation for:

- Namespace cannot be empty or contain spaces
- Campaign ID must be numeric and >= 1
- API key is validated against Tracknow API endpoint
- All inputs are properly sanitized

## Testing Tools Provided

1. **test-minimal.php** - Tests settings file loading and class instantiation
2. **test-wc-settings.php** - Full settings debugging with option values
3. **test-settings.php** - Database logging setting toggle and testing
4. **test-migration.php** - Database migration system testing

## Troubleshooting

If settings still don't appear:

1. Check if WooCommerce is active and up-to-date
2. Verify plugin is activated properly
3. Run test-minimal.php to check for PHP errors
4. Clear any caching (object cache, page cache)
5. Check WordPress admin for PHP error messages

## Next Steps

The settings should now be fully functional. Users can:

1. Navigate to WooCommerce → Settings → Tracknow
2. Configure all 13 available settings
3. Enable database logging to access advanced log features
4. Use the migration system for table updates
5. Access logs via the admin menu when database logging is enabled

All settings will be properly saved and loaded using the standard WooCommerce settings API.
