{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"landingPage": "/wp-admin/admin.php?page=wc-orders",
	"preferredVersions": {
		"php": "8.3",
		"wp": "latest"
	},
	"features": {
		"networking": true
	},
	"steps": [
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "woocommerce"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "installPlugin",
			"pluginData": {
				"resource": "wordpress.org/plugins",
				"slug": "orderbridge-for-woocommerce"
			},
			"options": {
				"activate": true
			},
			"ifAlreadyInstalled": "skip"
		},
		{
			"step": "mkdir",
			"path": "/wordpress/wp-content/mu-plugins"
		},
		{
			"step": "writeFile",
			"path": "/wordpress/wp-content/mu-plugins/orderbridge-for-woocommerce-demo.php",
			"data": "<?php\nadd_action( 'admin_notices', function () {\n\t$screen = get_current_screen();\n\tif ( ! $screen || 'woocommerce_page_wc-orders' !== $screen->id ) {\n\t\treturn;\n\t}\n\n\techo '<div class=\"notice notice-info\"><p>👋 Questions or want to learn more? <a href=\"https://products.wijnberg.dev/product/wordpress/plugins/orderbridge-for-woocommerce/\" target=\"_blank\" rel=\"noopener\"><strong>Read the OrderBridge documentation →</strong></a><small style=\"display:block;margin-top:.25rem\">Looking for the settings? <a href=\"/wp-admin/admin.php?page=wc-settings&amp;tab=wdevs_coe\">Open them here →</a></small></p><p><strong>Try the demo:</strong> Open an order, choose <em>Download export file</em> under <em>Order actions</em>, then apply the action.</p></div>';\n} );\n"
		},
		{
			"step": "setSiteOptions",
			"options": {
				"blogname": "OrderBridge for WooCommerce Demo",
				"woocommerce_allow_tracking": "no",
				"woocommerce_currency": "USD",
				"woocommerce_custom_orders_table_enabled": "yes",
				"woocommerce_default_country": "US:NY",
				"woocommerce_onboarding_profile": {
					"skipped": true
				},
				"woocommerce_coming_soon": "no",
				"permalink_structure": "/%postname%/",
				"wdevs_coe_templates": {
					"1": {
						"name": "B2B order export",
						"columns": {
							"product_fields": [
								{ "id": "sku", "name": "SKU", "order": 1 }
							],
							"order_item_fields": [
								{ "id": "name", "name": "Product", "order": 2 },
								{
									"id": "quantity",
									"name": "Quantity",
									"order": 3
								},
								{
									"id": "total",
									"name": "Line total",
									"order": 4
								}
							]
						}
					}
				},
				"wdevs_coe_order_edit_enabled": "yes",
				"wdevs_coe_order_edit_template_id": "1",
				"wdevs_coe_order_edit_file_format": "csv",
				"wdevs_coe_order_edit_csv_delimiter": ",",
				"wdevs_coe_order_edit_file_name": "order_{{order_id}}"
			}
		},
		{
			"step": "runPHP",
			"code": "<?php require '/wordpress/wp-load.php'; delete_transient( '_wc_activation_redirect' ); delete_transient( 'fs_plugin_orderbridge-for-woocommerce_activated' );"
		},
		{
			"step": "runPHP",
			"code": "<?php\nrequire '/wordpress/wp-load.php';\n\n$products = array();\nforeach (\n\tarray(\n\t\tarray( 'name' => 'Ergonomic Office Chair', 'sku' => 'CHAIR-100', 'price' => '249.00' ),\n\t\tarray( 'name' => 'Wireless Headset', 'sku' => 'HEADSET-200', 'price' => '89.00' ),\n\t\tarray( 'name' => 'Aluminum Laptop Stand', 'sku' => 'STAND-300', 'price' => '59.00' ),\n\t\tarray( 'name' => 'Mechanical Keyboard', 'sku' => 'KEYBOARD-400', 'price' => '119.00' ),\n\t) as $product_data\n) {\n\t$product = new WC_Product_Simple();\n\t$product->set_name( $product_data['name'] );\n\t$product->set_sku( $product_data['sku'] );\n\t$product->set_regular_price( $product_data['price'] );\n\t$product->set_price( $product_data['price'] );\n\t$product->set_manage_stock( true );\n\t$product->set_stock_quantity( 50 );\n\t$product->set_status( 'publish' );\n\t$product->save();\n\t$products[] = $product;\n}\n\n$demo_orders = array(\n\tarray( 'company' => 'Northwind Traders', 'first_name' => 'Olivia', 'last_name' => 'Bennett', 'email' => 'olivia.bennett@example.com', 'phone' => '+1 212-555-0101', 'billing_address' => '350 Fifth Avenue', 'billing_city' => 'New York', 'billing_state' => 'NY', 'billing_postcode' => '10118', 'shipping_address' => '11 Wall Street', 'shipping_city' => 'New York', 'shipping_state' => 'NY', 'shipping_postcode' => '10005', 'status' => 'completed', 'days_ago' => 3 ),\n\tarray( 'company' => 'Contoso Retail', 'first_name' => 'Liam', 'last_name' => 'Carter', 'email' => 'liam.carter@example.com', 'phone' => '+1 415-555-0102', 'billing_address' => '1 Market Street', 'billing_city' => 'San Francisco', 'billing_state' => 'CA', 'billing_postcode' => '94105', 'shipping_address' => '1355 Market Street', 'shipping_city' => 'San Francisco', 'shipping_state' => 'CA', 'shipping_postcode' => '94103', 'status' => 'processing', 'days_ago' => 9 ),\n\tarray( 'company' => 'Fabrikam Industries', 'first_name' => 'Emma', 'last_name' => 'Wilson', 'email' => 'emma.wilson@example.com', 'phone' => '+1 312-555-0103', 'billing_address' => '233 South Wacker Drive', 'billing_city' => 'Chicago', 'billing_state' => 'IL', 'billing_postcode' => '60606', 'shipping_address' => '875 North Michigan Avenue', 'shipping_city' => 'Chicago', 'shipping_state' => 'IL', 'shipping_postcode' => '60611', 'status' => 'on-hold', 'days_ago' => 18 ),\n\tarray( 'company' => 'Adventure Works', 'first_name' => 'Noah', 'last_name' => 'Thompson', 'email' => 'noah.thompson@example.com', 'phone' => '+1 206-555-0104', 'billing_address' => '400 Broad Street', 'billing_city' => 'Seattle', 'billing_state' => 'WA', 'billing_postcode' => '98109', 'shipping_address' => '800 Occidental Avenue South', 'shipping_city' => 'Seattle', 'shipping_state' => 'WA', 'shipping_postcode' => '98134', 'status' => 'completed', 'days_ago' => 32 ),\n);\n\nforeach ( $demo_orders as $index => $demo_order ) {\n\t$order = wc_create_order( array( 'status' => $demo_order['status'] ) );\n\t$order->add_product( $products[ $index % count( $products ) ], 1 );\n\t$order->add_product( $products[ ( $index + 1 ) % count( $products ) ], $index % 2 + 1 );\n\n\t$contact = array(\n\t\t'first_name' => $demo_order['first_name'],\n\t\t'last_name'  => $demo_order['last_name'],\n\t\t'company'    => $demo_order['company'],\n\t\t'country'    => 'US',\n\t);\n\t$order->set_address(\n\t\tarray_merge(\n\t\t\t$contact,\n\t\t\tarray(\n\t\t\t\t'email'     => $demo_order['email'],\n\t\t\t\t'phone'     => $demo_order['phone'],\n\t\t\t\t'address_1' => $demo_order['billing_address'],\n\t\t\t\t'city'      => $demo_order['billing_city'],\n\t\t\t\t'state'     => $demo_order['billing_state'],\n\t\t\t\t'postcode'  => $demo_order['billing_postcode'],\n\t\t\t)\n\t\t),\n\t\t'billing'\n\t);\n\t$order->set_address(\n\t\tarray_merge(\n\t\t\t$contact,\n\t\t\tarray(\n\t\t\t\t'phone'     => $demo_order['phone'],\n\t\t\t\t'address_1' => $demo_order['shipping_address'],\n\t\t\t\t'city'      => $demo_order['shipping_city'],\n\t\t\t\t'state'     => $demo_order['shipping_state'],\n\t\t\t\t'postcode'  => $demo_order['shipping_postcode'],\n\t\t\t)\n\t\t),\n\t\t'shipping'\n\t);\n\n\t$shipping = new WC_Order_Item_Shipping();\n\t$shipping->set_method_title( 'Flat rate' );\n\t$shipping->set_method_id( 'flat_rate' );\n\t$shipping->set_total( 12.50 );\n\t$order->add_item( $shipping );\n\t$order->set_payment_method( 'bacs' );\n\t$order->set_payment_method_title( 'Direct bank transfer' );\n\t$order->set_customer_note( 'Please deliver during business hours.' );\n\t$order->set_date_created( time() - ( $demo_order['days_ago'] * DAY_IN_SECONDS ) );\n\t$order->calculate_totals();\n\t$order->save();\n}\n"
		},
		{
			"step": "login",
			"username": "admin"
		}
	]
}
