{
  "$schema": "https://playground.wordpress.net/blueprint-schema.json",
  "meta": {
    "title": "Simple Connection for ChronoFresh",
    "author": "tlloancy",
    "description": "WooCommerce in test mode, with a France zone and the fresh shipping method. Labels use the plugin sandbox account."
  },
  "landingPage": "/wp-admin/admin.php?page=sccfcw-settings",
  "preferredVersions": {
    "php": "latest",
    "wp": "latest"
  },
  "steps": [
    {
      "step": "installPlugin",
      "pluginData": {
        "resource": "wordpress.org/plugins",
        "slug": "woocommerce"
      },
      "options": {
        "activate": true
      },
      "ifAlreadyInstalled": "skip"
    },
    {
      "step": "installPlugin",
      "pluginData": {
        "resource": "wordpress.org/plugins",
        "slug": "simple-connection-for-chronofresh-woocommerce"
      },
      "options": {
        "activate": true
      },
      "ifAlreadyInstalled": "skip"
    },
    {
      "step": "runPHP",
      "code": "<?php\nrequire_once '/wordpress/wp-load.php';\nupdate_option( 'permalink_structure', '/%postname%/' );\n\nfunction bp_page( $title, $slug, $content, $front = false ) {\n\t$existing = get_page_by_path( $slug );\n\tif ( $existing instanceof WP_Post ) {\n\t\twp_update_post(\n\t\t\tarray(\n\t\t\t\t'ID'           => $existing->ID,\n\t\t\t\t'post_content' => $content,\n\t\t\t\t'post_status'  => 'publish',\n\t\t\t)\n\t\t);\n\t\t$id = (int) $existing->ID;\n\t} else {\n\t\t$id = (int) wp_insert_post(\n\t\t\tarray(\n\t\t\t\t'post_title'   => $title,\n\t\t\t\t'post_name'    => $slug,\n\t\t\t\t'post_status'  => 'publish',\n\t\t\t\t'post_type'    => 'page',\n\t\t\t\t'post_content' => $content,\n\t\t\t)\n\t\t);\n\t}\n\tif ( $front && $id ) {\n\t\tupdate_option( 'show_on_front', 'page' );\n\t\tupdate_option( 'page_on_front', $id );\n\t}\n\treturn $id;\n}\n\nupdate_option( 'woocommerce_onboarding_profile', array( 'skipped' => true, 'completed' => true ) );\nupdate_option( 'woocommerce_coming_soon', 'no' );\nupdate_option( 'woocommerce_store_pages_only', 'no' );\nupdate_option( 'woocommerce_currency', 'EUR' );\nif ( class_exists( 'WC_Install' ) ) {\n\tWC_Install::create_pages();\n}\n\nfunction bp_product( $name, $slug, $price ) {\n\t$product = new WC_Product_Simple();\n\t$product->set_name( $name );\n\t$product->set_slug( $slug );\n\t$product->set_regular_price( (string) $price );\n\t$product->set_status( 'publish' );\n\t$product->set_catalog_visibility( 'visible' );\n\t$product->set_stock_status( 'instock' );\n\t$product->save();\n\treturn $product;\n}\n\nupdate_option( 'sccfcw_mode', 'test' );\nupdate_option( 'woocommerce_default_country', 'FR' );\nbp_product( 'Fresh box', 'fresh-box', '24' );\n$zone = new WC_Shipping_Zone();\n$zone->set_zone_name( 'France' );\n$zone->save();\n$zone->add_location( 'FR', 'country' );\n$zone->add_shipping_method( 'chronofresh_fresh_13' );\nflush_rewrite_rules();\n"
    },
    {
      "step": "login",
      "username": "admin",
      "password": "password"
    }
  ],
  "features": {
    "networking": true
  }
}
