woocommerce/includes
Néstor Soriano de73ec027c
Merge pull request #26303 from netzstrategen/feature/prevent-unnecessary-available-variations-render
Allows avoiding performance bottlenecks caused by get_available_variation().
2020-07-27 08:46:24 +02:00
..
abstracts Remove wc_round_tax_total calls because lines would have already been rounded appropriately before reaching here. 2020-07-24 19:12:24 +05:30
admin Merge branch 'master' into fix/25843 2020-07-24 17:04:28 -03:00
cli Removed the default `id` field added to all CLI commands 2020-07-10 14:16:30 -07:00
customizer remove privacy page dropdown 2020-06-18 10:40:17 -03:00
data-stores Merge pull request #26565 from woocommerce/fix/26510 2020-07-01 12:42:18 -03:00
emails Merge pull request #25630 from woocommerce/fix-25603 2020-05-11 19:43:08 -07:00
export [Importer/Exporter] Fix "Published" column values 2020-07-15 21:45:51 -03:00
gateways Extend BACS accounts filter with order ID 2020-07-06 13:36:24 +02:00
import [Importer/Exporter] Fix "Published" column values 2020-07-15 21:45:51 -03:00
integrations/maxmind-geolocation Use urlencode 2020-03-05 11:54:41 -03:00
interfaces get_total_refunded should return a float 2019-04-21 21:36:31 +02:00
legacy Renamed `WC_Cart::is_tax_displayed()` to `WC_Cart::get_tax_price_display_mode()` to clarify intent 2020-07-13 07:21:19 -07:00
libraries Don't echo error when doing AJAX because it invalidates JSON 2020-03-17 16:49:52 +05:30
log-handlers Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
payment-tokens Fix wrong context help for translators 2020-01-26 17:55:17 +01:00
queue Changes in the overall organization of the dependency injection: 2020-07-24 09:23:01 +02:00
shipping Tweak explanation for coupon discounts 2020-04-24 15:47:02 +02:00
shortcodes Revert "Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout"" 2020-06-05 15:18:01 +05:30
theme-support Replaced direct access of many constants with the Constants library 2020-01-31 22:18:47 -08:00
tracks [Tracker] Added order_total to orders_edit_status_change 2020-07-01 18:24:47 -03:00
traits Use standard way to calculate total in `get_subtotal_to_display` for consistency. 2019-11-27 04:43:23 +05:30
walkers
wccom-site Change "products" argument type from array to object. 2020-03-10 17:41:39 +03:00
widgets Extracted the repetitive Constants::get_constant( 'WC_VERSION' ) calls where possible 2020-02-04 14:02:57 -08:00
README.md Add documentation about the container and good coding practices. 2020-07-24 09:25:12 +02:00
class-wc-ajax.php Merge pull request #26642 from woocommerce/fix/26607 2020-07-24 13:23:53 +02:00
class-wc-api.php Update version/path getters 2019-06-21 20:00:03 +01:00
class-wc-auth.php
class-wc-autoloader.php Added the WC Admin enabled db update notice. 2020-02-23 21:59:03 +01:00
class-wc-background-emailer.php Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
class-wc-background-updater.php Switch to action scheduler 2019-02-28 11:11:08 +00:00
class-wc-breadcrumb.php Allow extension of WC_Breadcrumb class 2019-03-17 02:43:00 -04:00
class-wc-cache-helper.php add Google weblight user agent check 2020-06-24 14:26:25 -03:00
class-wc-cart-fees.php Introduced woocommerce_sort_fees_callback filter 2019-07-31 18:31:49 -03:00
class-wc-cart-session.php Replace wc_get_page_permalink( 'cart' ) with wc_get_cart_url() 2019-08-29 08:43:42 +01:00
class-wc-cart-totals.php Use round_item_subtotal for shipping because shipping prices never include taxes so no need to wc_round_tax_total. 2020-07-24 19:12:25 +05:30
class-wc-cart.php Do not use `wc_round_tax_total` in shipping tax for accuracy. 2020-07-24 19:12:25 +05:30
class-wc-checkout.php Undo the registration of old singletons in the DI container. 2020-07-24 09:20:24 +02:00
class-wc-cli.php
class-wc-comments.php Update saving of comment_type for product reviews to account for WP 5.5 default comment_type 2020-06-08 17:36:34 -05:00
class-wc-countries.php Merge pull request #26697 from passatgt/master 2020-07-01 12:55:50 -03:00
class-wc-coupon.php Improve coupon name output handling. 2020-02-26 12:24:04 +01:00
class-wc-customer-download-log.php
class-wc-customer-download.php Consistent CRUD classes with before/after save hooks 2019-04-17 12:47:35 +01:00
class-wc-customer.php #23596 - I have solve this issue. 2019-05-06 11:43:56 +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
class-wc-deprecated-action-hooks.php
class-wc-deprecated-filter-hooks.php
class-wc-discounts.php Added a check to prevent coupon cent remainders from decreasing the item cost below zero 2020-03-16 21:32:25 -07:00
class-wc-download-handler.php Fallback to force for remote file because xsendfile don;t support it by default 2020-02-07 17:54:54 +05:30
class-wc-emails.php Revert a couple of files to its original content after a messed rebase 2020-07-24 09:20:24 +02:00
class-wc-embed.php
class-wc-form-handler.php Merge pull request #26237 from woocommerce/fix/24000 2020-06-11 13:13:12 +02:00
class-wc-frontend-scripts.php Extracted the repetitive Constants::get_constant( 'WC_VERSION' ) calls where possible 2020-02-04 14:02:57 -08:00
class-wc-geo-ip.php
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 conditional code 2020-01-14 16:44:01 -03:00
class-wc-https.php
class-wc-install.php Shorten class and method names to reduce redundancy in naming. 2020-07-15 15:20:18 +05:30
class-wc-integrations.php Fixed missing methods, added deprecated notices and @since 2020-01-10 11:58:53 -03:00
class-wc-log-levels.php
class-wc-logger.php Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
class-wc-meta-data.php
class-wc-order-factory.php Removed variable and set exception paramater to array containing the order id. 2019-11-20 22:52:04 -06:00
class-wc-order-item-coupon.php Use wc_format_coupon_code when handling posted values 2019-03-06 11:44:27 +00:00
class-wc-order-item-fee.php
class-wc-order-item-meta.php
class-wc-order-item-product.php Check if order exists before create downloads hash 2019-08-12 12:18:35 -03:00
class-wc-order-item-shipping.php
class-wc-order-item-tax.php default tax rate percent to null 2019-07-11 15:56:28 +02:00
class-wc-order-item.php Updated outdated codex URLs 2019-06-12 19:31:01 -03:00
class-wc-order-query.php
class-wc-order-refund.php
class-wc-order.php Merge pull request #26846 from woocommerce/add/new_order_note_action 2020-07-01 12:56:55 -03:00
class-wc-payment-gateways.php Undo the registration of old singletons in the DI container. 2020-07-24 09:20:24 +02:00
class-wc-payment-tokens.php Fixed method name 2019-10-01 12:30:29 -03:00
class-wc-post-data.php Deprecated old cache function and replaced it with a new one. 2019-11-28 14:03:57 +01:00
class-wc-post-types.php Merge pull request #26877 from woocommerce/fix/26547 2020-07-08 12:08:29 -03:00
class-wc-privacy-background-process.php
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
class-wc-product-download.php Fix WordPress.Arrays.MultipleStatementAlignment errors automatically using phpcbf 2019-12-20 13:51:26 -03:00
class-wc-product-external.php Only use default message to avoid showing too much information to user 2019-07-19 15:37:10 -06:00
class-wc-product-factory.php
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
class-wc-product-simple.php Add 404 check when creating add to cart url for single products. 2019-10-09 12:44:47 +02:00
class-wc-product-variable.php Merge pull request #26303 from netzstrategen/feature/prevent-unnecessary-available-variations-render 2020-07-27 08:46:24 +02:00
class-wc-product-variation.php Only use default message to avoid showing too much information to user 2019-07-19 15:37:10 -06:00
class-wc-query.php add rating count to order by rating clause 2020-07-06 11:19:17 -03:00
class-wc-rate-limiter.php Fix Generic.Formatting.MultipleStatementAlignment violations 2019-12-20 14:21:08 -03:00
class-wc-regenerate-images-request.php
class-wc-regenerate-images.php combine check 2019-03-18 10:59:43 +00:00
class-wc-register-wp-admin-settings.php
class-wc-rest-authentication.php Move authentication to WCCOM Site API to wccom-site main class. 2019-07-15 21:59:48 +07:00
class-wc-rest-exception.php Moved auth and exception classes to main includes directory - these are shared between legacy and new API. The package may replace these in the future. 2019-06-19 11:52:50 +01:00
class-wc-session-handler.php Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
class-wc-shipping-rate.php
class-wc-shipping-zone.php Switched conditon by accident 2019-04-17 12:57:02 +01:00
class-wc-shipping-zones.php Fix Generic.Formatting.MultipleStatementAlignment violations 2019-12-20 14:21:08 -03:00
class-wc-shipping.php Revert a couple of files to its original content after a messed rebase 2020-07-24 09:20:24 +02:00
class-wc-shortcodes.php Fix PEAR.Functions.FunctionCallSignature violations 2019-12-20 15:25:23 -03:00
class-wc-structured-data.php Added missing schema markup 2020-02-14 10:51:41 +02:00
class-wc-tax.php Pass $customer to woocommerce_match_rates hook. 2020-05-01 13:49:55 -07:00
class-wc-template-loader.php Validate page template 2020-04-29 17:53:04 +05:30
class-wc-tracker.php fix logic errors in get_blocks_from_page: 2020-04-07 10:23:03 +12:00
class-wc-validation.php Fixes for Hungarian address format and name order 2020-06-04 19:21:41 +02:00
class-wc-webhook.php Merge pull request #25183 from om4james/webhook-de-duplication 2020-02-05 18:38:15 +01:00
class-woocommerce.php Improevements on ExtendedContainer and LegacyProxy documentation. 2020-07-24 09:25:11 +02:00
wc-account-functions.php Address / Addresses strings in correct order for _n() 2020-05-07 20:57:30 -04:00
wc-attribute-functions.php Fix set cache loop when no attributes exist 2020-05-14 12:37:29 -05:00
wc-cart-functions.php Update min files and selectWoo 2020-06-16 17:15:12 +02:00
wc-conditional-functions.php Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
wc-core-functions.php Small changes after review feedback: 2020-07-24 09:24:06 +02:00
wc-coupon-functions.php
wc-deprecated-functions.php Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
wc-formatting-functions.php Merge pull request #26462 from db2000ro/fix/24885 2020-07-01 13:20:01 -03:00
wc-notice-functions.php Prevent empty notices to get added 2020-01-24 13:31:05 -03:00
wc-order-functions.php Allow custom values in wc_generate_order_key() 2020-05-20 17:41:22 -03:00
wc-order-item-functions.php Deprecated old cache function and replaced it with a new one. 2019-11-28 14:03:57 +01: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 Merge branch 'master' into refactor/add-jetpack-constants 2020-02-04 14:36:35 -08:00
wc-rest-functions.php Fix PEAR.Functions.FunctionCallSignature violations 2019-12-20 15:25:23 -03:00
wc-stock-functions.php Merge pull request #26503 from Knyazevich/origin/fix/wc_update_product_stock_status-phpdoc 2020-07-01 13:21:21 -03:00
wc-template-functions.php Merge pull request #26554 from jeffreyscottfrench/Fix--select_country-default-value 2020-06-30 10:34:06 +02:00
wc-template-hooks.php Introduced wc_get_pay_buttons() function 2019-11-07 17:23:38 -03:00
wc-term-functions.php Simplify and modernize wc_walk_category_dropdown_tree() 2019-11-22 15:25:44 -03:00
wc-update-functions.php Add the wc_update_400_ prefix to db update routine 2020-03-10 09:27:30 -03:00
wc-user-functions.php Add login link for existing account 2020-06-22 09:57:28 -06:00
wc-webhook-functions.php Moved synchronous webhook execution into a shutdown function 2020-06-25 16:54:17 -07:00
wc-widget-functions.php

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.