woocommerce/plugins/woocommerce-admin/src/Features/ActivityPanels.php

69 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/**
* WooCommerce Activity Panel.
* NOTE: DO NOT edit this file in WooCommerce core, this is generated from woocommerce-admin.
*/
2019-08-01 18:17:08 +00:00
namespace Automattic\WooCommerce\Admin\Features;
use Automattic\WooCommerce\Admin\Notes\Notes;
2019-07-31 19:47:32 +00:00
/**
* Contains backend logic for the activity panel feature.
*/
class ActivityPanels {
/**
* Class instance.
*
* @var ActivityPanels instance
*/
protected static $instance = null;
/**
* Get class instance.
*/
public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Hook into WooCommerce.
*/
public function __construct() {
add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
// Run after Automattic\WooCommerce\Admin\Loader.
add_filter( 'woocommerce_components_settings', array( $this, 'component_settings' ), 20 );
// New settings injection.
add_filter( 'woocommerce_admin_shared_settings', array( $this, 'component_settings' ), 20 );
}
/**
* Adds fields so that we can store activity panel last read and open times.
*
* @param array $user_data_fields User data fields.
* @return array
*/
public function add_user_data_fields( $user_data_fields ) {
return array_merge(
$user_data_fields,
array(
'activity_panel_inbox_last_read',
'activity_panel_reviews_last_read',
)
);
}
/**
* Add alert count to the component settings.
*
* @param array $settings Component settings.
*/
public function component_settings( $settings ) {
Migrate Stock Panel to Homescreen (https://github.com/woocommerce/woocommerce-admin/pull/5729) * Refactor low stock variable to be the count instead of a boolean. * Add initial render of the Stock panel on the homescreen. * Move existing Stock panel to homescreen accordion. * Ensure int value for low stock product count. * Update ProductImage styling. * Update stock activity car styles. * Only show 5 low stock products. * Add "undo" action to the stock updated snackbar. * Fix check for explicit notice dismissal when taking actions. * Hide now-in-stock products after updating. By cllearing "edited" flag on successful update. * Fetch more products after updating stock. * Fix the number of product placeholders shown. * Only show products placeholders on the initial fetch. * Fix placeholder style. * Fetch low stock count dynamically. * Let initialOpen prop toggle Accordion panels if they haven't been toggled by the user. * Refactor item total count state. Allows for auto-updating item totals whenever identical queries (from a totals perspective) are issued. * Add last order date to low stock products API response. * Allow non-date strings in ActivityCard date prop. * Add last order date to stock panel cards. * Remove empty stock panel view. * Add test file for StockPanel. * Only request necessary fields from products endpoint. * Add test for products fetch after stock update. * Fix field name. * Add test for last order date in low stock products API response. * Stock panel should be initially closed. * Skip updating a product if the quantity is unchanged.
2020-11-25 18:51:15 +00:00
$settings['alertCount'] = Notes::get_notes_count( array( 'error', 'update' ), array( 'unactioned' ) );
return $settings;
}
}