{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"meta": {
		"title": "MageComp Pincode Checker – Live Demo",
		"description": "WooCommerce products + Pincode Checker with demo pincodes",
		"author": "MageComp",
		"categories": [
			"woocommerce",
			"ecommerce"
		]
	},
	"preferredVersions": {
		"php": "8.3",
		"wp": "latest"
	},
	"features": {
		"networking": true
	},
	"login": true,
	"landingPage": "/wp-admin/admin.php?page=pincode-settings",
	"steps": [
		{
			"step": "login",
			"username": "admin"
		},
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "woocommerce"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "magecomp-pincode-checker"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire_once '/wordpress/wp-load.php';\nupdate_option('woocommerce_onboarding_profile', ['completed' => true, 'skipped' => true]);\nupdate_option('woocommerce_task_list_hidden', 'yes');\nupdate_option('woocommerce_task_list_complete', 'yes');\nupdate_option('woocommerce_admin_install_timestamp', time());\ndelete_transient('_wc_activation_redirect');\n"
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire_once '/wordpress/wp-load.php';\nrequire_once ABSPATH . 'wp-admin/includes/file.php';\nrequire_once ABSPATH . 'wp-admin/includes/media.php';\nrequire_once ABSPATH . 'wp-admin/includes/image.php';\n\n// Single product data\n$title       = 'Laptop';\n$description = 'A laptop suitable for everyday use.';\n$price       = 599.99;\n$sale_price  = 549.99;\n$stock       = 5;\n\n// Product image\n$image_url = 'https://subcategoryslider.magecomp.org/pub/media/catalog/product/cache/207e23213cf636ccdef205098cf3c8a3/l/a/laptop-black.png';\n\n$post_id = wp_insert_post([\n    'post_title'   => $title,\n    'post_content' => $description,\n    'post_status'  => 'publish',\n    'post_type'    => 'product'\n]);\n\nif ($post_id && !is_wp_error($post_id)) {\n    update_post_meta($post_id, '_regular_price', $price);\n    update_post_meta($post_id, '_sale_price', $sale_price);\n    update_post_meta($post_id, '_price', $sale_price);\n    update_post_meta($post_id, '_manage_stock', 'yes');\n    update_post_meta($post_id, '_stock', $stock);\n    update_post_meta($post_id, '_stock_status', 'instock');\n    wp_set_object_terms($post_id, 'simple', 'product_type');\n\n    // Set featured image\n    $attachment_id = media_sideload_image($image_url, $post_id, null, 'id');\n    if (!is_wp_error($attachment_id)) {\n        set_post_thumbnail($post_id, $attachment_id);\n    }\n}\n"
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire_once '/wordpress/wp-load.php';\n\n$demo_pincodes = [\n    ['400001','Mumbai','Maharashtra','IN'],\n    ['110001','Delhi','Delhi','IN'],\n    ['560001','Bengaluru','Karnataka','IN'],\n    ['600001','Chennai','Tamil Nadu','IN'],\n    ['700001','Kolkata','West Bengal','IN'],\n    ['500001','Hyderabad','Telangana','IN'],\n    ['411001','Pune','Maharashtra','IN'],\n    ['380001','Ahmedabad','Gujarat','IN'],\n    ['10001','New York','New York','US'],\n    ['90001','Los Angeles','California','US'],\n    ['60601','Chicago','Illinois','US'],\n    ['77001','Houston','Texas','US'],\n    ['33101','Miami','Florida','US'],\n    ['94102','San Francisco','California','US'],\n    ['98101','Seattle','Washington','US'],\n    ['75001','Paris','Ile-de-France','FR'],\n    ['10115','Berlin','Berlin','DE'],\n    ['80331','Munich','Bavaria','DE'],\n    ['SW1A','London','England','GB'],\n    ['M5H','Toronto','Ontario','CA']\n];\n\nglobal $wpdb;\nforeach ($demo_pincodes as $data) {\n    $exists = $wpdb->get_var($wpdb->prepare(\n        \"SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'mgcppich_pincodes' LIMIT 1\",\n        $data[0]\n    ));\n\n    if ($exists) {\n        continue;\n    }\n\n    $post_id = wp_insert_post([\n        'post_type' => 'mgcppich_pincodes',\n        'post_status' => 'publish',\n        'post_title' => $data[0]\n    ]);\n\n    if ($post_id && !is_wp_error($post_id)) {\n        update_post_meta($post_id, 'city', $data[1]);\n        update_post_meta($post_id, 'state', $data[2]);\n        update_post_meta($post_id, 'country', $data[3]);\n        update_post_meta($post_id, 'status', 1);\n    }\n}\n"
		},
		{
			"step": "wp-cli",
			"command": "wp option update permalink_structure '/%postname%/'"
		}
	]
}