woocommerce/includes
Nestor Soriano d6118841c8 Introduce an experimental GraphQL API.
- Uses the webonyx/graphql-php framework.
- Must be enabled at Settings - Advanced - GraphQL API.
- Entry point is POST at /wp-json/wc/graphql/api
- Input is a JSON object with "query" and optional "variables" fields.
- Code lives at src/Internal/GraphQL.
- Same authentication token/secrets as the REST API are used.
- Introduces a new "woocommerce_graphql_check_permissions" filter.
- Add ?verbose_errors to the url to get the exception message
  and a stack trace in case of internal error (for this to work
  either the user must be in the administrators role
  or WP_DEBUG must be set)
2021-03-19 10:24:31 +01:00
..
abstracts Fix typos in docs 2021-03-05 11:19:58 +02:00
admin Introduce an experimental GraphQL API. 2021-03-19 10:24:31 +01:00
blocks Review refactor. 2021-01-06 15:28:51 +01:00
cli Merge branch 'master' into fix/27215 2020-10-14 10:16:36 -03:00
customizer Revert "Use %1$s instead of %s on regen description" 2021-01-15 20:27:03 -03:00
data-stores Refactor and moved filter to _wc_recount_terms function 2021-03-10 12:33:46 -08:00
emails Fix docblock defaults to false closes #29367 2021-03-12 11:59:18 -08:00
export Add filter to allow third-parties to filter exportable product types 2021-02-02 14:41:03 +10:00
gateways Remove deprecated PayPal Standard parameter 2020-12-04 14:39:03 -03:00
import Add filter to allow third-parties to filter exportable product types 2021-02-02 14:41:03 +10:00
integrations/maxmind-geolocation Replace 'DIRECTORY_SEPARATOR' with '/' 2020-08-26 15:50:34 -05:00
interfaces Fixed package tag usage 2020-08-05 13:36:24 -03:00
legacy Fixed usage of package tag in REST API and templates 2020-09-17 11:56:08 -03:00
libraries Don't echo error when doing AJAX because it invalidates JSON 2020-03-17 16:49:52 +05:30
log-handlers Fixed package tag usage 2020-08-05 13:36:24 -03:00
payment-tokens Fixed package tag usage 2020-08-05 13:36:24 -03:00
queue Make next webhook not return a date when the webhook is already running. 2020-11-04 09:10:28 -05:00
rest-api Merge pull request #29218 from wywarren/fix/27553 2021-03-11 09:22:34 -08:00
shipping Add a 'NumberUtil' class with a 'round' method. 2020-10-01 11:08:51 +02:00
shortcodes Update `lostpassword_post` action and add missing parameter 2020-12-02 09:52:58 -03:00
theme-support Remove extra content wrapper 2021-02-12 17:50:48 -05:00
tracks Add section to tracks event props 2021-02-23 12:25:40 +09:00
traits Add a 'NumberUtil' class with a 'round' method. 2020-10-01 11:08:51 +02:00
walkers Convert optional-before-required arguments to required (take 2) 2020-10-16 13:08:31 +02:00
wccom-site Fixed incorrect package tags 2020-08-05 17:49:10 -03:00
widgets Reintroduce adjust_posts_count, and remove unnecessary comment. 2020-09-10 15:17:43 +02:00
README.md Update default GIT branch 2021-02-25 20:51:14 -03:00
class-wc-ajax.php Fixed docblock 2021-02-26 20:54:40 -03:00
class-wc-api.php Fixed usage of package tag in REST API and templates 2020-09-17 11:56:08 -03:00
class-wc-auth.php Fixed usage of package tag in REST API and templates 2020-09-17 11:56:08 -03:00
class-wc-autoloader.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-background-emailer.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-background-updater.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-breadcrumb.php support overriding/customising password reset page title via `action`: 2020-10-14 09:50:36 +13:00
class-wc-cache-helper.php Avoid/minimize wc-ajax requests when `geolocation_ajax` is enabled | #26973 2021-02-19 14:50:59 -08:00
class-wc-cart-fees.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-cart-session.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-cart-totals.php Remove unnecessary dots 2021-01-22 17:13:49 +01:00
class-wc-cart.php Use product already loaded 2021-02-23 21:10:34 -03:00
class-wc-checkout.php Check if index value is set before accessing 2021-02-15 06:54:22 -08:00
class-wc-cli.php
class-wc-comments.php Addressed PR feedback. 2021-01-18 10:29:42 +05:30
class-wc-countries.php Merge pull request #29008 from inc2734/patch-1 2021-03-04 07:31:45 -08:00
class-wc-coupon.php Use correct syntax for translators comments. 2020-12-21 15:33:10 +05:30
class-wc-customer-download-log.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-customer-download.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-customer.php Add protective check to make sure WC()->session is initialized before loading the data store. 2020-12-30 19:20:51 +05:30
class-wc-data-exception.php
class-wc-data-store.php Use the spread operator instead of call_user_func_array() in WC_Data_Store 2019-11-21 11:52:47 -03:00
class-wc-datetime.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-deprecated-action-hooks.php
class-wc-deprecated-filter-hooks.php apply_filters_deprecated to avoid conflict with wp profile 2019-01-30 16:06:51 +00:00
class-wc-discounts.php Better error messages for when coupon are held in other transactions. 2020-12-16 15:19:40 +05:30
class-wc-download-handler.php Added since tag in new filters introduced in 4.5 2020-08-17 18:01:41 -03:00
class-wc-emails.php Revert "pass email object to header and footer templates" 2021-01-18 16:51:31 +05:30
class-wc-embed.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-form-handler.php Check if $product exists before using 2020-11-11 19:55:59 -03:00
class-wc-frontend-scripts.php Avoid/minimize wc-ajax requests when `geolocation_ajax` is enabled | #26973 2021-02-19 14:50:59 -08:00
class-wc-geo-ip.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-geolite-integration.php Added a deprecation to the old Geolite library wrapper class' public methods 2020-01-14 13:44:41 -08:00
class-wc-geolocation.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-https.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-install.php Merge pull request #28933 from Mindsize/wc-24581-holding-stock-minutes 2021-02-03 16:05:18 -06:00
class-wc-integrations.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-log-levels.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-logger.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-meta-data.php WC_Meta_Data | PHPDoc Fix (#20371) 2018-06-05 13:29:56 +01:00
class-wc-order-factory.php Removed/reverted more unnecessary changes. 2020-11-10 14:23:43 +05:30
class-wc-order-item-coupon.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-order-item-fee.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-order-item-meta.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-order-item-product.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-order-item-shipping.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-order-item-tax.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-order-item.php Removed/reverted more unnecessary changes. 2020-11-10 14:23:43 +05:30
class-wc-order-query.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-order-refund.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-order.php Fix typos in docs 2021-03-05 11:19:58 +02:00
class-wc-payment-gateways.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-payment-tokens.php Fix typos in comments 2021-01-22 17:13:49 +01:00
class-wc-post-data.php Fixed docblock of new hooks of 5.0 2021-01-18 13:44:15 -03:00
class-wc-post-types.php Update Products and Reports icons to use Dashicons instead of custom font 2021-02-12 10:37:23 -05:00
class-wc-privacy-background-process.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-privacy-erasers.php Updated the privacy-related strings as well. 2020-02-04 13:25:47 +01:00
class-wc-privacy-exporters.php Adds support for group_description for privacy exporters which was added in WP5.3 through WPCoreChangeset#45825 and WPCoreTracTicket#45491 2020-02-04 12:57:31 -08:00
class-wc-privacy.php Delay the registration of data exporters and erasers. 2020-10-23 19:02:10 +02:00
class-wc-product-attribute.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-product-download.php Fix tests 2021-02-16 16:19:55 +01:00
class-wc-product-external.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-product-factory.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-product-grouped.php Only use default message to avoid showing too much information to user 2019-07-19 15:37:10 -06:00
class-wc-product-query.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-product-simple.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-product-variable.php Merge pull request #27514 from helgatheviking/has_options 2020-10-27 09:48:26 -07:00
class-wc-product-variation.php Minor docblock grammar/typo/casing fixes 2020-10-23 17:27:39 +04:00
class-wc-query.php Fix price filtering when there are variations. 2021-02-05 16:34:42 +01:00
class-wc-rate-limiter.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-regenerate-images-request.php prevent regenerate image filter loop 2020-08-25 14:31:15 -03:00
class-wc-regenerate-images.php Improve choice of words 2020-08-25 18:03:03 -03:00
class-wc-register-wp-admin-settings.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-rest-authentication.php Introduce an experimental GraphQL API. 2021-03-19 10:24:31 +01:00
class-wc-rest-exception.php Fixed usage of package tag in REST API and templates 2020-09-17 11:56:08 -03:00
class-wc-session-handler.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-shipping-rate.php Correct function summaries in the WC_Shipping_Rate class 2021-02-12 12:12:27 -05:00
class-wc-shipping-zone.php Replace 'DIRECTORY_SEPARATOR' with '/' 2020-08-26 15:50:34 -05:00
class-wc-shipping-zones.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-shipping.php Invert “if” statement to reduce nesting 2020-12-11 08:23:22 +01:00
class-wc-shortcodes.php Revert "Load product category content with content-product-cat.php" 2020-11-23 20:52:27 -03:00
class-wc-structured-data.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-tax.php Merge pull request #27671 from mahmoudsaeed/master 2021-02-15 14:31:25 -03:00
class-wc-template-loader.php Map all possible taxonomy templates 2020-11-23 19:29:30 -03:00
class-wc-tracker.php Updates per feedback. 2021-02-25 15:19:27 -08:00
class-wc-validation.php Fixed Puerto Rico address localization 2020-12-01 16:24:58 -08:00
class-wc-webhook.php Add a 'NumberUtil' class with a 'round' method. 2020-10-01 11:08:51 +02:00
class-woocommerce.php Introduce an experimental GraphQL API. 2021-03-19 10:24:31 +01:00
wc-account-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-attribute-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-cart-functions.php Merge pull request #28064 from woocommerce/fix/27087 2020-10-29 17:55:02 -03:00
wc-conditional-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-core-functions.php Remove compatibility checks for major version. 2021-02-23 13:27:06 +01:00
wc-coupon-functions.php Fix docblock summary for wc_get_coupon_id_by_code 2020-08-22 22:20:12 +02:00
wc-deprecated-functions.php add/update correct deprecated notices on existing deprecations 2020-07-16 17:13:08 -03:00
wc-formatting-functions.php Merge pull request #28933 from Mindsize/wc-24581-holding-stock-minutes 2021-02-03 16:05:18 -06:00
wc-notice-functions.php remove duplicate apply_filter 2020-08-21 11:36:03 +03:00
wc-order-functions.php Merge pull request #28933 from Mindsize/wc-24581-holding-stock-minutes 2021-02-03 16:05:18 -06:00
wc-order-item-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-page-functions.php support overriding/customising password reset page title via `action`: 2020-10-14 09:50:36 +13:00
wc-product-functions.php change attibutes to attributes 2021-01-23 15:39:01 +03:30
wc-rest-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-stock-functions.php fix whitespace 2020-10-02 08:22:33 -05:00
wc-template-functions.php Merge pull request #29151 from woocommerce/hide_coupon_on_incomplete_checkout 2021-03-03 17:05:53 -03:00
wc-template-hooks.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-term-functions.php Refactor and moved filter to _wc_recount_terms function 2021-03-10 12:33:46 -08:00
wc-update-functions.php Addressed PR feedback. 2021-01-18 10:29:42 +05:30
wc-user-functions.php Merge pull request #27352 from juliquiron/fix/slow-wc-customer-get-operations 2020-12-14 09:43:04 +05:30
wc-webhook-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-widget-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00

README.md

WooCommerce includes files

This directory contains WooCommerce legacy code. Ideally, the code in this folder should only get the minimum required changes for bug fixing, and any new code should go in the src directory instead.

Interacting with the src folder

Whenever you need to get an instance of a class from the src directory, please don't instantiate it directly, but instead use the container. To get an instance of the container itself you can use the wc_get_container function, for example:

$container = wc_get_container();
$service = $container->get( \Automattic\WooCommerce\TheNamespace\TheService::class );
$service->do_something();

The exception to this rule might be data-only classes that could be created the old way (using a plain new statement); but in general, all classes in the src directory are registered in the container and should be resolved using it.

Adding new actions and filters

Please take a look at the considerations for creation new hooks in src code, as they apply for includes code as well. The short version is that new hooks should be introduced only if they provide a valuable extension point for plugins, and not with the purpose of driving WooCommerce's internal logic.

Writing unit tests

As it's the case for the src folder, writing unit tests is generally mandatory if you are a WooCommerce team member or a contributor from another Automattic team, and encouraged if you are an external contributor. Tests should cover any new code (although as mentioned, adding new code in includes should be rare) and any modifications to existing code.

In order to make it easier to write unit tests, there are a couple of mechanisms in place that you can use:

  • The code hacker. Pros: you don't need to do any special changes to your code to make it testable. Cons: it's a hack, the tested code is being actually modified while being loaded by the PHP engine, so not an ideal solution.

  • The legacy proxy and the related helper methods in WC_Unit_Test_case: although these are intended in principle for writing tests for code in the src directory, they can be used for includes code as well. Pros: a clean approach, no hacks involved. Cons: you need to modify your code to use the proxy whenever you need to call a function or static method that makes the code difficult to test.

It's up to you as a contributor to decide which mechanism to use in each case. Choose wisely.