woocommerce/includes
vedanshujain 31ad8d651a Refactor `read_meta` into filter_raw_data for better re-usability. 2020-09-14 15:27:56 +05:30
..
abstracts Refactor methods to break down into smaller units for re-usability. 2020-09-14 15:27:55 +05:30
admin Fix using tax classes with some non-ASCII characters 2020-09-08 16:00:56 -03:00
cli Fixed incorrect package tags 2020-08-05 17:49:10 -03:00
customizer Fix the error message shown for the max setting 2020-07-10 12:58:57 +01:00
data-stores Refactor `read_meta` into filter_raw_data for better re-usability. 2020-09-14 15:27:56 +05:30
emails Fixed package tag usage 2020-08-05 13:36:24 -03:00
export Fixed package tag usage 2020-08-05 13:36:24 -03:00
gateways Rename PayPal to PayPal Standard 2020-08-25 12:25:44 +10:00
import Fixed package tag usage 2020-08-05 13:36:24 -03:00
integrations/maxmind-geolocation Fixed package tag usage 2020-08-05 13:36:24 -03:00
interfaces Fixed package tag usage 2020-08-05 13:36:24 -03:00
legacy Fixed package tag usage 2020-08-05 13:36:24 -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 Fixed package tag usage 2020-08-05 13:36:24 -03:00
rest-api Also allow null for date-time for BW 2020-08-13 16:49:44 +05:30
shipping Fixed package tag usage 2020-08-05 13:36:24 -03:00
shortcodes Fixed $columns type in docblock 2020-08-21 12:55:28 -05:00
theme-support Fixed package tag usage 2020-08-05 13:36:24 -03:00
tracks Improve choice of words 2020-08-25 18:03:03 -03:00
traits Fixed package tag usage 2020-08-05 13:36:24 -03:00
walkers Fixed package tag usage 2020-08-05 13:36:24 -03: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 Add documentation about the container and good coding practices. 2020-07-24 09:25:12 +02:00
class-wc-ajax.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-api.php Merge pull request #27239 from woocommerce/fix/package-tag 2020-08-07 13:37:24 -03:00
class-wc-auth.php Fixed package tag usage 2020-08-05 13:36:24 -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 Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-cache-helper.php Fixed package tag usage 2020-08-05 13:36:24 -03: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 Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-cart.php Prevented zero from being considered empty when validating posted variation attributes 2020-09-09 11:29:31 -07:00
class-wc-checkout.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-cli.php
class-wc-comments.php Merge pull request #26928 from khosroblog/master 2020-08-14 13:40:01 -05:00
class-wc-countries.php Fixed coding standards 2020-07-20 18:08:02 -03:00
class-wc-coupon.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
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 Fixed package tag usage 2020-08-05 13:36:24 -03:00
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
class-wc-discounts.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
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 Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-embed.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-form-handler.php Merge pull request #27219 from woocommerce/fix/filter-quantity-in-add_to_cart_handler_grouped 2020-09-12 15:56:49 -03:00
class-wc-frontend-scripts.php Fixed package tag usage 2020-08-05 13:36:24 -03: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 Improve the query to retrieve "Any..."-attributed variations in filtering widget 2020-09-01 16:47:41 +02: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
class-wc-order-factory.php Add support for fetching order using a hydration object. 2020-09-14 15:27:56 +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 Support for order_item to be init from obj with `order_item_id` prop. 2020-09-14 15:27:56 +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 Add support to prime refund cache in wc_order class. 2020-09-14 15:27:56 +05:30
class-wc-payment-gateways.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-payment-tokens.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-post-data.php Merge pull request #27239 from woocommerce/fix/package-tag 2020-08-07 13:37:24 -03:00
class-wc-post-types.php Fix #27436 2020-08-22 17:22:45 +12: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 Update Suggested Privacy Policy text to utilize css class instead of as it was deprecated. Also wrap the contents in the div to style the section to match WordPress. This follows from WPCoreTrac#49282 and although back-compat is being introduced in WP5.4 as of WPChangeset#47112 this change will better support users of WP5.1-5.4 2020-02-04 13:24:55 -08:00
class-wc-product-attribute.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-product-download.php Fixed package tag usage 2020-08-05 13:36:24 -03: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 Revert improved filtering for variations. 2020-09-09 17:36:26 +02:00
class-wc-product-variation.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-query.php Reintroduce adjust_posts_count, and remove unnecessary comment. 2020-09-10 15:17:43 +02:00
class-wc-rate-limiter.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-regenerate-images-request.php Fixed package tag usage 2020-08-05 13:36:24 -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 Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-rest-exception.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-session-handler.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-shipping-rate.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-shipping-zone.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-shipping-zones.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-shipping.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-shortcodes.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-structured-data.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-tax.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-template-loader.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-tracker.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-wc-validation.php Merge pull request #27059 from masteradhoc/masteradhoc-postcode-liechtenstein 2020-08-14 15:40:30 -03:00
class-wc-webhook.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
class-woocommerce.php Prepare master for 4.6.0 development 2020-09-11 14:07:58 -03: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 Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-conditional-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-core-functions.php Merge pull request #27508 from woocommerce/fix/27419 2020-09-02 13:32:54 -05: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 #27239 from woocommerce/fix/package-tag 2020-08-07 13:37:24 -03:00
wc-notice-functions.php remove duplicate apply_filter 2020-08-21 11:36:03 +03:00
wc-order-functions.php Add support to use `cache_hydration` in wc_get_order. 2020-09-14 15:27:56 +05:30
wc-order-item-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-page-functions.php Make wc_get_endpoint_url() compatible with WordPress use_trailing_slashes settings 2019-07-31 20:57:55 -03:00
wc-product-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-rest-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-stock-functions.php Merge pull request #27239 from woocommerce/fix/package-tag 2020-08-07 13:37:24 -03:00
wc-template-functions.php Encapsulate scope of `c` variable 2020-09-08 09:20:18 +02:00
wc-template-hooks.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-term-functions.php Fixed package tag usage 2020-08-05 13:36:24 -03:00
wc-update-functions.php Improve the query to retrieve "Any..."-attributed variations in filtering widget 2020-09-01 16:47:41 +02:00
wc-user-functions.php Improve choice of words 2020-08-25 18:03:03 -03:00
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.