* Remove setup_experiment_1 and setup_experiment_2 tests and css
* Remove setup_experiment_1 and 2 from the client code
* Copy over setup_experiment_1 options to the setup tasklist and remove setup_experiment_1 and 2
* Add changelog
* Determine the default component to use by task id
* Update plugins/woocommerce-admin/client/tasks/hooks/useActiveSetupList.ts
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
* Introduce the ObjectCache class.
It's an abstract class intended to be used to implement caching for
any kind of object (arrays or PHP objects) using the underlying
WordPress caching or any alternative custom cache engine.
* Add changelog file
* Change the order of parameters in ObjectCache::get
Also change the max expiration value from one day to one month
* Implement order edit screen rendering.
* Add changelog.
* Use global function instead of harcoded string.
* Use pagecontroller to display order edit form.
* Move HTML out from the translatable string.
Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
* Capitalize `Order` for consistency.
Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
* Minor realignment.
* phpcs fix .
* Decouple meta boxes from global $post object to support custom order tables.
* Bug fixes - improperly set $order object, and allow passing null.
* Make order item meta work with order object.
* Use `$order` object to minimize diff.
* Refactor $theorder object initialization to a common method.
* Remove check for WC_Order object.
* Move common methods to inside `src` in a dedicated class.
* Fix spacing for code style.
* Renamed method to be more accurate.
* Add proxies for static so they can be mocked.
* Remove PageController import.
* Move helper methods to an internal util class.
Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
* Support force_default_suggestions argument
* Use force_default_suggestions
* Support force_default_suggestions argument -- returns the default payment suggestions when both woocommerce_show_marketplace_suggestions and woocommerce_setting_payments_recommendations_hidden options are set to no
* Add changelog
* Add methods to get and clear queued pixel events
* Add utils for getting and asserting events in unit tests
* Add in some assertions around task list completion tracks
* Add changelog entry
* Add comment for test task fixture
* Stop re-enabling product attributes lookup table usage after each install.
Now the option will be enabled after a WooCommerce install/update
only if the user hadn't explicitly disabled it before.
* Add changelog file
* Make sure orders are saved with a default status
* Add support for ‘customer’ query var in COT
* Make PHPCS happy in COT datastore tests
* Add tests for ‘customer’ query var
* Add changelog
* Add OrdersTableQuery for querying the COT tables
* First stab at `OrdersTableDataStore::query()` method
* Silence possible PHP warning
* Add docblocks & phpcs fixes
* Introduce OrdersTableMetaQuery
* Add support for meta_query
* Add changelog
* ‘status’ should have the ‘wc-‘ prefix
* PHPCS fixes
* Minor improvements
* Add tests for OrdersTableQuery
* Remove ‘paginate’ query var
* Add support for reading multiple objects at once
* Address feedback
* Prevent `get_order_data_for_ids()` from producing an incorrect query when no IDs are passed
* Make CI happy
* Add WooCommerce default styles for block themes
* Ensure sale badge remains as is in Twenty Twenty-Two
* Style the mark element in theme colors
* Update product variations dropdowns
* address feedback
* address feedback
* fix store notice position
Co-authored-by: Luigi <gigitux@gmail.com>
The attributes page displays all the terms for all the existing
product attributes, which causes a performance problem in sites
with a lot of attributes and terms.
This commit limits the number of attributes shown to 100 by default,
but it also introduces a woocommerce_max_terms_displayed_in_attributes_page
filter to customize it.
* Use method_exists instead of throwing in reflect_class_or_callable
In AbstractServiceProvider::reflect_class_or_callable we were
detecting whether a 'init' method exists in the class or not via
doing 'new ReflectionMethod' and catching the exception.
This caused problems with XDebug, which is bad enough, but additionally,
throwing an exception when it's not abosultely necessary
is a bad practice in general.
* Add changelog file
* Fix code standards errors in class-wc-meta-box-orrder-data.php
- Sanitize all input
- Escape all output
- Verify nonce on save
- Verify that all required POST parameters are present on save
- Minor fixes (periods at end of comments, function docs, Yodas...)
* Check payment method name, not title, on add_order_item_totals_payment_method_row
* Remove unnecessary nonce verification in "save" for orders.
Also move comment to new line for readability.
* Remove unnecessary nonce check in WC_Meta_Box_Order_Data::save
The check is already performed in the code that invokes "save".
* Add transaction id to payment method string if URL doesn't exist
* Minor fix
Co-authored-by: Jorge A. Torres <jorge.torres@automattic.com>
* Update woocommerce admin scripts to align more with monorepo
* Add changelog
* Add dev script back in
* Add install-if-deps-outdated back into build script
* Remove --force from dev script and add WC_ADMIN_PHASE to turbo cache key
* Remove install-if-deps-outdated from build
* Add composer install step to pr unit tests workflow
* Remove old install scripts, that are not needed anymore
* Make sure client changes are part of the cache hit
* Add composer install to code coverage and code sniff as well
* Add composer_no_dev input to install-build workflow
* Add sass dependency to woocommerce/admin/client turbo cache
* Add validations to `recordEvent`
* Add changelog
* Use always class constant
* Changed trow exception by console.error
* Add tests to `validate_and_sanitize`
* Created 2 different methods to test `event_validation_and_sanitization`
* Fix tests
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Fix free features is still rendered when there is no recommendation
* Add changelog
* Update BusinessDetails tab to go to next step if no installable extensions
* Update spinner
* Set retries to 4 on CI
* Use variable for authentication path storage
* Handle test cleanup in after hook
* Improve conditional
* Clean up global attributes
* Update customer email address
* Changelog file
Co-authored-by: Jon Lane <jon.lane@automattic.com>
* Updated wp-env test port
* Added script to init test env
* Added env helper scripts
* Updated admin email to match wp-env
* Fixed flaky tests
* Updated test readme
* Updated workflow to use wp-env
* Added changelog
* Stored admin email in variable
* Added check for flaky test
* Updated workflow to work with both envs
* Updated README.md
* Updated condition
* Updated changelog
* Fixed workflow
* Fixed workflow
* Fixed workflow
* Restored workflow
* Updated check to be a string
* API: System Status: Cache plugins data
This is a follow up to https://github.com/woocommerce/woocommerce/pull/32823
where we introduced caching for retrieving theme data. Here we're
cachcing plugin data. Since we have to read from the filesystem and
parse the plugin headers, this can be kind of slow.
We should see an improvement on sites with more than a few plugins and
the improvement could be significant on sites that have many plugins
installed (even if they're not active).
* add CLI com command class and hook it
* Update php docs and change registered command names for wc com.
* Fix lint issues.
* Retrieve and display extension list and for the connected site.
* Adding the changelog for wc com extension list
* Remove the install command which not implemented in current branch.
* Update example usages for wp wc com extension list command.
* Update changelog.
* Fix the changelog file formatting
Co-authored-by: Rommel Castro <rommelxcastro@gmail.com>
Co-authored-by: Néstor Soriano <konamiman@konamiman.com>
* Update github action to equire valid changelog file
* Update github action for changelogger to install depedencies and composer
* Make valid changelog files that were invalid
* `add_meta()` should be more flexible
* Add `delete_order_data_from_custom_order_tables()`
* Add private method `trash_order()` to COT datastore for handling order trashing
* First stab at COT datastore `delete()`
* Delete COT data for orders when deleting its associated post
* Add changelog
* Simplify delete logic
* Minor fixes
* Rework `create()` tests
* Add tests for `delete()`
* Remove unnecessary var
* Set allowedTextDomain to only allow woocommmerce text domain
* Set allowedTextDomain to only allow woocommerce text domain
* Fix wrong or missing i18n text domain
* Add changelog
* Add changelog
* Updates to simple product test to reduce flakiness
* Remove focus
* Fix to improve flakiness of order refund test
* Added a wait to help page loads test
* Add a couple more waits to refund tests
* Changelog
* Retry key generation during global setup
* Setup checklist has changed, update
* Update to setup task list
* Add wait for setup checklist
* Update locator for install checklist
* Changelogger: Fix PHPCS violations (#33664)
* Deploy header task variant from task list experiment (#33750)
* Deploy task list experiment 1
* Add changelog
* Fix wrong copy in the payment task (#33749)
* Add headingDescription prop to PaymentGatewaySuggestions list
* Fix payment suggestions heading text
* Add changelog
* Fix missing manage button for TikTok (#33731)
* Fix missing manage button for TikTok
* Add changelog
* Packages: Fix postinstall errors on install (#33724)
* Fix additional payment task name (#33727)
* Rename "Set up additional payment providers" task -> "Set up additional payment options"
* Add changelog
* Remove change files for #33704 (#33734)
* Add shipping class data store (#33765)
* Add initial shipping classes data store
* Add types for the product shipping class store
* Filter out undefined items in list for when an item is deleted
* Add changelog
* Add data store README
* Fix onboarding test
* Skipping flaky test
Co-authored-by: Jon Lane <jon.lane@automattic.com>
Co-authored-by: Paul Sealock <psealock@gmail.com>
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
Co-authored-by: jonathansadowski <jonathansadowski@users.noreply.github.com>
Co-authored-by: louwie17 <lourensschep@gmail.com>
* Final updates for Playwright
* Update config
* Add uuid dependency
* Increase retries to 2
* Update selectors on shipping page
* Use baseURL instead of hard-coded URL for API
* Clarify comment
* Use baseURL instead of hard-coded URL
* Check to see if an order was created before attempting to delete it
* Add changelog
* Turn on Playwright tests in GitHub
* Increase timeout for CI execution
* Update configuration options (minor edit)
* Fix for checkout flaky test
* Parse orderId from URL
* Check for substring
* Streamline email tests
* Remove .only
* Only clear email logs of messages for test
* Get orderId from page element
* Fix for test not waiting for reset
* Add in second wait for Performance section
* Change significance from minor to patch
Co-authored-by: Jon Lane <jon.lane@automattic.com>
* Make sure the default form value tooltip is initialiazed when adding the first variation
* Update copy of default form value tooltip in variations
* Add changelog
* Fix auto formatting
* Add pointer events: none to tooltip to prevent flickering
* Change review shipping task id to 'review-shipping'
* Add click track for shipping-recommendation task from the settings page
* Changelog
* Add test
* Add more specific test param
* Add pyament icons
* Add changelog
* Text and logo changes when wc pay is installed and setup
* Use PaymentSuggestions to query plugins
* Make sure image_72x72 exists
* Remove unused namespaces
* Remove stripe2 image -- no longer needed
* Make sure recommended payment is not already active
* Check plugins field to filter out active plugins
add: intro tooltips for shipping smart defaults
- removed php code for setting 'reviewed' option as it was being set on page load and thus always evaluated to true before the user sees it
- added intro tooltips
Update wp-background-process.php to use wp_convert_hr_to_bytes()
Currently the code is typecasting the memory limit to an int. This assumes that the memory limit is in MB, so if you set your memory limit to 4G this will return 4194304 bytes (4.19304 MB.) Instead, we should use the native WordPress function `wp_convert_hr_to_bytes` to handle the conversion into bytes correctly.
* Update StoreDetails task action url to navigate to the setting page
* Add changelog
* Update complete logic of StoreDetails task
* Update store details unit tests for new task completion logic
Added `triggerHandler` before each ajax request.
* Added namespace to event name
* Linting.
Co-authored-by: Luigi Pulcini <luigi@barn2.com>
Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
This reverts commit bccc80366d.
When we merged this PR, we thought the Woo mobile apps would have enough time to implement some corresponding changes on their side. That turned out not to be the case. Without the ability to force a refresh of the analytics cache, this PR causes the apps to have a greater risk of showing users stale analytics data that they can’t immediately update.
* Include Tracks property indicating block editor on product update.
* Add changelog
* In a block editor the Update button does not have the selector.
* Remove - from Tracks even property.
* Refine a condition of a non-empty object.
* Incorporate feedback: add callback for rendering the Update button.
* Add recent feedback- jQuery way of handling post render execution.
* Remove `console.log
* Fix `product_update` event recording
* Removed `hasRecordedEvent` and fixed `description validation
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Update shipping task fields when shipping smart default feature is enabled.
* Always display the shipping task regardless of having a physical product
* Updated text copy for the fields
* Do not display the step description if it is not the current step
* Added a banner for the shipping printing step
Remove description if the it is not the current step
* Add changelog
* Fix namespace conflict after the rebase
* Re-use wcs banner from the experimental shipping recommendation
* Delete ShippingLabelPrinting -- replaced by wcs banner from experimental-shipping-recommendation
* Add TOS link
* Remove ShippingPrintLabel styles -- no longer needed
* Minor refactor
* Move description set logic to getSteps()
* Use map to override step fields
* Remove unnecessary feature check
* Remove description in the map func
* Render ShipStation banner if plugins includes woocommerce-shipstation-integration
* Plugins component skip button is now optional
* Add link from payment settings page
* Add new experimental shipping task flow
* Changelog
* Update plugins/woocommerce/src/Admin/Features/OnboardingTasks/Tasks/ExperimentalShippingRecommendation.php
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
* Rename all tracks to shipping_recommendation
* Add back skip installer bind
* Pass plugins list to pluginSlugs to be more predictable
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
* Add logic to set the default shipping options
* Set the flat rate cost to 15 (temp cost)
* Add changelog
* Update plugins/woocommerce/src/Internal/Admin/Homescreen.php
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
* Run the changes only if shipping-smart-defaults is enabled
* Assume user is going to sell physical products if obw is skipped or the store details has not been completed
* Make sure store country is set by an actual user by checking the value of woocommerce_store_addres
* Remove flat late logic
* Use woocommerce_store_address. store_address is always empty
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
* Add phpcs-changed
* Put report flag value in quotes
* Use phpcs action workflow instead
* Remove no longer used phpcs script
* Remove phpcs ignore rule
* Use proper name for code sniffer step
* Fixes issue #33335
Check for an empty string instead of an empty variable.
* Update wc-product-functions.php
* Update wc-product-functions.php
* Changelog
* Fix cases when $term is false or empty array
Co-authored-by: Peter Fabian <peter.fabian.github@gmail.com>
* Fix broken design of Single Product template in block themes and on sale badge being partially hidden
* Update changelog to mention Twenty Twenty-Two explicitly.
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Fix phpcs errors and warnings
* Fix code that throw deprecation notices in PHP 8.1
The deprecation notices are about:
- Various "passing null to parameter (...) is deprecated"
- Usage of strftime
- Using "false" as if it was an empty array
- Mismatching return type of implemented interfaces,
that's fixed by adding #[\ReturnTypeWillChange]
* Fix some more code that throw deprecation notices in PHP 8.1
* Small commenting/formatting fixes.
* Add changelog file
* Formatting.
Co-authored-by: Peter Fabian <peter.fabian.github@gmail.com>
During migration $wpdb->prepare would force null and empty values to be zero for %f placeholder. This was causing verification logic to fail, which is being addressed in this commit.
The alternative was to insert null values without running them via $wpdb->prepare, but that seemed less safer than converting to zero because it would have to done manually since $wpdb->prepare wouldn't support it.
This commit adds documentation for WooCommerce's client component commands. This should make it easier to know what commands to run to work in these components.
This commit changes it to woocommerce/client/admin. This is an invalid NPM package name and an invalid Composer package name. This will prevent conflicts but also identify it as a component of Core.
In line with the fact that it's a component of WooCommerce rather than a standalone package, `woocommerce-legacy-assets` has been renamed `woocommerce/client/legacy`.
* Trigger the hook that record the track events
once the option settings are updated:navigation and analytics. Tracks do not include yes/no properties, so we record the latter as _disabled.
* Changelog
* Prevent reloading of page immediately after feature updates
* Remove feature specific code in tracks class
Co-authored-by: Joshua Flowers <joshuatf@gmail.com>
* Changes the frequency at which the Reports API cache can be invalidated via the cache version number to be at most once every 10 minutes, instead of with every change to the store.
* Changes the TTL of Reports API cache entries so that they expire after an hour instead of after a week.
The goal of these changes is to increase the chance that a request to the Reports API for store stats will result in a cache hit, thus avoiding expensive, slow queries. The reason for lowering the TTL is so that if multiple store changes are made within the new 10-minute frequency window, the cache data will only be stale for up to an hour. With #33325 users will be able to refresh entries in the cache manually if they think something is stale.
Closes#33315
Make sure payment gateway title is a string before sanitizing.
* Add changelog
* Drop type-hint in `validate_safe_text_field()`
* Update plugins/woocommerce/includes/abstracts/abstract-wc-settings-api.php
Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
* Add `OrdersTableDataStoreMeta` to handle metadata for orders
* Add `OrdersTableDataStoreHelper` with various helper functions used in the COT datastore
* Pass some helper classes as args to the COT datastore
* Use `OrdersTableDataStoreMeta` for meta in COT datastore
* Minor fixes to columns definition in COT datastore
* First pass at update() in the COT datastore
* PHPCS fixes
* Remove duplicate `read_meta` calls.
* Register `OrdersTableDataStore` earlier to make container happy
* Do not hardcode table metadata in `OrdersTableDataStoreMeta`
* Correctly format decimals for storing in the db
* read() shouldn’t success on non-existing orders
* Rework persisting to db in OrdersTableDataStore
* Correctly handle some props in OrdersTableDataStore
* Add changelog
* Add missing TODOs
* Remove unused variables
* No need to query db before deleting meta in `OrdersTableDataStoreMeta`
* Simplify OrdersTableDataStoreMeta::update_meta()
* Explicitly enumerate columns in OrdersTableDataStoreMeta::get_metadata_by_id()
* Make COT metadata implementation more generic
* Do not use property_exists() to determine existence of meta value
* Move some methods over to DatabaseUtil and get rid of COT datastore helper
* Rename `CustomDataStoreMeta` to `CustomMetaDataStore`
* Make PHPCS happy
* Add unit test.
* Correct arg passed to persist_order_to_db()
* Remove comment
* Split conditional on multiple lines
Co-authored-by: vedanshujain <vedanshu.jain.2012@gmail.com>
Adds a new collection parameter to all Reports API endpoints that utilize caching, `force_cache_refresh`, which will cause the current request to bypass the cache, re-run the queries for the requested data, and overwrite the previous cache entry with the new results.
Note that this doesn't invalidate the entire cache, only the entry for the particular set of collection parameters and values specified in the request.
This also adds a way to include debugging information related to the cache in the API response. Modeled after the way the Query Monitor plugin adds such information, you can get this by including an `_envelope` parameter in your API request. The debugging info includes whether the cache has been disabled via filter (`should_use_cache`), whether the `force_cache_refresh` parameter was used, whether the returned data was a `cache_hit` or not, and an array of the query parameters that were actually used to create the cache key.
Closes#33221
* Introduce a 'safe_text' field that allows a reduced subset of HTML tags.
* Escape on input as well as output; generalize sanitization function.
* Set reasonable default rules.
* Guard against invalid callbacks (escaping/sanitizing) functions.
* Update plugins/woocommerce/src/Internal/Utilities/HtmlSanitizer.php
Co-authored-by: Peter Fabian <peter.fabian.github@gmail.com>
* Allow alt (accessibility) for img tags; allow class attributes for img and span tags.
* Allow class attr for p tags.
* Use safe_text for payment gateway titles.
* Make HtmlSanitizer available through Utils service provider.
* Update settings code to pull HtmlSanitizer as a service and to use the new sanitize() method.
* Remove `style` from list of allowed attributes.
Allowing arbitrary CSS rules through style could undo the intent of this change, since that would allow a range of positioning and sizing changes to be effected.
* Remove unusued import.
* If no (KSES) rules are specifed, then strip all tags (this is a safer default strategy).
* For better safety, only apply pre-processor callbacks; remove responsibility for trimming of strings.
Applying callbacks to a string after it ahs passed through wp_kses() could (potentially) undo the work done by that function, and result in unexpected tags in the sanitizer's output.
Co-authored-by: barryhughes <3594411+barryhughes@users.noreply.github.com>
Co-authored-by: Peter Fabian <peter.fabian.github@gmail.com>
* Update WooStep to have name in meta
* Add useProductStepChange hook and use it to detect form value changes in product tourkit, added tracking for tour view, tour dismiss, tour complete, and step complete
* Add tour view, tour dismiss, tour completion track to old product walkthrough
* Changelog
* Fix test
* Add listener to publish button for product spotlight tour
* Add track for old walkthrough publish button