<?php
/**
 * Add Hero Customization Fields to Stores Table
 * This script adds fields for store owners to customize their hero section colors and logo
 * 
 * Fields added:
 * - hero_color_1: First color for gradient (default: #3b82f6)
 * - hero_color_2: Second color for gradient (default: #8b5cf6)
 * - logo_url: Already exists, but we'll ensure it's there
 */

require_once 'config.php';

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

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

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

// Check if logo_url column exists
$checkLogo = $conn->query("SHOW COLUMNS FROM stores LIKE 'logo_url'");
if ($checkLogo->num_rows == 0) {
    $alterSql3 = "ALTER TABLE stores ADD COLUMN logo_url VARCHAR(255) NULL AFTER whatsapp_group_link";
    if ($conn->query($alterSql3)) {
        echo "✓ Added 'logo_url' column\n";
    } else {
        echo "✗ Error adding logo_url: " . $conn->error . "\n";
        exit(1);
    }
} else {
    echo "✓ 'logo_url' column already exists\n";
}

echo "\n=== Done! ===\n";
echo "Store owners can now customize their hero section colors and upload logos.\n";
?>


