(temporary) add hard-coded fake orders-list suggestion data

This commit is contained in:
haszari 2019-02-22 16:06:18 +13:00
parent 37578aa5d4
commit 124e1a7b4a
1 changed files with 163 additions and 0 deletions

View File

@ -125,12 +125,174 @@ class WC_Marketplace_Suggestions {
return apply_filters( 'woocommerce_allow_marketplace_suggestions', true );
}
/**
* Test json API data.
*
* @return string fake JSON data
*/
private static function get_test_suggestions_data() {
$fake_suggestions = '[
{
"slug": "product-edit-empty-header",
"context": "product-edit-empty-header",
"title": "Recommended extensions",
"allow-dismiss": false
},
{
"slug": "product-edit-empty-footer-browse-all",
"context": "product-edit-empty-footer",
"link-text": "Browse all extensions",
"url": "https://woocommerce.com/product-category/woocommerce-extensions/",
"allow-dismiss": false
},
{
"slug": "product-edit-variation-images",
"hide-if-installed": "woocommerce-additional-variation-images",
"context": "product-edit-meta-tab-body",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Additional Variation Images",
"copy": "Add gallery images.",
"button-text": "From $49",
"url": "https://woocommerce.com/products/woocommerce-additional-variation-images/"
},
{
"slug": "product-edit-min-max-quantities",
"hide-if-installed": "woocommerce-additional-variation-images",
"context": "product-edit-meta-tab-body",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Min/Max Quantities",
"copy": "Specify min & max allowed product quantities.",
"button-text": "From $29",
"url": "https://woocommerce.com/products/min-max-quantities/"
},
{
"slug": "orders-empty-header",
"context": "orders-list-empty-header",
"title": "Tools for your store",
"allow-dismiss": false
},
{
"slug": "orders-empty-footer-browse-all",
"context": "orders-list-empty-footer",
"link-text": "Browse all extensions",
"url": "https://woocommerce.com/product-category/woocommerce-extensions/",
"allow-dismiss": false
},
{
"slug": "orders-empty-name-your-price",
"context": "orders-list-empty-body",
"hide-if-installed": "woocommerce-name-your-price",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Name Your Price",
"copy": "Allow customers to define the product price.",
"button-text": "From $149",
"url": "https://woocommerce.com/products/name-your-price/"
},
{
"slug": "orders-empty-zapier",
"context": "orders-list-empty-body",
"hide-if-installed": "woocommerce-zapier",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Zapier",
"copy": "Integrate your store with more than 1000 cloud services.",
"button-text": "From $59",
"url": "https://woocommerce.com/products/zapier/"
},
{
"slug": "orders-empty-shipment-tracking",
"context": "orders-list-empty-body",
"hide-if-installed": "woocommerce-shipment-tracking",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Shipment Tracking",
"copy": "Add shipment tracking info to your orders.",
"button-text": "From $49",
"url": "https://woocommerce.com/products/shipment-tracking/"
},
{
"slug": "orders-empty-table-rate-shipping",
"context": "orders-list-empty-body",
"hide-if-installed": "woocommerce-table-rate-shipping",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Table Rate Shipping",
"copy": "Advanced, flexible shipping.",
"button-text": "From $99",
"url": "https://woocommerce.com/products/table-rate-shipping/"
},
{
"slug": "products-empty-header-product-types",
"context": "products-list-empty-header",
"title": "Other types of products",
"allow-dismiss": false
},
{
"slug": "products-empty-footer-browse-all",
"context": "products-list-empty-footer",
"link-text": "Browse all extensions",
"url": "https://woocommerce.com/product-category/woocommerce-extensions/",
"allow-dismiss": false
},
{
"slug": "products-empty-memberships",
"context": "products-list-empty-body",
"hide-if-installed": "woocommerce-memberships",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Memberships",
"copy": "Give members access to restricted content or products, for a fee or for free.",
"button-text": "From $149",
"url": "https://woocommerce.com/products/woocommerce-memberships/"
},
{
"slug": "products-empty-addons",
"context": "products-list-empty-body",
"show-if-installed": [
"woocommerce-subscriptions",
"woocommerce-memberships"
],
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Product Add-Ons",
"copy": "Offer add-ons like gift wrapping, special messages or other special options for your products.",
"button-text": "From $149",
"url": "https://woocommerce.com/products/product-add-ons/"
},
{
"slug": "products-empty-product-bundles",
"context": "products-list-empty-body",
"hide-if-installed": "woocommerce-product-bundles",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Product Bundles",
"copy": "Offer customizable bundles and assembled products.",
"button-text": "From $49",
"url": "https://woocommerce.com/products/product-bundles/"
},
{
"slug": "products-empty-composite-products",
"context": "products-list-empty-body",
"title": "Composite Products",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"copy": "Create and offer product kits with configurable components.",
"button-text": "From $79",
"url": "https://woocommerce.com/products/composite-products/"
},
{
"slug": "products-list-enhancements-category",
"context": "products-list-inline",
"icon": "https://woocommerce.com/wp-content/uploads/2018/06/icon.png",
"title": "Looking to optimize your product pages?",
"button-text": "Explore enhancements",
"url": "https://woocommerce.com/product-category/woocommerce-extensions/product-extensions/"
}
]';
return json_decode( $fake_suggestions );
}
/**
* Pull suggestion data from remote endpoint & cache in a transient.
*
* @return array of json API data
*/
public static function get_suggestions_api_data() {
return self::get_test_suggestions_data();
$suggestion_data = get_transient( 'wc_marketplace_suggestions' );
if ( false !== $suggestion_data ) {
return $suggestion_data;
@ -159,3 +321,4 @@ class WC_Marketplace_Suggestions {
}
WC_Marketplace_Suggestions::init();