Commit Graph

546 Commits

Author SHA1 Message Date
Joshua T Flowers cbc96b0253 Refactor notes and conditions for adding notes (https://github.com/woocommerce/woocommerce-admin/pull/4340)
* Add note traits to check for existence and generic conditions

* Add new note type for marketing notes

* Delete marketing notes when opted out

* Add tests for marketing notes
2020-05-22 16:48:40 +03:00
Jeff Stieler 3c8490c26b Add existing TaskList component to new home screen (https://github.com/woocommerce/woocommerce-admin/pull/4378)
* Move TaskList component up in directory tree.

* Render the TaskList on the new home screen.

* Render single tasks in isolation on new home screen.

* Fix "is requesting" selection for options API.

* Add loading placeholder for TaskList.

* Add initial test for the task list on the home screen.

* Fix dynamic imports under test.

* Add test for inline TaskList on home screen.

* Test that single task view works on new home screen.

* Restore Jest mocks between tests.

* Fix linting errors.
2020-05-21 11:15:08 -06:00
Ron Rennick 6720c17140 update unit test bootstrap for WC 4.2 (https://github.com/woocommerce/woocommerce-admin/pull/4312) 2020-05-13 09:56:05 -03:00
Joshua T Flowers 6fd251bfe4 Adds Jetpack stats to performance indicator endpoints (https://github.com/woocommerce/woocommerce-admin/pull/4291)
* Move allowed report analytics data to separate function

* Add function to retrieve allowed Jetpack module endpoints

* Fix API urls

* Add number format as default for jetpack modules

* Add module permissions and format to array

* Add filter for returned data from performance indicators API

* Filter jetpack stats by queried dates

* Fix empty date query filtering

* Mock the Jetpack API response

* Add tests for Jetpack stats in allowed endpoints

* Add tests for filtering Jetpack stats based on time

* Add tests for default args
2020-05-13 14:52:32 +03:00
Matt Sherman f639d4a32e Remove obsolete inbox messages (https://github.com/woocommerce/woocommerce-admin/pull/4182)
* Remove welcome note
* Remove store notice setting note
* Remove review your experience note
* Add tests for delete_notes_with_name
* Add filter support so that other code can add notes to be deleted on upgrade.
2020-05-05 15:38:16 -04:00
Paul Sealock 3fc69b9739 Homepage: Add stats overview selection (https://github.com/woocommerce/woocommerce-admin/pull/4264)
* Homwpage: add stats overview stat toggle

* toggle stats

* fix

* tests

* better hook name

* clean up

* add back in Fragment

* remove extra prop

* better test name
2020-05-05 10:58:39 +12:00
Joshua T Flowers ea2c2f7707 Fix sorting to push Storefront to the top of the theme list (https://github.com/woocommerce/woocommerce-admin/pull/4187)
* Fix sorting to push Storefront to the top of the theme list

* Add test to ensure Storefront is sorted in get_themes()

* copy paste cleanup

* Refactor sorting logic.

* Fix linting errors

* Updates per feedback.

* Add check for products property

* Fix for 5.6 CI.

* Oh hey another CI fix

Co-authored-by: Timmy Crawford <timmydcrawford@gmail.com>
2020-04-28 14:47:05 -07:00
Chris Shultz 65f7a0cf7d Remove A/B testing from order page shipping prompt. (https://github.com/woocommerce/woocommerce-admin/pull/4180) 2020-04-23 10:33:42 -07:00
Paul Sealock 28c85668fb Plugins: Move API out of Onboarding (https://github.com/woocommerce/woocommerce-admin/pull/4093)
* Plugins DataStore: decouple from onboarding (https://github.com/woocommerce/woocommerce-admin/pull/4048)

* Plugins DataStore: Add client side store

* change active_plugins to public static function

* don't change shape of allowed plugins
2020-04-20 14:04:13 +12:00
Paul Sealock c500d3fa98 Plugins DataStore: decouple from onboarding (https://github.com/woocommerce/woocommerce-admin/pull/4048)
* Plugins DataStore: Add client side store
2020-04-17 11:58:36 +12:00
Steve Grunwell 27704012a6 Enable the default homepage template to be filtered (https://github.com/woocommerce/woocommerce-admin/pull/4072)
This commit adds the "woocommerce_admin_onboarding_homepage_template" filter, enabling themes/plugins to filter the default homepage template created by the WooCommerce onboarding process.
2020-04-09 09:26:03 +12:00
Jason Conroy e5bd8f3184 Marketing Tab MVP (https://github.com/woocommerce/woocommerce-admin/pull/3953)
* Add Marketing feature flag

* Add marketing page and menu item

* Register marketing page with layout controller

* Add initial marketing cards

* Add max-width to marketing overview page

* Add initial marketing WelcomeCard component

* Make marketing welcome card permanently dismiss

* Add a readme for the marketing page components

* Record tracks event when marketing welcome dismissed

* Match design width

* Add welcome image and initial styles

* Use gridicon for close button

* Fix whitespace

* Add PluginsHelper::get_plugin_data()

* Add initial Marketing\InstalledExtensions class

* Preload installed marketing extensions data

* Tweak extension statuses

* Add InstalledExtensionRow component

* Add initial extension data to InstalledExtensions card

* Refactor PluginsHelper::get_plugin_data method

Using the new get_plugin_path_from_slug method

* Ensure get_plugins() function is available for PluginsHelper

* Simplify using PluginsHelper method

* Add MailChimp configured status logic

* Add links to InstalledExtensionRow component

* Add key prop to extensions list

* Setup styles for InstalledExtensions card

* Display nothing if no installed extensions

* Add InstalledExtensions::get_allowed_plugins()

* Setup Marketing Overview API controller

* Add /activate-plugin marketing endpoint

* Add more extensions URL props

* Add Facebook extension configured status logic

* Update Facebook extension URL props

* Fix extenion data logic

* Move component into it’s own directory

* Setup /marketing/overview/recommended endpoint

* Initial marketing page card header styles

* Add basic extension data to RecommendedExtensions

* Use color as variable

* Tweak card header padding for design

* Add basic styling to RecommendedExtensions card

* settingsUrl is not available if the plugin is not active

* Add /marketing/overview/installed-plugins REST endpoint

* Add basic activation functionality to InstalledExtensions component

* Don’t throw error on success

* Add MVP data store for installed extensions card

* Add core dark blue color variable

* Add styles for installed extensions card

* Move knowledge-base component to its own directory

* Pull recommended marketing plugins from remote test site

* Hide description when configured

As per design

* Tweak colors based on design

* Finish off styling for RecommendedExtensions

* Limit recommended extensions to 6 items

* Add error handling to RecommendedExtensions card

* Rename ‘copy’ extension prop

* Add marketing button component to match design

* Create ProductIcon component for marketing

* Add InstalledExtension icons

* Fix icon image paths

* Add ProductIcon to InstallExtensionRow

* Final styling to installed extensions card row

* Knowledge base card placeholders

* Fix missing icons when plugin not activated

* Remove logging

* Tweak array structure to ensure we have an array in JS

and not an object

* Refactor KnowledgeBase marketing component

- We don’t need loop through every post when rendering, just pick the posts we need
- Remove unused classes

* Move padding from each slide to the container

* Improve slider animations by absolute positioning the slides

* Reduce the slider animation timeout and add a note

* Add in-app purchase flow url params for recommended extensions

* Fix slider animation

* Reset slider height on window resize

* Short slider animation, fix double margin on smaller screens

* Add initial marketing/knowledge-base endpoint

* Pull knowledge base posts from API

* Rename welcome card dismiss tracks event

* Record event on recommended product click

* Recond onclick events for installed extensions card

* Record event when carousel navigation clicked

* img elements must have an alt prop

* Remove import that is never used

* use camelCase

* Decode HTML entities from API call

* Remove unused container div

* Add card loading state

* Add images to knowledge base card

* Link knowledge base posts

* Use the Pagination component rather than duplicate it’s functionality

* Clean up and rename knowledge base slider

* Clean knowledge base CSS and update responsive styles for single post slide

* Add a README for button component

* Add README for product icon component

* Add initial readme for Slider component

* Add correct image sizes to knowledge base slider, finalize styles

* Fix extension link urls

* Resolve some code formatting issue

* Bind class click methods to this

* Wrap nodes in Fragment

* Fix wccom-back path

* Add placeholder author and gravatar

Default avatar url size returned from the API is currently set to 96 so I’ve done a simple replace with 16

* Fix style-lint expected new line

* Add docblock for get_knowledge_base_posts()

* Setup data store for marketing to handle installedExtensions card

* Fix function names

“Activating” not “installing”

* Move welcome card component to its own dir

* IconButton component is going to be deprecated

ref: https://github.com/WordPress/gutenberg/pull/19299

* Support multiple activating plugins in the data store

* Rename extension to plugin for consistency

* Add propTypes to component

* Rename data-store/ to data/

* Fix import paths

* Extract isActivatingPlugin logic into datastore

* Move data store selectors into own file

* POST requests are not cached

* Export apiFetch action

* Don’t wrap API response in object

* Implement data store for recommended extensions

* Implement data store for marketing knowledge base

* Tidy getRecommendedPlugins resolver

* Try a cross browser cover/crop image effect to fit proposed design

And help fit longer titles in

* Add caught errors to handler

* Adjust positioning so watermater is displayed

* InstalledExtensions phpcs fixes

* Marketing phpcs fixes

* Alignment fix

* MarketingOverview phpcs fixes

* Missing full stop

* Update breadcrumbs to use new approach

* Fix style lint issues

* Record `marketing_knowledge_article` track event on knowledge base post click

* Import apiFetch and controls from @wordpress/data-controls

* Hex color to lowercase

* Remove duplicate method after rebase

* Use new showPageArrowsLabel rather than hide with CSS

* Fix blurry avatars on hidpi displays

* Hide avatar if URL is falsy

* Replace test author data with live data

* Combine conditionals into ternary

* Combine conditionals into ternary

* Simplify class column logic

* Only preload option and component settings in the admin

* Fix isActivatingPlugin not updating

Component was not re-rendeding.

* Use querySelector over getElementsByClassName

* Hide Marketing Welcome Card immediately on click

* Use create-a-ticket url for supportUrl and make that the default

* Add getInstalledPlugins resolver with preloaded data

* Revert "Add getInstalledPlugins resolver with preloaded data"

This reverts commit b8b127ec6411bef15616576b3bb189dc31777c13.

* Load plugin data in a separate request after activation

* Update welcome image

* Don’t return plugin data in the activation request.

* A space is required before closing bracket

* Update Jest config to gracefully handle static assets

Ref: https://jestjs.io/docs/en/webpack#handling-static-assets

* Remove unused onExit property

* Remove placeholder README

* Use prop directly

* yield createNotice

* Add note to indicate which Category

* Increase transient time to 3 days

* Use $gap-small

* Add proptype

* Add debounce to slider height resize listener

* Clean up isLoading logic

* Dont show image elements if image data is empty

* Open knowledge base posts in a new window

* Add “noreferrer”

* Turn the tab on in all env

Co-authored-by: Daniel Bitzer <danielbitzer@gmail.com>
2020-03-28 06:48:27 -07:00
Fernando Espinosa b71bc861fb WooCommerce Shipping order page prompt (https://github.com/woocommerce/woocommerce-admin/pull/3955)
Co-authored-by: David Stone <david@nnucomputerwhiz.com>
Co-authored-by: Chris Shultz <chris.shultz@automattic.com>
Co-authored-by: Harris Wong <harris.wong@a8c.com>
2020-03-27 13:42:58 -07:00
Jason Conroy d237256aa9 Abstract onboarding plugin code into a PluginsHelper class (https://github.com/woocommerce/woocommerce-admin/pull/3999)
* Abstract WP plugin code into a PluginsHelper class

We plan to use these methods in the Marketing tab.

* Add PluginsHelper::is_plugin_active()

* Add PluginsHelper::is_plugin_installed()

* Add PluginsHelper::get_plugin_data()

* Add PluginsHelper::get_plugin_path_from_slug()

* Refactor PluginsHelper::get_plugin_data method

Using the new get_plugin_path_from_slug method

* Refactor is_plugin_installed and is_plugin_active

Also adds support for plugin slugs or paths as parameters.

* Ensure get_plugins() function is available for PluginsHelper

* Ensure plugin path is a string before checking if installed/active

* PHPCS fixes

* Add initial unit tests for PluginsHelper

* Check plugin data array keys rather than all values

Will make it less fragile when Woo plugin data changes

* Fix typos

Co-authored-by: Daniel Bitzer <danielbitzer@gmail.com>
2020-03-27 11:28:59 +10:30
Paul Sealock 6582975f98 Made the data store reading of content_data more resilient (https://github.com/woocommerce/woocommerce-admin/pull/3926) (https://github.com/woocommerce/woocommerce-admin/pull/3961)
Before 0.10.0 notes had a default content_data of array(). If stored in the database, these notes would be unable to be loaded. This adds some resiliency to the loading so that invalid content_data fields don't break WC_Admin_Note::set_content_data().

Co-authored-by: Christopher Allford <christopher.allford@automattic.com>
2020-03-24 13:10:33 +13:00
Ron Rennick 43a941ad16 remove replace_actionscheduler_store_class function (https://github.com/woocommerce/woocommerce-admin/pull/3936)
* remove replace_actionscheduler_store_class function from master

* remove AS store class file

* reuse variable

* Fix test helper queue action cancellation for AS 2.x.x.

* Remove WPPostStore logic from SchedulerTraits.

* Remove dead queue code from WC_Admin_Notes.

Missed in https://github.com/woocommerce/woocommerce-admin/pull/3662.

Co-authored-by: Paul Sealock <psealock@gmail.com>
Co-authored-by: Jeff Stieler <jeff.m.stieler@gmail.com>
2020-03-19 10:34:09 -06:00
Joshua T Flowers da3d5359a6 Fix failing tests after WC 4.0 merge (https://github.com/woocommerce/woocommerce-admin/pull/3870)
* Manually call on_plugins_loaded after loading plugins for testing

* Update import tests to cancel all pending actions in new AS tables

* Fix deprecated next method in AS

* Remove priority queue test for unused priority in AS 3.0

* Check only for pending status actions in batch queue tests

* Add cancel_actions_by_group method to WPPostStore

* Add method to check for next blocking job time

* Force delete scheduled actions on older versions of AS
2020-03-12 14:46:13 +01:00
Fernando 5946e8c855 Onboarding - business step: add more options in the competitors list and other fixes (https://github.com/woocommerce/woocommerce-admin/pull/3812)
* Modified question in the business step of the onboarding

* Added more options in the competitors list

Onboarding - Business step -> Add more options in the competitors list.

* Added an option input field to Onboarding, business step

To the Onboarding's business step added an input field when the user selects "Other".

* Added suggested improvements

* Added new param to "test_schema" test

Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2020-03-06 16:20:54 -03:00
Joshua T Flowers cb3fcbcf08 Onboarding: Remove old development flags (https://github.com/woocommerce/woocommerce-admin/pull/3809)
* Remove old onboarding flags

* Remove flag from onboarding docs

* Enable onboarding in tests
2020-03-04 09:46:02 +01:00
Darren Ethier 33c5b41e3f Align WooCommerce javascript code standards/linting/styles with WordPress core. (https://github.com/woocommerce/woocommerce-admin/pull/3674)
* align code styles with the same configuration as Woo-Blocks

* initial pass of reformat-files

* applies manual fixes to various new linting errors surfaced by the configuration change.

* Fix state mutation in image-upload

* remove unused pre-commit-hook.js

* requestAnimationFrame -> window.requestAnimationFrame

* wc-api eslint changes

* eslint fixes on client/lib and client/settings

* client/header eslint changes

* fixes for client/dashboard part 1

* fixes client/dashboard part 2 of 2

* client/analytics part 1

* client/analytics continued

* client/analytics, last batch

* rename __mock__ directory

* pass in useEffect, useState from React component or function

* remove '+' from sprintf string argument

* use ref instead of findDOMNode

* reformat and repaply package.json changes

* install deps before running linter in Travis

* useGetCountryStateAutofill

* counryStateAutofill

* countryStateAutofill

Co-authored-by: Paul Sealock <psealock@gmail.com>
2020-02-14 15:23:21 +13:00
Ron Rennick d192e55dda fix SQL error in category sort (https://github.com/woocommerce/woocommerce-admin/pull/3521)
* fix SQL error in category sort

Co-authored-by: Jeff Stieler <jeff.m.stieler@gmail.com>
2020-01-15 16:26:28 -04:00
Joshua T Flowers af5022c3d1 Reports sync refactor (https://github.com/woocommerce/woocommerce-admin/pull/3285) 2020-01-03 00:00:37 +08:00
Joshua T Flowers 3da148156e Onboarding: Add theme install and activation endpoints (https://github.com/woocommerce/woocommerce-admin/pull/3482)
* Add API endpoint to install themes

* Add API endpoint to activate a theme

* Add an array of allowed themes and sanitize slugs

* Limit allowed themes to already installed or free themes

* Add theme installation tests

* Add tests for theme activation

* Add onboarding theme installation and activation tests

* Remove unused argument in onboarding plugins API
2019-12-30 15:47:15 +08:00
Jeff Stieler 162a8cd550 Allow report caching layer to be filtered off. (https://github.com/woocommerce/woocommerce-admin/pull/3434)
* Add filter to conditionally disable report caching.

* Disable caching for Orders Stats unit tests.

Fixes the display of the last query when tests fail.
2019-12-17 16:21:44 -05:00
Ron Rennick ba30224098 Stardardize hooks (https://github.com/woocommerce/woocommerce-admin/pull/3339)
* rename woocommerce_reports_* hooks/filters to woocommerce_analytics_*

* introduce woocommerce_navigation_ filter prefix

* update remaining wc_admin_* filters/hooks

* phpcs sniff fixes for notes data store

* standardize woocommerce_note_ hook prefix

* one of filter renames

* update contributing readme, onboarding unit test

* missed _notes_ -> _note_ filter

* update ext example hooks
2019-12-06 12:06:11 +13:00
Justin Shreve 448e1f3e11 Remove Newspack Dependency (https://github.com/woocommerce/woocommerce-admin/pull/3302)
* Switch to @wordpress/component's Button

* Finish button conversion

* Move to @wp/component's CheckboxControl

* Add  ImageUpload component

* Remove Newspack package

* CSS Cleanup

* Handle PR feedback: Fix tests, add ImageUploader basic test, fix FireFox/Safari Display issues, and  currency input bug
2019-12-02 12:39:22 -05:00
Justin Shreve 50cc3edaed Update onboarding filters with a consistent prefix (https://github.com/woocommerce/woocommerce-admin/pull/3295)
* Update onboarding filters with a consistent prefix

* Rename woocommerce_onboarding_payments to match the other task list options
2019-11-25 11:15:22 -05:00
David Levin 52cb35f4de Correcting and clarifying analytics terms and calculations (https://github.com/woocommerce/woocommerce-admin/pull/3104)
* Relabel Net Revenue to Net Sales, revert previous refund work on Gross revenue and rename to total sales. Update the orer of all the things

* Add gross sales calculation to revenue stats endpoint.

* Restore coupon_total when updating order stats.

* Wire up gross sales to revenue report.

* Fix revenue report refunds calculation when there are no refunds.

* update net sales labels and cases in order, product and category tables

* Subtract refunded shipping and taxes from gross sales.

* pluses to minuses to fix the gross revenue and refund totals when refunding

* Add gross_sales to revenue stats orderby enum.

* Change refund labels to Returns

* Remove usage of defunct coupon_total column.

* Store refunded amount in stats table.

* Rename "gross_total" column to "total_sales".

* Net total for refund orders can be used instead of a new column.

* Rename gross_revenue to total_sales.

* Coalesce coupons total in order stats query.

SUM()ing all nulls gives null, not zero.

* Use segmentation selections to backfill missing data.

Fo when report columns and segmentation columns don't match.

* Remove errant gross_sales from expected interval test data.

* Fix gross sales tests for revenue/stats.

* Move missing segment fills back to their original locations.

* Fix remaining tests failing because of gross sales.

* Fix db upgrade function rename of gross_total column.

* Fix linter errors.
2019-11-22 10:06:14 -05:00
Ron Rennick f78c143f3b Move in-house rest endpoints to private namespace (https://github.com/woocommerce/woocommerce-admin/pull/3204)
* move in-house rest endpoints to private namespace

* PHPCS sniff fixes
2019-11-12 14:15:55 -04:00
Justin Shreve 5b80e321ba Enable onboarding in the plugin build for those who have opted-in (https://github.com/woocommerce/woocommerce-admin/pull/3184)
* Enable onboarding in the plugin build for those who have opted-in

* Update constant andd option value
2019-11-07 13:31:02 -05:00
Ron Rennick afed4fba36 Data store refactor (https://github.com/woocommerce/woocommerce-admin/pull/2961)
* Base Report data store utility functions - 1

Standardizing the data store classes will be easier if the base class contains simple utility functions
that can replace logic implemented in multiple data stores.

- set_db_table_name() assigns a WP DB table name class variable for the data store
- get_db_table_name() retrieves the WP DB table name
- prepend_table_name() prepends a field in a query fragment with the data store table name

* add context, clause handling, and filters to reports data store

* add generated SQL clauses to class properties

* reduce id getter logic to single function with filter, add phpdocs to new filters

* update table_name to private string for use in constructor

* extract SQL query clause handling to its own class

- Will allow for use in subquery processing without creating a get_data stub
- Swap parameter order in add_sql_clause for readability
- Add support for clearing multple clauses in one call

* add context var to SqlQuery class

* implement SqlQuery in Categories data store

* implement subquery in categories data store

* coupons data stores, more underlying refactor

- fix warnings
- make filtered id functions static
- add limit parameter handling
- update coupons data store
- update coupon stats data store

* refactor coupon stats data store

* refactor customers and customer stats data stores

* add context to subqueries

* add missed prepend table name call

* refactor downloads data store, fix some warnings

* fix warnings, add separator parameter to filtered IDs

* refactor taxes and tax stats data stores

* refactor variations data store

* refactor product and product stats data stores

* make table_name static throughout for compat with static hook functions

* refactor order and order stats datastores

- use consistent visibility on initialize_queries()
- update db_table_name logic to use static keyword instead of self

* fix missed whitespace

* fix segmenting query, add SqlQuery join clause

* DRY data store constructors, class properties

* prefix table name when not yet assigned

* fix unit tests, interpolations, WPDB delete calls

* DRY get_object_where_filter()

* remove redundant table prefix from unit test init

* fix refactored SQL queries

* restore product paging

* remove unused query param arrays

* add first pass on data docs readme

* remove debug code, errant SQL spacing

* refactor out outer_from query element

* merge wheres, joins before filtering

* move all report column definitions to assign_report_columns

* fix data readme markdown

* small code formating fixes from review

* remove static from query/datastore context

* missed self:: in previous, add comments, small code moves

* rename get_statement() to get_query_statement()

* remove temporary query references

* static reference, remove reference parameter, fix coupon compare

* add todo reminders

* use correct query parameter in coupon data stores
2019-11-07 10:28:37 -07:00
Jeff Stieler 1ac8577fc2 Match server-side CSV export format to client-side (https://github.com/woocommerce/woocommerce-admin/pull/2987)
* Add "exportable" report interface for defining CSV export values.

* Define export values for Orders Report.

* Define export values for Products Report.

* Define export values for Categories Report.

* Define export values for Coupons Report.

* Allow commas and double quotes in CSV exported values.

* Fix in-browser export formatting of orders report products.

* Align server-side orders report export formatting with in-browser.

* Cover comma and double quote escaping in CSV export package tests.

* Define export values for Customers Report.

* Embed response links when requesting data for CSV exports.

* Define export values for Downloads Report.

* Move reusable report export functions to a trait.

* Define export values for Stock Report.

* Define export values for Taxes Report.

* Define export values for Variations Report.

* Define export values for Revenue Report.

* Always pass export row data through the filter.

* Fix formatting in test case for CSV coupon export.

* Quote escape CSV headers in client-side export.

Escape values with spaces as well.

* Check if inventory is managed at the product level before using the stock status/quantity.

* Prevent CSV injection in csv-export package.
2019-10-24 09:41:16 -07:00
Justin Shreve e31e115e93 Update proceed without Jetpack/WCS to go to store details step (https://github.com/woocommerce/woocommerce-admin/pull/3040)
* Update proceed without Jetpack/WCS to go to store details step

* Adjust how we track the start/plugins step
2019-10-17 10:57:29 -04:00
Justin Shreve 5ee318064a Remove the Onboarding Levels API (https://github.com/woocommerce/woocommerce-admin/pull/3041) 2019-10-15 10:46:12 -04:00
Justin Shreve d8132942f3 Change usage tracking prompt to modal (https://github.com/woocommerce/woocommerce-admin/pull/2968)
* Move tracking usage question to modal

* Fix PHPCS errors

* Adjust button alignment, update PHPCS version.

* Fix options check

* Handle PR feedback
2019-10-10 10:05:13 -04:00
Joshua T Flowers 37fbdaf5c0 Add options REST API permission checks (https://github.com/woocommerce/woocommerce-admin/pull/3004) 2019-10-09 06:39:40 +08:00
Mike Jolley edcfc161fa Category Lookup Table - Fix Category Segments (https://github.com/woocommerce/woocommerce-admin/pull/2253)
* Look table class and installer

* New table + stats

* Working reports/initial population

* Remove test

* Refactor, remove depth

* Unused table

* Update todo

* Add docblocks and reorder get_insert_sql params for consistency

* Adjust css braces

* clear hook on deactivation

* PSR-4 category lookup

* linting CSS closing brace last char on line

* initialize category lookup table in unit tests

* missed linting fixes

* revert move of run_all_pending call

* use consistent reference for term_relationships in queries
2019-10-02 12:35:37 +13:00
Joshua T Flowers c70c7bfd68 Fix vendor scripts not autoloading (https://github.com/woocommerce/woocommerce-admin/pull/2907)
* Fix vendor scripts and test bootstrapping

* Escape the downloaded file URL in tests

* Generate feature config file for tests

* Run feature config generation before and after script tests
2019-09-25 14:20:15 -04:00
Darren Ethier d728d38219 Refactor: Alternative approach to implementing extendable settings from the server (https://github.com/woocommerce/woocommerce-admin/pull/2917)
* integrate with new asset data registration (php side)

- includes back-compatibility.

* update js configuration and implement settings alias

- this aliases `@woocommerce/wc-admin-settings` to the settings api exposed via blocks (either the blocks plugin or core) and all the settings provided via the server.
- Adds fallback for back-compat if `wc.wcSettings` is not available in the environment (fallsback to `wcSettings`).

* initial pass to update all wcSettings direct usage to the new api

- this is just an initial pass, more can be done in separate pulls.

* missed one spot for adding new filter implementation

* fix incorrect jest config

* Avoid unnecessary assignment and directly return.

* Remove unnecessary defaults

* Fix inline comment text case.

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* Remove unnecessary inline comment.

* use @todo instead of TODO

Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>

* fix incorrect reference in webpack config.

* add missing import and slightly delay dependency injection for scripts

* update get-setting and set-setting callbacks

* disable lint rule for console.error on dev doc builds
2019-09-23 17:47:08 -04:00
Albert Juhé Lluveras 3406bd85e0 Fix variable name typo (https://github.com/woocommerce/woocommerce-admin/pull/2922) 2019-09-13 18:39:51 +02:00
Joshua T Flowers f095466442 Onboarding: Add create homepage logic to "Customize Appearance" step (https://github.com/woocommerce/woocommerce-admin/pull/2889) 2019-09-06 22:18:44 +08:00
Joshua T Flowers 52c295b820 Onboarding: Add "Import products" step (https://github.com/woocommerce/woocommerce-admin/pull/2868) 2019-09-06 10:06:29 +08:00
Jeff Stieler 2546a3faec Merge pull request woocommerce/woocommerce-admin#2832 from woocommerce/fix/2702-queue-customer-updates
Queue customer lookup updates.
2019-09-04 08:49:40 -07:00
Jeff Stieler b6c34109f0 Look for `title` properties when using JSON schema for indicator labels.
Fix the dashboard labels at the same time.
2019-09-04 07:49:37 -07:00
Jeff Stieler 3cb05f13d3 Test help queue runner - run until no more jobs remain. 2019-08-21 16:39:09 -07:00
Jeff Stieler 8f27a374f1 Fix tests. 2019-08-21 09:34:17 -07:00
Jeff Stieler bfefb2d647 Ignore refunded amounts when calculating gross total. 2019-08-20 11:41:28 -07:00
Jeff Stieler 953427bea5 Remove defunct filename prefix from remaining files.
Excluding the note classes for third party compatibility.
2019-08-12 15:06:36 -07:00
Jeff Stieler 13878db9ac PSR-4ify the feature plugin and install classes. 2019-08-12 15:03:21 -07:00
Jeff Stieler 7dd4d2b791 PSR-4ify the reports time interval class. 2019-08-12 15:03:21 -07:00
Jeff Stieler 88f6fd9d06 PSR-4ify report query classes. 2019-08-12 15:03:19 -07:00
Jeff Stieler b7912bc579 PSR4-ify the Reports data store classes. 2019-08-12 15:03:17 -07:00
Jeff Stieler b71d8c23c8 PSR4-ify core API subclasses. 2019-08-12 15:03:15 -07:00
Jeff Stieler 416ab09653 PSR-4ify the action schedule post store subclass. 2019-08-12 15:03:12 -07:00
Jeff Stieler e509e51552 PSR-4ify the sync class. 2019-08-12 15:03:11 -07:00
Jeff Stieler ce7267b198 PSR-4ify the report exporter classes. 2019-08-12 15:03:10 -07:00
Jeff Stieler ca68769205 Update admin notes classes to PSR-4. 2019-08-12 15:03:09 -07:00
Jeff Stieler 9c469a9f60 Fix tests. 2019-08-12 15:03:06 -07:00
Justin Shreve 708464fe8e Add revenue question to the business details page (https://github.com/woocommerce/woocommerce-admin/pull/2763)
* Add revenue question to the business details page

* Handle PR feedback: remove empty values, include currency in the stats api call.
2019-08-08 11:38:47 -04:00
Justin Shreve dca1b07377 Onboarding - Task List: Add store connection task (https://github.com/woocommerce/woocommerce-admin/pull/2718)
* Adds store connection task

* PR Feedback
2019-08-01 14:09:08 -04:00
Justin Shreve 1410e7ed29 Add a "this store is being setup for a client" store detail field (https://github.com/woocommerce/woocommerce-admin/pull/2727) 2019-08-01 13:29:35 -04:00
Ron Rennick 135ac032be update assertisWPError calls to assertWPError in unit tests 2019-07-19 16:45:52 -03:00
Ron Rennick 2260e60453 Merge pull request woocommerce/woocommerce-admin#2484 from woocommerce/fix/2400
use summary query to total coupons per order
2019-07-08 13:49:17 -03:00
Timmy Crawford dde788631c Notes: Type cast is_snoozeable on insert. (https://github.com/woocommerce/woocommerce-admin/pull/2573) 2019-07-08 09:48:38 -07:00
Ron Rennick 3cc9232c2b add unit test for multiple coupons on orders 2019-07-05 14:44:08 -03:00
Joshua T Flowers d640b15d09 Add a theme REST API to allow uploading themes (https://github.com/woocommerce/woocommerce-admin/pull/2568)
* Add theme upload REST api controller

* Add theme data to theme controller response

* Add tests for themes api

* Change user cap check to upload_themes

* Add test for users without theme capabilities
2019-07-05 16:01:35 +08:00
Justin Shreve 5a2f0c9da0 Onboarding - Add business extension recommendations (https://github.com/woocommerce/woocommerce-admin/pull/2551)
* Add business extension recommendations

* Fix failing test. Set max height and width for toggle

* Fix toggle display and fix when the extensions show (so they dont hide and disapear as "currently" selling is selected).
2019-07-04 11:56:28 -04:00
Jeff Stieler 5b905025fc Merge pull request woocommerce/woocommerce-admin#2526 from woocommerce/add/311-report-csv-exporter-endpoint
Add Report CSV Export Endpoint
2019-07-03 08:43:18 -06:00
Jeff Stieler c7d94cc929 Use the default "read reports" permission for the export endpoint. 2019-07-02 13:53:42 -06:00
Paul Sealock 8857635162 fix tests 2019-07-02 12:35:58 +12:00
Paul Sealock 563e94b7a2 add leading slash in path for Leaderboards 2019-07-02 12:19:55 +12:00
Justin Shreve aed4ea63b4 Server side route handling 2019-07-01 12:22:34 +12:00
Jeff Stieler 35d763fa8c Merge pull request woocommerce/woocommerce-admin#2463 from KZeni/patch-2
Add State alongside City (and other customer info).
2019-06-28 12:24:25 -06:00
Jeff Stieler fbd231acf4 Add test for reports export endpoint. 2019-06-28 11:10:13 -06:00
Jeff Stieler 8c40000ec2 Merge pull request woocommerce/woocommerce-admin#2496 from woocommerce/fix/rest-controller-default-params
Test that REST controllers work with their default parameters.
2019-06-28 08:52:16 -06:00
Ron Rennick 6982c21d3d Merge pull request woocommerce/woocommerce-admin#2519 from woocommerce/fix/2495
remove double slash from image urls, use string for download ID
2019-06-28 09:28:51 -03:00
Ron Rennick 9f76b02283 set all the unit test download IDs to strings 2019-06-27 17:46:56 -03:00
Jeff Stieler 7e87732dfb Rework test to rely on the REST server handling route defaults. 2019-06-27 11:38:54 -06:00
Jeff Stieler b8abe63d15 Don’t create a batch job that exceeds the range end. 2019-06-26 14:23:56 -06:00
Jeff Stieler 5b4d671833 Change test queue batch size.
Introduces error condition where range start is beyond the end.
2019-06-26 14:16:33 -06:00
Ron Rennick 57a8fbcb51 remove double slash from image urls, use string for download ID 2019-06-26 16:55:57 -03:00
Jeff Stieler 356f1ada77 Merge pull request woocommerce/woocommerce-admin#2502 from woocommerce/add/311-reports-csv-exporter-class
Add Reports CSV Exporter Class
2019-06-26 09:50:06 -06:00
Jeff Stieler 466ddda1a6 Add a test of the CSV export to the coupons report. 2019-06-24 19:26:33 -06:00
Jeff Stieler d6d3161bff Exclude IP download controller from defaults test. 2019-06-24 12:16:58 -06:00
Jeff Stieler 4711a4e11d Ensure coupons are enabled for testing. 2019-06-24 10:55:43 -06:00
Jeff Stieler 7e14630b3b Set default params on each test request, and use an admin user. 2019-06-24 10:55:40 -06:00
Jeff Stieler ff8615dac7 Test that all REST controllers can be called with default params. 2019-06-24 10:50:21 -06:00
Kurt Zenisek ce8d670420 Increased assertCount to accommodate the added data point 2019-06-20 14:24:14 -05:00
Jeff Stieler f75e3c7820 Check for good WC_Orders before using instance methods. 2019-06-20 08:31:10 -06:00
Joshua T Flowers 57416a2bdb Refactor customer name retrieval (https://github.com/woocommerce/woocommerce-admin/pull/2418)
* Return early from creating customer if order is false

* Refactor customer first and last name methods

* Separate customer name tests to create guest orders

* Check for parent_id before retrieving customer ID in refund

* Use registered customer ID in import report tests

* Compare absolute integer when checking for valid customer ID

* Check for order before getting customer ID when retrieving existing customer ID
2019-06-20 11:22:47 +08:00
Kurt Zenisek a39c885160 Added state alongside city & other info 2019-06-19 17:11:24 -05:00
Jeff Stieler d4e242b028 Add test to catch missing version updates. 2019-06-13 15:40:02 -06:00
Ron Rennick 241ebb63ff Merge pull request woocommerce/woocommerce-admin#2407 from woocommerce/fix/2354
Update Amount of {Item} to Number of {Item} when it's a count throughout
2019-06-13 13:41:15 -03:00
Joshua T Flowers 2f49a0a5a7 Prevent multiple imports from running simultaneously (https://github.com/woocommerce/woocommerce-admin/pull/2414)
* Prevent multiple imports from running simultaneously

* Cancel previous imports before importing again in tests
2019-06-13 23:32:58 +08:00
Ron Rennick 6b02ee217c Update Amount of Orders to Number of Orders throughout 2019-06-12 16:16:18 -03:00
Albert Juhé Lluveras 8bc2261c8a Add date_created_gmt property to orders endpoint (https://github.com/woocommerce/woocommerce-admin/pull/2086)
* Add date_created_gmt property to orders enpoint

* Make date_created properties of type date-time and improve descriptions
2019-06-12 11:21:56 +02:00
Paul Sealock dbd536c7a3 Settings: Add default date 2019-06-12 11:40:21 +12:00
Albert Juhé Lluveras 5d01cee56c Add progress bars to Historical Data Import screen (https://github.com/woocommerce/woocommerce-admin/pull/2312)
* Hook up import/status endpoint to Historical Data Import screen

* Fix PHP tests

* Add speak message when the import is complete

* Several fixes

* Cleanup

* Update progress bars every 3 seconds and bugfixes

* Rename ongoingImport to activeImport

* Use timestamp to identify queries

* Use timestamps for historical data state

* Add 'initializing' status

* Cleanup

* Pass less props around

* Refactor getStatus

* Set stop timestamp on request error

* Typo
2019-06-11 14:47:53 +02:00
Justin Shreve 821408fc83 Add Muriel/Newspack components for use in onboarding (https://github.com/woocommerce/woocommerce-admin/pull/2313)
* Add Muriel/Newspack components for use in onboarding

* Adjust some alignment
2019-05-28 10:05:55 -04:00
Joshua T Flowers 5e8509edd3 Onboarding: Add profiler body class on initial load + respect skipped/completed flags (https://github.com/woocommerce/woocommerce-admin/pull/2300) (https://github.com/woocommerce/woocommerce-admin/pull/2318)
* Add profiler body class on initial load, and respect skipped/complete status.

* Handle PR feedback: Remove unnecessary global, add some todos, added a filter around the next step slug, generalized the is-loading class a bit.
2019-05-28 06:38:01 -04:00
Joshua T Flowers cda83b4509 Onboarding - Add shared step actions and step 1 actions (https://github.com/woocommerce/woocommerce-admin/pull/2283)
* Add method to go to next profiler step in step controller

* Add method to update profile params in step controller

* Add action methods to step 1 in the profiler

* Allow JSON body params for profile controller

* Use JSON body params in onboarding profile tests
2019-05-28 11:09:48 +08:00
Paul Sealock f9bad3646d Persisted Queries: Avoid non-time related screens 2019-05-24 08:38:52 +12:00
Jeff Stieler 0d863ae7a6 Exclude auto-draft and trashed orders from imports. 2019-05-20 13:51:44 -06:00
Mike Jolley 79373b062c Merge branch 'master' into update/refactor-main-file 2019-05-16 14:20:13 +01:00
Joshua T Flowers 8a03b1bfb3 Add onboarding profile REST endpoints (https://github.com/woocommerce/woocommerce-admin/pull/2217)
* Add onboarding profile endpoint to get profile data

* Add onboarding profile update endpoint

* Add onboarding profile endpoint tests

* Update onboarding API namespaces
2019-05-16 13:05:37 +08:00
Mike Jolley 254e378346 Moved actionsheduler hook to main file 2019-05-14 19:19:24 +01:00
Ron Rennick 6780ae0136 update unit tests for new customer count 2019-05-13 14:14:53 -03:00
Joshua T Flowers fb91cd8788 Add import status endpoint and progress options (https://github.com/woocommerce/woocommerce-admin/pull/2189)
* Update import progress during batches

* Add import status route for querying import progress

* Update import totals before import start

* Move wc admin notes to separate action scheduler group

* Add import totals route to query customer and order totals

* Add wc helper queue job processing method

* Add import status and total tests

* Separate action type clearing for imports and notes

* Typecast action types as array in clear_pending_wcadmin_actions()
2019-05-13 10:30:07 +08:00
Joshua T Flowers c6a6e737c4 Add refund filtering to order reports (https://github.com/woocommerce/woocommerce-admin/pull/2179)
* Add customer functions to order and refund classes

* Extract shared order and refund methods to trait

* Add refund filter to advanced filters in orders report

* Filter refund types in orders data store

* Extract refunds subquery to parent report data store method

* Add refund subquery filtering to order stats data store

* Add tests around refund type filtering

* Change the default option for the refunds filter
2019-05-10 14:56:57 +08:00
Joshua T Flowers 3382fb7011 Record refunds separate from order entries (https://github.com/woocommerce/woocommerce-admin/pull/2083)
* Sync refunds on order sync

* Separate order and refund class extensions

* Add customer functions to order and refund classes

* Change products store to work with refund amounts

* Return early for refunds in coupon data store

* Allow refund processing in tax data store

* Remove unused refund amounts from tables and data stores

* Change order counts to parse out refund entries

* Include refunded orders in default queried statuses

* Only process order number filter on shop order post types

* Extract shared order and refund methods to trait

* Fix renamed schedule_single_order_import method

* Bump PHP and WP version requirements
2019-05-10 14:39:25 +08:00
Jeff Stieler a36e3cd024 Merge pull request woocommerce/woocommerce-admin#2034 from woocommerce/add/1850-import-endpoint
Add import endpoint and controller
2019-05-01 13:29:00 -06:00
Joshua Flowers 63c59a1f72 Update batch test function names and constants 2019-04-30 17:39:02 -06:00
Joshua Flowers 591c66995d Add tests for delete endpoint 2019-04-30 17:39:01 -06:00
Jeff Stieler f9c1b130c3 Add extra verification to import cancel endpoint test. 2019-04-30 10:38:07 -06:00
Joshua Flowers 61492c5f10 Add import cancel tests 2019-04-30 10:17:09 -06:00
Jeff Stieler a3fdd72ba5 Merge pull request woocommerce/woocommerce-admin#1907 from woocommerce/fix/1615-order-number-filter
Support Sequential Order Numbers in Downloads Report order number filter
2019-04-30 10:10:39 -06:00
Jeff Stieler 4a85b012b5 Add tests for customer import using new parameters. 2019-04-30 09:46:14 -06:00
Jeff Stieler 3bfc53c9cf Reintroduce the customer lookup init to report regeneration.
With the new date range and “skip existing” logic.
2019-04-30 09:17:12 -06:00
Joshua T Flowers 53a4098de1 Fix missing leaderboard schema options (https://github.com/woocommerce/woocommerce-admin/pull/2059)
* Add missing schema properties

* Add missing leaderboard schema tests
2019-04-26 10:43:52 -07:00
Kelly Dwan 18bb29e35d Fix warnings in travis: CSS lint error & phpunit warning (https://github.com/woocommerce/woocommerce-admin/pull/2109)
* Fix stylelint issue

* Use WC_Helper_Order to create the order, which will correctly populate customer info
2019-04-25 10:22:57 -04:00
Joshua T Flowers c17baa02cd Encode and decode persited query as JSON string in the leaderboards controller (https://github.com/woocommerce/woocommerce-admin/pull/2100)
* Encode and decode persited query as JSON string in leaderboards controller

* Update peristed query tests to use JSON string
2019-04-24 04:38:49 +08:00
Joshua Flowers 7a41da3058 Bust cache for orders query in import tests 2019-04-12 16:50:43 +08:00
Joshua Flowers 5838e2ab48 Add import controller tests 2019-04-12 16:50:42 +08:00
Joshua T Flowers e31be343e2 Make customer name extendable (https://github.com/woocommerce/woocommerce-admin/pull/1976)
* Make customer name extendable

* Update get_customer_name to favor user profile information

* Update customer name on profile update

* Add tests around customer name getting and setting

* Prefix customer name filter with woocommerce_reports_
2019-04-09 11:39:39 +08:00
Joshua T Flowers f682fe76be Add leaderboard controller and endpoint (https://github.com/woocommerce/woocommerce-admin/pull/1995)
* Add leaderboard controller and endpoint

* Add existing leaderboard stats to leaderboard endpoint

* Add persisted query to leaderboard params

* Add leaderboard endpoint tests

* Check if extended_info params are set before assigning

* Change number param input format to mixed inside wc_admin_number_format
2019-04-09 11:34:56 +08:00
Joshua T Flowers 753780bf7b Onboarding: Add levels REST API (https://github.com/woocommerce/woocommerce-admin/pull/1938)
* Add levels rest controller

* Add default levels

* Add onboarding level API tests

* Drop all since tags

* Make pre-response levels array associative for easier formatting

* Fix level tests for associative array
2019-04-05 10:35:30 +08:00
Ron Rennick b384571afe Merge pull request woocommerce/woocommerce-admin#1984 from woocommerce/phpcs/tests
phpcs fixes class-wc-tests-reports-orders-stats.php
2019-04-03 10:21:38 -03:00
Joshua T Flowers 0c5c1c3db4 Remove coupon_total from order stats table (https://github.com/woocommerce/woocommerce-admin/pull/1975)
* Remove coupons_total from order stats table

* Replace discount amount with coupon objects in stat tests
2019-04-03 09:37:17 +08:00
Ron Rennick 26b5ba2b89 phpcs fixes class-wc-tests-reports-orders-stats.php 2019-04-02 16:22:55 -03:00
Joshua T Flowers 9c3faea12f Refactor notes controller and add ordering params (https://github.com/woocommerce/woocommerce-admin/pull/1878)
* Separate notes controller request args and add collection params

* Fix page param var

* Fix collection params sanitization

* Allow array of note types to be queried

* Add order and orderby collection params to notes controller

* Allow sorting by order and orderby params in notes data store

* Make sure notes are ordered by date and unread matches inbox note types

* Allow status or type params to use an array of items

* Add tests for notes ordering

* Remove unnecessary query arg assignment in the notes data store

* Update get_notes_count to use array for status and type
2019-04-01 10:53:34 +08:00
Joshua T Flowers 42ddfc0108 Add coupons count to data store and hook up to summary numbers in orders report (https://github.com/woocommerce/woocommerce-admin/pull/1912)
* Change coupons sum to distinct coupon count in REST API

* Hook up unique coupon count to orders summary numbers

* Add coupons count to order segmenting

* Add coupons count to expected stats in order test and revenue tests
2019-04-01 10:16:57 +08:00
Jeff Stieler 164a55b0d2 Allow strings in downloads report order number filter. 2019-03-26 16:04:36 -06:00
Jeff Stieler 7742a7d65e Add test coverage for “unsnoozing” notes. 2019-03-20 08:52:27 -06:00
Jeff Stieler 2a08ba20e8 Add a snoozed note to test data. 2019-03-20 08:52:27 -06:00
Albert Juhé Lluveras e6cf40e3f0 Allow sorting by tax_code in Taxes report (https://github.com/woocommerce/woocommerce-admin/pull/1812) 2019-03-15 21:44:03 +01:00
Jeff Stieler bfe5a75e98 Update text domain. (https://github.com/woocommerce/woocommerce-admin/pull/1795)
* Translation call text domain change from “wc-admin” to “woocommerce-admin”.

* Fix .pot file generation.

* Fix errantly closed array item in /revenue/stats controller.

* Rename plugin zip, main file, and repo name to "woocommerce-admin".
2019-03-13 11:14:02 -06:00
Justin Shreve 1348245406 Add store notice around processing historical data. (https://github.com/woocommerce/woocommerce-admin/pull/1763)
* Add store notice around processing historical data.

* Cleanup

* Handle PR feedback.

* Clean up `add` logic and add empty content_data. Also add logic to get_notes_count so that we can hide unactioned statuses.

* Add the ability to update a note, and to also mark a status when an alert is clicked.

* Remove mark_actioned call on sync

* add missing todo
2019-03-12 09:13:20 -04:00
Albert Juhé Lluveras 6c9b96f49a Make variations and coupons endpoints return zero-value items (https://github.com/woocommerce/woocommerce-admin/pull/1765)
* Make categories endpoint return zero-value items

* Rename PHP variable to make it more specific

* Remove uneeded lines

* Make variations and coupons endpoints return zero-value items

* Remove second parameter from get_ids_table
2019-03-12 11:11:28 +01:00
Albert Juhé Lluveras d3230d8dae Make categories endpoint return zero-value items (https://github.com/woocommerce/woocommerce-admin/pull/1755)
* Make categories endpoint return zero-value items

* Rename PHP variable to make it more specific

* Remove uneeded lines

* Remove second parameter from get_ids_table
2019-03-12 10:50:53 +01:00
Albert Juhé Lluveras cf162dda7f Taxes report: sort tax rates numerically instead of alphabetically (https://github.com/woocommerce/woocommerce-admin/pull/1766)
* Taxes report: sort tax rates numerically instead of alphabetically

* Use DECIMAL(7,4) for tax_rate sorting
2019-03-12 10:31:19 +01:00
Jeff Stieler a50a9bccb1 Ensure that other scheduled actions are claimed before WC Admin actions. (https://github.com/woocommerce/woocommerce-admin/pull/1759)
* Use menu_order to lower the claim priority of WC Admin scheduled actions.

* Use a ActionScheduler_Store subclass to modify menu_order.

* Check to make sure we’re overriding only AS’s built in WP Post data store.
2019-03-08 11:59:32 -07:00
Albert Juhé Lluveras d2c0dd5555 Make products and rates endpoints return zero-value items (https://github.com/woocommerce/woocommerce-admin/pull/1722)
* Make products endpoint return zero-value items

* Make rates endpoint return zero-value items

* Several fixes

* Add tests

* Simplify code

* Merge both queries into one to simplify code

* Rename 'get_outer_from_sql_params' to 'get_from_sql_params'
2019-03-06 12:36:43 +01:00
Peter Fabian 99e88706ad Merge pull request woocommerce/woocommerce-admin#1681 from woocommerce/fix/1476-2
Updated is_returning_customer definition to use refactored function.
2019-03-05 13:00:07 +01:00
Justin Shreve fce16ade7a Display order number on reports (https://github.com/woocommerce/woocommerce-admin/pull/1706)
* Display order number on reports, and add to API response.

* Add method for getting order number, avoiding loading the data store if no filter is attached.
2019-02-28 09:14:21 -05:00
Ron Rennick 6969f841fa update unit tests for batch group 2019-02-25 09:34:59 -04:00
Peter Fabian 43e49ca704 Added test for registered customer. 2019-02-23 00:03:53 +01:00
Peter Fabian 4668734af7 Removed debugging var from test. 2019-02-23 00:02:40 +01:00
Peter Fabian 3ce686e6cd Updated is_returning_customer definition to use refactored function. 2019-02-22 22:06:21 +01:00
Joshua T Flowers aef11ef586 Refactor customer ID creation (https://github.com/woocommerce/woocommerce-admin/pull/1619)
* Fix indendtation for table creations

* Refactor how customers are created on order update

* Check if user has a role of customer or previous orders before storing

* Add tests for user creation

* Allow null emails for customers

* Only select customer_id in guest ID query
2019-02-20 10:30:00 +08:00
Joshua T Flowers 44604bcd02 Reduce net order total by refunded amount less tax and shipping refunds (https://github.com/woocommerce/woocommerce-admin/pull/1600)
* Reduce net order total by refunded amount less tax and shipping refunds

* Fix net_totals in tests with refunds
2019-02-20 09:39:42 +08:00
Justin Shreve 4f64358c8e Fix customer filters and download user filtering (https://github.com/woocommerce/woocommerce-admin/pull/1618)
* Add the ability to search name, username, and email fields on the customer endpoint, update autocompletors, add in include parameter.

* Update the username to be returned in the download response, update download filtering based on customer id, and only rename include parameter on main customers endpoint.
2019-02-19 14:35:29 -05:00
Joshua T Flowers f0ec3c49a1 Add tax refund calculations (https://github.com/woocommerce/woocommerce-admin/pull/1556)
* Add item and shipping refund calucations to taxes on order update

* Sync taxes on refund delete

* Fix up tax stats API testing

* Add refunds to tax stats API tests
2019-02-18 10:20:16 +08:00
Ron Rennick e2b220bb54 Merge pull request woocommerce/woocommerce-admin#1570 from woocommerce/phpcs/tests
Phpcs sniff fixes for unit tests
2019-02-15 14:50:50 -04:00
Peter Fabian f7d0d2379f Merge branch 'master' into fix/489-date_date_gmt
# Conflicts:
#	includes/class-wc-admin-api-init.php
2019-02-15 17:07:38 +01:00
Joshua T Flowers cba9ab61b2 Update returning customer values to respect excluded statuses (https://github.com/woocommerce/woocommerce-admin/pull/1557)
* Excluded statuses from customers oldest orders

* Fix tests for returning customer where excluded statuses are used

* Remove save_post hook used for testing

* Extract conditions for first order swapping
2019-02-15 10:09:16 +08:00
Ron Rennick 767b047f4b phpcs for admin-notess.php 2019-02-14 19:20:47 -04:00
Ron Rennick 45acf57c22 phpcs for product-reviews.php 2019-02-14 19:19:22 -04:00
Ron Rennick 7a255d7490 phpcs for products.php 2019-02-14 19:18:34 -04:00
Ron Rennick b69f8fdbf2 phpcs for reports-customers-stats.php 2019-02-14 19:17:05 -04:00
Ron Rennick e91f7f6d00 phpcs for reports-customers.php 2019-02-14 19:14:43 -04:00
Ron Rennick cd1fdef99d phpcs for reports-download-stats.php 2019-02-14 19:13:18 -04:00
Ron Rennick a89083077e phpcs for reports-interval.php 2019-02-14 19:12:15 -04:00
Ron Rennick db568ec9af phpcs for report-order-stats.php 2019-02-14 19:11:17 -04:00
Ron Rennick ece6fb1a91 phpcs for report-performance-indicators.php 2019-02-14 19:08:25 -04:00
Ron Rennick 8ce7af9f61 phpcs for report-stock-stats.php 2019-02-14 19:06:11 -04:00
Ron Rennick 7910e76d8c phpcs for bootstrap.php 2019-02-14 19:04:30 -04:00
Ron Rennick 58cfde18a4 phpcs print_R use in class-wc-tests-reports-order-stats.php 2019-02-14 18:54:45 -04:00
Ron Rennick 12c42c7967 phpcs for class-wc-tests-reports-orders-stats.php except print_r 2019-02-14 17:14:52 -04:00
Ron Rennick 16c5cf8c77 phpcs for class-wc-tests-reports-revenue-stats.php 2019-02-14 16:34:38 -04:00
Justin Shreve 24301e0090 Add stock stats endpoint and hook up to the stock report. (https://github.com/woocommerce/woocommerce-admin/pull/1535)
* Add stock stats endpoint and hook up to the stock report.

* Handle PR feedback
2019-02-13 22:31:27 -05:00
Joshua T Flowers 746d062f09 Check and update customer first orders to fix returning_customers (https://github.com/woocommerce/woocommerce-admin/pull/1517)
* Add get_oldest_orders function to customer data store

* Check if is first order in is_returning_customer()

* Check if the customers first order has changed and update all orders respectively

* Fix check for empty oldest_orders array

* Change avg_items_per_order to number instead of integer

* Fix failing tests for new/returning customers

Only the first orders with product 1 and without coupons should be new per each customer

* Remove sleep functions from tests

* Assign second order to a variable for legibility

* Fix second order assignment and check if set
2019-02-14 11:14:01 +08:00
Jeff Stieler c862de29d3 Merge pull request woocommerce/woocommerce-admin#1534 from woocommerce/fix/1455-customers-report-name-search
Hook up customers report table search box
2019-02-13 13:55:47 -08:00
Jeff Stieler 73c430b9b8 Merge pull request woocommerce/woocommerce-admin#1510 from woocommerce/fix/532-wc-install-approach
Use a WC_Install-like approach to initialize WC Admin data
2019-02-12 13:05:48 -08:00
Justin Shreve 60d364d329 Update 5.0.0 version check and add basic readme.txt (https://github.com/woocommerce/woocommerce-admin/pull/1521)
* Update version check, add basic WP.org readme

* Clean up test depedency since we are supporting 5.0.0 or greater

* add some additional keywords

* update greater than message
2019-02-12 15:22:16 -05:00
Justin Shreve 0fe061b97d Add Feature Flags (https://github.com/woocommerce/woocommerce-admin/pull/1500)
* First pass at adding feature flags. Accessible over PHP and JS.

* Hook up dev config to test enviornments, hook up features to their flags.

* Cleanup some code and add documentation. Remove beta config.

* Handle PR Feedback: Add devdocs flag, remove categories flag, fix auto-generated PHP warning.

* Add todo for beta phase.

* Handle PR feedback: Simplify is_array check, update build command, simplify test mock, remove empty webpack line.
2019-02-12 15:02:02 -05:00
Jeff Stieler e36d25e112 Make customer object IDs compatible with `wc-api`/`fresh-data`. 2019-02-12 11:08:03 -08:00
Jeff Stieler 926fdcfb97 Hook `v4/customers` endpoint up to customers report/lookup table and change name search to be fuzzy. 2019-02-12 11:06:22 -08:00
Peter Fabian a6761fc606 Merge branch 'master' into fix/489-date_date_gmt 2019-02-10 17:24:54 +01:00
Jeff Stieler 884825f325 Fix method calls in test suite (functions moved classes). 2019-02-08 13:19:20 -08:00
Peter Fabian 5fbf5b62d7 Normalize datetimes before doing any further processing with the input from the user.
Also, passing DateTime objects around instead of string so that timezone info can be easily attached to it.
2019-02-08 18:11:04 +01:00
Claudio Sanches ec43d58973 Fixed WordPress database error in unit tests
Fixes the follow error:

```
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'THIS WONT MATCH' at line 1]
```

Fixes woocommerce/woocommerce-admin#1489
2019-02-07 19:48:16 -02:00
Albert Juhé Lluveras e2b10bdb49 Fix test_variable_product_extended_info (https://github.com/woocommerce/woocommerce-admin/pull/1498) 2019-02-07 10:49:50 +01:00
Joshua T Flowers 8c3973a445 Add manage_stock to stock controller response (https://github.com/woocommerce/woocommerce-admin/pull/1475)
* Add manage_stock to stock controller response

* Add manage_stock property to stock report tests

* Add changelog entry

* Make stock quantity float instead of int

* Add manage_stock to the products API response

* Check for manage_stock in products table

* Add manage_stock property to product API tests
2019-02-07 16:29:01 +08:00
Albert Juhé Lluveras 79738b2022 Add 'variations' attribute in products 'extended_info' (https://github.com/woocommerce/woocommerce-admin/pull/1478)
* Add 'variations' attribute in products 'extended_info'

* Add tests
2019-02-07 09:27:02 +01:00
Joshua T Flowers 2b0c8089c0 Try: Fix failing returning customer test (https://github.com/woocommerce/woocommerce-admin/pull/1496)
* Don't check against same order when checking for returning customer

* Sleep between order creation

* Add todo removal comments for sleep functions
2019-02-07 15:49:56 +08:00
Peter Fabian 79e22bcefd Switched to creating orders from oldest to newest, not the other way around. (https://github.com/woocommerce/woocommerce-admin/pull/1495)
That should hopefully take care of the problem with strange new/returning customer values and failing tests.
2019-02-07 15:41:09 +08:00
Joshua T Flowers b7379def1b Format todo comments to match WC Core format (https://github.com/woocommerce/woocommerce-admin/pull/1474)
* Format todo comments to match WC Core format

* Remove variations todo comment
2019-02-06 14:41:53 +08:00
Claudio Sanches b7c40c2c29 Merge pull request woocommerce/woocommerce-admin#1461 from woocommerce/fix/1460
Fixed database prefixes for admin notes tables
2019-02-05 16:21:43 -02:00
Claudio Sanches d26e82b526 Merge branch 'master' into fix/1307 2019-02-05 16:20:08 -02:00
Claudio Sanches 86c3c00480 Clean tables when order is deleted 2019-02-05 16:15:39 -02:00
Justin Shreve 949afce248 Add Product Detail Report & Finish Comparison Chart Mode Functionality (https://github.com/woocommerce/woocommerce-admin/pull/1391)
Product detail report and comparison

Code cleanup

Fix 404 on product variations endpoint after rebase

Fix up tests

Fix loading indicators and add some checks around malformed variation response

Add date filtering SQL bits to the variations query

Handle PR feedback: Fix viewport, fix duplicate product issue, fix legend display reset, fix bargraph overflow, fix some coding standards/whitespace, add extra variation santiziation.

Fix scroll on wide charts, and fix undefined prop getting passed into report chart render
2019-02-05 13:12:58 -05:00
Claudio Sanches 10f40d4cf3 Merge branch 'master' into fix/1307 2019-02-05 15:48:59 -02:00
Peter Fabian 98e91966d5 Updated tests for code in master:
- added segment arrays and
- forced sync before running asserts.
2019-02-05 18:46:42 +01:00
Peter Fabian b69d2aa2ab Merge branch 'master' into fix/1012-2
# Conflicts:
#	tests/reports/class-wc-tests-reports-orders-stats.php
2019-02-05 18:34:15 +01:00
Jeff Stieler 7664612b57 Fix order stats report status filtering test case (returning customer value incorrect). 2019-02-04 16:59:08 -07:00
Jeff Stieler f938dd5708 Invoke queue test helper in new Order Stats and Products Report tests. 2019-02-04 11:46:46 -07:00
Jeff Stieler bebe1bdead Add test for scheduling a retry job when order syncing fails. 2019-02-04 09:18:51 -07:00
Jeff Stieler 21572698d8 Fix unit tests that rely on queued data updates. 2019-02-04 09:18:50 -07:00
Jeff Stieler 9b1f6999aa Add action argument support when scheduling dependent actions. 2019-02-04 09:06:44 -07:00
Joshua T Flowers 0d4e42def0 Add segments to expected response in order stats (https://github.com/woocommerce/woocommerce-admin/pull/1466) 2019-02-04 18:39:33 +08:00
Joshua T Flowers 17179d41ff Add order status tests and refund tests (https://github.com/woocommerce/woocommerce-admin/pull/1443)
* Add default order status tests

* Test querying an excluded status

* Add tests for product line item refunds

* Update status test method comment

* Drop @since versioning from doc blocks
2019-02-04 10:52:29 +08:00
Claudio Sanches c1bb5802d1 Fixed coding standards 2019-02-01 18:48:54 -02:00
Claudio Sanches 31e8dc9332 Merge branch 'master' into fix/1307 2019-02-01 18:24:26 -02:00
Peter Fabian 32f851be5b Merge pull request woocommerce/woocommerce-admin#1286 from woocommerce/fix/1035
Added segmenting support to REST API
2019-02-01 20:50:38 +01:00
Claudio Sanches 4c71e78222 Fixed database prefixes
Moved from woocommerce_ to wc_
2019-02-01 17:23:07 -02:00
Peter Fabian 2bc99cdb31 Added basic tests for zero filling when sorting intervals by non-date property. 2019-02-01 18:16:39 +01:00
Peter Fabian c2bcad2e50 Merge branch 'master' into fix/1012-2 2019-02-01 13:32:35 +01:00
Joshua T Flowers e65247c54e Add SKU to product variations table (https://github.com/woocommerce/woocommerce-admin/pull/1422)
* Add SKU to product variations data store extended info

* Show SKU in product variations table

* Add sku tests for product variation reports
2019-01-31 09:27:15 +08:00
Peter Fabian e433609d9d Updated test of schema for taxes/stats. 2019-01-30 18:46:06 +01:00
Claudio Sanches d1fef77ed0 Added unit tests for order deletation 2019-01-29 20:21:09 -02:00
Paul Sealock 4854933485 Merge pull request woocommerce/woocommerce-admin#1404 from woocommerce/fix/customers-date-between-args
Customers Report: REST API: Fix between argument handling
2019-01-30 10:32:54 +13:00
Timmy Crawford 10c6016d4c Update usage of lib/number to @woocommerce/number (https://github.com/woocommerce/woocommerce-admin/pull/1400)
* Remove usage of lib/number

* Remove formatNumber usage when currency is used.

* Add wc-number as a dependency of wc-currency.

* Add locutus as a dev dependency.

* Add number to test helper.
2019-01-29 08:48:46 -08:00
Peter Fabian e4e09b4c39 Merge branch 'master' into fix/1035 2019-01-29 10:01:41 +01:00
Paul Sealock 3e16a37be0 add tests 2019-01-29 11:01:25 +13:00
Paul Sealock 483c199fbf tests working 2019-01-29 10:53:56 +13:00
Paul Sealock 2f022ffdba dry interval.php 2019-01-29 10:23:44 +13:00
Paul Sealock 3d0890a704 basic working 2019-01-29 09:21:11 +13:00
Paul Sealock bca0785e64 Customers Report: support between args for dates 2019-01-29 08:58:07 +13:00
Jeff Stieler 7592dae4bb Merge pull request woocommerce/woocommerce-admin#1385 from woocommerce/add/customers-report-table-summary
Add table summary to Customers Report
2019-01-28 09:59:52 -07:00
Jeff Stieler 2703a0da4c Merge pull request woocommerce/woocommerce-admin#1370 from woocommerce/fix/942-phpunit-gutenberg-dependency
Conditionally include Gutenberg plugin in test suite
2019-01-28 09:59:13 -07:00
Peter Fabian 05aedb2a63 Added tests for ASC ordering. 2019-01-25 17:40:33 +01:00
Jeff Stieler 8207bd7649 Add tests for customers report stats endpoint. 2019-01-23 17:48:22 -07:00
Jeff Stieler 4cfa082d0f Load gutenberg from test plugins directory if required. 2019-01-23 16:59:10 -07:00
Peter Fabian c96b291a6c Added a bit of test for interval=hour order_by=date desc. 2019-01-23 22:13:00 +01:00
Peter Fabian d61a4dd5bd Updated tests to be more stable around hour end. 2019-01-25 00:06:59 +01:00
Peter Fabian 71a9be299a Updated tests to pass before implementing the updated new/returning customer definition.
Context: https://github.com/woocommerce/wc-admin/issues/558#issuecomment-447782060
2019-01-23 13:29:40 +01:00
Peter Fabian 83a0d96f68 Added segmenting to response for revenue/stats test. 2019-01-23 10:37:09 +01:00
Peter Fabian e432a17f1e Added segmenting to response for products/stats test. 2019-01-23 10:36:50 +01:00
Peter Fabian f190c1bad1 Fixed copy-paste bug for testing subtotals in REST response. 2019-01-23 10:36:27 +01:00
Peter Fabian bcb7513f34 Added segmenting to response for coupons/stats test.
Fixed copy-paste error in test for subtotals.
2019-01-23 10:35:48 +01:00
Peter Fabian fed94cbd0c Added segmenting to response for coupons/stats test.
Changed return type for currency.
2019-01-23 10:34:07 +01:00
Peter Fabian 507ee13825 Merge branch 'master' into fix/1035
# Conflicts:
#	client/analytics/report/customers/table.js
#	includes/api/class-wc-admin-rest-reports-orders-stats-controller.php
#	tests/reports/class-wc-tests-reports-orders-stats.php
2019-01-23 10:13:55 +01:00
Jeff Stieler 2d4aea1971 Only install/activate Gutenberg plugin if WP version under test is earlier than 5.0. 2019-01-22 10:44:00 -07:00
Peter Fabian 8a9a2c0673 Fixed interval arithmetic for hours and days. 2019-01-22 17:49:02 +01:00
Justin Shreve 1f8caf106e Fix performance-indicators/allowed schema. 2019-01-21 12:28:32 -05:00
Justin Shreve 01b96ebea5 Hook up performance indicators to the REST API 2019-01-18 08:19:19 -05:00
Justin Shreve 96fc10747f Add label and generated report URL to the performance indicator response. 2019-01-18 08:16:52 -05:00
Joshua T Flowers 7cdbbf87e8 Update all wc-admin endpoints to v4 (https://github.com/woocommerce/woocommerce-admin/pull/1298)
* Update all wc-admin endpoints to v4

* Add namespace for products and customers controllers

* Include product quantity in orders data store

* Add coupons to extended data in the orders data store

* Format order statuses response from database

* Hook up orders table to orders endpoint

* Add namespace to data endpoint controller

* Add namespaces to remaining extended controllers

* Use NAMESPACE var in place of wc/v4

* Update product links in orders table to products reports

* Add coupons rest controller override

* Format coupon code in response

Co-Authored-By: joshuatf <joshuatf@gmail.com>
2019-01-18 10:52:58 +08:00
Jeff Stieler 4407e05bc4 Merge pull request woocommerce/woocommerce-admin#1342 from woocommerce/fix/1090-currency-settings-formatting
Honor WooCommerce Settings When Formatting Currency/Price
2019-01-17 17:06:13 -07:00
Jeff Stieler 6ed8ea117a Refactor formatCurrency() to use store settings for formatting rather than store locale. 2019-01-17 00:04:57 -07:00
Joshua T Flowers da22cbdc9d Update returning customer data to use customer ID (https://github.com/woocommerce/woocommerce-admin/pull/1180)
* Change check for returning customers to check customer_id

* Count distinct returning and new customers in totals

* Fix priority action misplacement and order date timestamp

* Change expected num returning/new customers to fix failing tests

Previously these included references to number of returning vs new orders.  Update to refer to the newly updated customer count.

* Use new get_customer_id_by_user_id() to get customer ID

* Fix 0 returning customers expectation

* Move returning customer function to order stats data store

* Sync order stats on order delete

* Change date compare for is_returning_customer

* Add test case for returning customer order

* Add references to  instead of 2
2019-01-17 10:47:30 +08:00
Jeff Stieler c0e6a097fd Fix orders report test. 2019-01-16 09:45:52 -07:00
Jeff Stieler 5c6174066e Add tests for report regeneration batch queuing methods. 2019-01-16 09:45:04 -07:00
Jeff Stieler 1a5af7094d Add WC_Action_Queue test helper class.
The test helper allows inspection of the action queue.
2019-01-16 09:45:04 -07:00
Jeff Stieler 4786938bdf Fix customers report tests. 2019-01-16 09:45:03 -07:00
Peter Fabian 05c7670090 Merge branch 'master' into fix/1035
# Conflicts:
#	includes/class-wc-admin-reports-interval.php
#	includes/data-stores/class-wc-admin-reports-data-store.php
#	includes/data-stores/class-wc-admin-reports-products-data-store.php
2019-01-16 12:51:23 +01:00
Joshua T Flowers 33a7cfa1b0 Store all order statuses (https://github.com/woocommerce/woocommerce-admin/pull/1285)
* Store all orders regardless of status in wc_order_stats

* Only query select statuses if status_is or status_is_not is not set

* Fix order stats example query

* Filter category store by default order statuses

* Add table_name to interval functions to avoid ambiguity

* Filter coupon store by default order statuses

* Fix interval stats by adding table_name to interval function

* Filter products store by default order statuses

* Remove unused order_status in coupons data store

* Store products with any order status

* Fix ambiguous order by call in products data store

* Apply status filter after other filters to avoid logical OR matching

* Store all coupon data regardless of order status

* Filter taxes by default order statuses

* Filter customer stats by default order status

* Filter default order statuses in variations data store

* Use excluded statuses to filter reports by default

* DRY up default excluded statuses query

* Fix up new orders data store after rebase
2019-01-16 10:23:00 +08:00
Peter Fabian 29f07f8c57 Re-enable temporarily disabled tests. 2019-01-15 11:51:43 +01:00
Peter Fabian 5ba443fca8 Updated data store used in test to reflect the rename of class. 2019-01-15 11:50:53 +01:00
Peter Fabian c324157483 Merge branch 'master' into fix/1035
# Conflicts:
#	includes/data-stores/class-wc-admin-reports-orders-data-store.php
#	includes/data-stores/class-wc-admin-reports-orders-stats-data-store.php
2019-01-15 11:39:39 +01:00