woocommerce
/
src
/
Admin
/
Features
/
MarketingRecommendations
/
MiscRecommendationsDataSourcePoller.php
DefaultMarketingRecommendations.php
3 months ago
Init.php
1 year ago
MarketingRecommendationsDataSourcePoller.php
1 year ago
MiscRecommendationsDataSourcePoller.php
1 year ago
MiscRecommendationsDataSourcePoller.php
67 lines
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Admin\Features\MarketingRecommendations; |
| 4 | |
| 5 | use Automattic\WooCommerce\Admin\RemoteSpecs\DataSourcePoller; |
| 6 | use WC_Helper; |
| 7 | |
| 8 | /** |
| 9 | * Specs data source poller class for misc recommendations. |
| 10 | * |
| 11 | * The misc recommendations are fetched from the WooCommerce.com API, the data structure looks like this: |
| 12 | * |
| 13 | * [ |
| 14 | * { |
| 15 | * "id": "woocommerce-analytics", |
| 16 | * "order_attribution_promotion_percentage": [ |
| 17 | * [ "9.7", 100 ], |
| 18 | * [ "9.6", 60 ], |
| 19 | * [ "9.5", 10 ] |
| 20 | * ] |
| 21 | * } |
| 22 | * ] |
| 23 | * |
| 24 | * @since 9.5.0 |
| 25 | */ |
| 26 | class MiscRecommendationsDataSourcePoller extends DataSourcePoller { |
| 27 | |
| 28 | /** |
| 29 | * Data Source Poller ID. |
| 30 | */ |
| 31 | const ID = 'misc_recommendations'; |
| 32 | |
| 33 | /** |
| 34 | * Class instance. |
| 35 | * |
| 36 | * @var MiscRecommendationsDataSourcePoller instance |
| 37 | */ |
| 38 | protected static $instance = null; |
| 39 | |
| 40 | /** |
| 41 | * Get class instance. |
| 42 | */ |
| 43 | public static function get_instance() { |
| 44 | if ( ! self::$instance ) { |
| 45 | self::$instance = new self( |
| 46 | self::ID, |
| 47 | self::get_data_sources(), |
| 48 | array( |
| 49 | 'transient_expiry' => DAY_IN_SECONDS, |
| 50 | ) |
| 51 | ); |
| 52 | } |
| 53 | return self::$instance; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Get data sources. |
| 58 | * |
| 59 | * @return array |
| 60 | */ |
| 61 | public static function get_data_sources() { |
| 62 | return array( |
| 63 | WC_Helper::get_woocommerce_com_base_url() . 'wp-json/wccom/marketing-tab/misc/recommendations.json', |
| 64 | ); |
| 65 | } |
| 66 | } |
| 67 |