<?php
/**
 * Add Store Customization Fields
 * This script adds fields for store owners to customize button colors and background color
 * 
 * Fields added:
 * - button_color: Primary button color (default: #3b82f6)
 * - button_hover_color: Button hover color (default: #2563eb)
 * - background_color: Store page background color (default: #0f172a)
 */

require_once 'config.php';

echo "=== Adding Store Customization Fields ===\n\n";

// Check if button_color column exists
$checkCol1 = $conn->query("SHOW COLUMNS FROM stores LIKE 'button_color'");
if ($checkCol1->num_rows == 0) {
    $alterSql1 = "ALTER TABLE stores ADD COLUMN button_color VARCHAR(7) DEFAULT '#3b82f6' AFTER hero_color_2";
    if ($conn->query($alterSql1)) {
        echo "✓ Added 'button_color' column\n";
    } else {
        echo "✗ Error adding button_color: " . $conn->error . "\n";
        exit(1);
    }
} else {
    echo "✓ 'button_color' column already exists\n";
}

// Check if button_hover_color column exists
$checkCol2 = $conn->query("SHOW COLUMNS FROM stores LIKE 'button_hover_color'");
if ($checkCol2->num_rows == 0) {
    $alterSql2 = "ALTER TABLE stores ADD COLUMN button_hover_color VARCHAR(7) DEFAULT '#2563eb' AFTER button_color";
    if ($conn->query($alterSql2)) {
        echo "✓ Added 'button_hover_color' column\n";
    } else {
        echo "✗ Error adding button_hover_color: " . $conn->error . "\n";
        exit(1);
    }
} else {
    echo "✓ 'button_hover_color' column already exists\n";
}

// Check if background_color column exists
$checkCol3 = $conn->query("SHOW COLUMNS FROM stores LIKE 'background_color'");
if ($checkCol3->num_rows == 0) {
    $alterSql3 = "ALTER TABLE stores ADD COLUMN background_color VARCHAR(7) DEFAULT '#0f172a' AFTER button_hover_color";
    if ($conn->query($alterSql3)) {
        echo "✓ Added 'background_color' column\n";
    } else {
        echo "✗ Error adding background_color: " . $conn->error . "\n";
        exit(1);
    }
} else {
    echo "✓ 'background_color' column already exists\n";
}

echo "\n=== Done! ===\n";
echo "Store owners can now customize button colors and background color.\n";
?>


