{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"meta": {
		"title": "Admin Powerups for WooCommerce demo",
		"author": "smartwpplugins",
		"description": "A demo WooCommerce store with fictional products, customers and orders, and a few power-ups switched on.",
		"categories": [
			"WooCommerce"
		]
	},
	"landingPage": "/wp-admin/admin.php?page=apwc-powerups",
	"preferredVersions": {
		"php": "8.3",
		"wp": "latest"
	},
	"features": {
		"networking": true
	},
	"steps": [
		{
			"step": "setSiteOptions",
			"options": {
				"blogname": "Admin Powerups Demo Store",
				"permalink_structure": "/%postname%/",
				"woocommerce_default_country": "US:CA",
				"woocommerce_store_address": "500 Market Street",
				"woocommerce_store_city": "San Francisco",
				"woocommerce_store_postcode": "94105",
				"woocommerce_currency": "USD"
			}
		},
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "woocommerce"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "admin-powerups-for-woocommerce"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "runPHP",
			"code": "<?php\n/**\n * Demo store: use High-performance order storage (Advanced order search needs it).\n * Runs before any order exists; orders are created in the next step, a new request.\n */\nrequire '/wordpress/wp-load.php';\n\nif ( function_exists( 'wc_get_container' ) && class_exists( '\\Automattic\\WooCommerce\\Internal\\DataStores\\Orders\\DataSynchronizer' ) ) {\n\twc_get_container()->get( \\Automattic\\WooCommerce\\Internal\\DataStores\\Orders\\DataSynchronizer::class )->create_database_tables();\n\tupdate_option( 'woocommerce_custom_orders_table_data_sync_enabled', 'no' );\n\tupdate_option( 'woocommerce_custom_orders_table_enabled', 'yes' );\n}\n"
		},
		{
			"step": "runPHP",
			"code": "<?php\n/**\n * Demo store for the WordPress.org Live Preview (WordPress Playground).\n * Fictional data only: example.test emails, 555 phone numbers.\n */\nrequire '/wordpress/wp-load.php';\n\n// Nothing in the sandbox can send mail; don't try while the demo is built.\nadd_filter( 'pre_wp_mail', '__return_false' );\n\nupdate_option( 'woocommerce_onboarding_profile', array( 'skipped' => true ) );\nupdate_option( 'woocommerce_coming_soon', 'no' );\nupdate_option( 'woocommerce_store_pages_only', 'no' );\ndelete_transient( '_wc_activation_redirect' );\n\nforeach ( array( 'WC_Gateway_COD', 'WC_Gateway_BACS' ) as $apwc_demo_class ) {\n\tif ( class_exists( $apwc_demo_class ) ) {\n\t\t$apwc_demo_gateway                      = new $apwc_demo_class();\n\t\t$apwc_demo_gateway->settings['enabled'] = 'yes';\n\t\tupdate_option( $apwc_demo_gateway->get_option_key(), $apwc_demo_gateway->settings );\n\t}\n}\n\n// Products: name, price, SKU, stock.\n$apwc_demo_products = array(\n\tarray( 'Canvas Tote Bag', '28.00', 'ES-TOTE', 42 ),\n\tarray( 'Stoneware Mug', '14.00', 'ES-MUG', 3 ),\n\tarray( 'Wool Throw Blanket', '59.00', 'ES-THROW', 18 ),\n\tarray( 'Linen Apron', '32.00', 'ES-APRON', 0 ),\n\tarray( 'Brass Desk Lamp', '89.00', 'ES-LAMP', 9 ),\n\tarray( 'Cedar Candle', '22.00', 'ES-CANDLE', 61 ),\n\tarray( 'Leather Notebook', '36.00', 'ES-NOTE', 27 ),\n\tarray( 'Walnut Serving Board', '48.00', 'ES-BOARD', 6 ),\n);\n$apwc_demo_product_ids = array();\nforeach ( $apwc_demo_products as $apwc_demo_row ) {\n\t$apwc_demo_id      = wc_get_product_id_by_sku( $apwc_demo_row[2] );\n\t$apwc_demo_product = $apwc_demo_id ? wc_get_product( $apwc_demo_id ) : new WC_Product_Simple();\n\t$apwc_demo_product->set_name( $apwc_demo_row[0] );\n\t$apwc_demo_product->set_status( 'publish' );\n\t$apwc_demo_product->set_regular_price( $apwc_demo_row[1] );\n\t$apwc_demo_product->set_sku( $apwc_demo_row[2] );\n\t$apwc_demo_product->set_manage_stock( true );\n\t$apwc_demo_product->set_stock_quantity( $apwc_demo_row[3] );\n\t$apwc_demo_product->set_low_stock_amount( 5 );\n\t$apwc_demo_product_ids[] = $apwc_demo_product->save();\n}\n\n// Customers: first, last, phone, street, city, state, postcode.\n$apwc_demo_people = array(\n\tarray( 'Maya', 'Patel', '(415) 555-0142', '1200 Valencia Street', 'San Francisco', 'CA', '94110' ),\n\tarray( 'Jonah', 'Castillo', '(512) 555-0117', '88 Rainey Street', 'Austin', 'TX', '78701' ),\n\tarray( 'Priya', 'Raman', '(206) 555-0163', '415 Pike Street', 'Seattle', 'WA', '98101' ),\n\tarray( 'Marcus', 'Lowell', '(617) 555-0128', '31 Newbury Street', 'Boston', 'MA', '02116' ),\n\tarray( 'Elena', 'Fischer', '(303) 555-0190', '1600 Market Street', 'Denver', 'CO', '80202' ),\n\tarray( 'Sam', 'Okafor', '(312) 555-0175', '200 Wacker Drive', 'Chicago', 'IL', '60606' ),\n);\n$apwc_demo_customers = array();\nforeach ( $apwc_demo_people as $apwc_demo_person ) {\n\t$apwc_demo_login = strtolower( $apwc_demo_person[0] . '.' . $apwc_demo_person[1] );\n\t$apwc_demo_email = $apwc_demo_login . '@example.test';\n\t$apwc_demo_user  = get_user_by( 'email', $apwc_demo_email );\n\t$apwc_demo_uid   = $apwc_demo_user ? $apwc_demo_user->ID : wp_insert_user(\n\t\tarray(\n\t\t\t'user_login' => $apwc_demo_login,\n\t\t\t'user_pass'  => wp_generate_password( 24 ),\n\t\t\t'user_email' => $apwc_demo_email,\n\t\t\t'first_name' => $apwc_demo_person[0],\n\t\t\t'last_name'  => $apwc_demo_person[1],\n\t\t\t'role'       => 'customer',\n\t\t)\n\t);\n\tif ( is_wp_error( $apwc_demo_uid ) ) {\n\t\tcontinue;\n\t}\n\t$apwc_demo_customer = new WC_Customer( $apwc_demo_uid );\n\t$apwc_demo_customer->set_billing_first_name( $apwc_demo_person[0] );\n\t$apwc_demo_customer->set_billing_last_name( $apwc_demo_person[1] );\n\t$apwc_demo_customer->set_billing_email( $apwc_demo_email );\n\t$apwc_demo_customer->set_billing_phone( $apwc_demo_person[2] );\n\t$apwc_demo_customer->set_billing_address_1( $apwc_demo_person[3] );\n\t$apwc_demo_customer->set_billing_city( $apwc_demo_person[4] );\n\t$apwc_demo_customer->set_billing_state( $apwc_demo_person[5] );\n\t$apwc_demo_customer->set_billing_postcode( $apwc_demo_person[6] );\n\t$apwc_demo_customer->set_billing_country( 'US' );\n\t$apwc_demo_customer->save();\n\t$apwc_demo_customers[] = array( $apwc_demo_uid, $apwc_demo_person, $apwc_demo_email );\n}\n\n// Orders over the last 30 days: mixed statuses, a few guest orders.\n$apwc_demo_statuses = array( 'processing', 'completed', 'completed', 'on-hold', 'processing', 'completed', 'pending', 'completed', 'processing', 'completed', 'cancelled', 'completed', 'processing', 'completed', 'on-hold', 'completed' );\nif ( ! wc_get_orders( array( 'limit' => 1, 'return' => 'ids' ) ) ) {\n\tforeach ( $apwc_demo_statuses as $apwc_demo_i => $apwc_demo_status ) {\n\t\t$apwc_demo_guest = ( 0 === $apwc_demo_i % 5 );\n\t\t$apwc_demo_who   = $apwc_demo_customers[ $apwc_demo_i % count( $apwc_demo_customers ) ];\n\t\t$apwc_demo_order = wc_create_order( array( 'customer_id' => $apwc_demo_guest ? 0 : $apwc_demo_who[0] ) );\n\t\tforeach ( array( $apwc_demo_i % 8, ( $apwc_demo_i * 3 + 1 ) % 8 ) as $apwc_demo_n => $apwc_demo_p ) {\n\t\t\t$apwc_demo_order->add_product( wc_get_product( $apwc_demo_product_ids[ $apwc_demo_p ] ), 1 + ( $apwc_demo_i + $apwc_demo_n ) % 3 );\n\t\t}\n\t\t$apwc_demo_person = $apwc_demo_who[1];\n\t\t$apwc_demo_order->set_address(\n\t\t\tarray(\n\t\t\t\t'first_name' => $apwc_demo_person[0],\n\t\t\t\t'last_name'  => $apwc_demo_person[1],\n\t\t\t\t'email'      => $apwc_demo_guest ? 'guest' . $apwc_demo_i . '@example.test' : $apwc_demo_who[2],\n\t\t\t\t'phone'      => $apwc_demo_person[2],\n\t\t\t\t'address_1'  => $apwc_demo_person[3],\n\t\t\t\t'city'       => $apwc_demo_person[4],\n\t\t\t\t'state'      => $apwc_demo_person[5],\n\t\t\t\t'postcode'   => $apwc_demo_person[6],\n\t\t\t\t'country'    => 'US',\n\t\t\t),\n\t\t\t'billing'\n\t\t);\n\t\t$apwc_demo_order->set_payment_method( 0 === $apwc_demo_i % 4 ? 'cod' : 'bacs' );\n\t\t$apwc_demo_order->set_payment_method_title( 0 === $apwc_demo_i % 4 ? 'Cash on delivery' : 'Direct bank transfer' );\n\t\t$apwc_demo_order->calculate_totals();\n\t\t$apwc_demo_order->set_date_created( time() - ( 30 - $apwc_demo_i * 2 ) * DAY_IN_SECONDS );\n\t\t$apwc_demo_order->set_status( $apwc_demo_status );\n\t\t$apwc_demo_order->save();\n\t}\n}\n\n// Switch on a handful of power-ups; the rest stay off for the visitor to try.\nif ( class_exists( '\\SmartWP\\AdminPowerups\\Plugin' ) ) {\n\t$apwc_demo_registry = \\SmartWP\\AdminPowerups\\Plugin::instance()->registry();\n\tforeach ( array( 'advanced-order-search', 'order-address-sync', 'user-address-columns', 'advanced-customer-search', 'quick-stock', 'guest-accounts' ) as $apwc_demo_module ) {\n\t\t$apwc_demo_registry->set_enabled( $apwc_demo_module, true );\n\t}\n}\n"
		},
		{
			"step": "login",
			"username": "admin",
			"password": "password"
		}
	]
}