Commit Graph

130 Commits

Author SHA1 Message Date
Christopher Allford 070954c888 Revert #28187
The default functionality within the `ThemeSupport` class has an unintended
side-effect of breaking the existing default functionality within the
`wc_get_theme_support()` function. Since the default set in the support
class is prioritized over the one given to `ThemeSupport::get_option()`,
the WordPress options set in the Customizer are never used for images.
2021-05-21 12:10:15 -07:00
roykho 65bbb719b9
Clean up code and update version 2021-05-21 06:32:29 -07:00
Roy Ho 20a73762c5
Update src/Internal/RestockRefundedItemsAdjuster.php
Co-authored-by: Vedanshu Jain <vedanshu.jain.2012@gmail.com>
2021-05-20 13:14:42 -07:00
Roy Ho 41f44578c7
Update src/Internal/RestockRefundedItemsAdjuster.php
Co-authored-by: Vedanshu Jain <vedanshu.jain.2012@gmail.com>
2021-05-20 13:14:35 -07:00
roykho b808d9a24f
Fix merge conflicts 2021-05-11 08:53:03 -07:00
roykho 8c3e90b3ce
Initialize _restock_refunded_items meta on order update 2021-05-11 08:35:48 -07:00
Nestor Soriano eb2e67d17d
Make the debug tools page entries for attribute filtering hidden by default.
To show the entries the following needs to be run:

wc_get_container()
->get(\Automattic\WooCommerce\Internal\ProductAttributesLookup\LookupDataStore::class)
->show_feature();
2021-05-10 11:32:39 +02:00
Nestor Soriano cdc55bf846
Fix typos in comments 2021-05-07 09:16:45 +02:00
Nestor Soriano f53f959d03
Fix the usage of FakeQueue in DataRegeneratorTest.
Also update the doc comment of FakeQueue itself on how to use it.
2021-05-05 11:11:36 +02:00
Nestor Soriano c4e7074c70
Add unit tests for the DataRegenerator class 2021-05-04 16:15:16 +02:00
Nestor Soriano 4d13b0ca07
ExtendedContainer::replace now allows registering anonymous classes. 2021-05-04 16:14:34 +02:00
Nestor Soriano 42245ed92a
Add unit tests for LookupDataStore::update_data_for_product (variable products) 2021-05-03 11:14:33 +02:00
Nestor Soriano 467af94b1d
Add unit tests for LookupDataStore::update_data_for_product (simple products)
Also:

- Add the FakeQueue class
- Fix LookupDataStore, it was using a hardcoded "wp_" lookup table name
2021-04-30 12:10:25 +02:00
Nestor Soriano e58d26f377
Fix: using "current" on a possibly "false" value. 2021-04-29 16:46:41 +02:00
Nestor Soriano 44cf1648d5
DataRegenerator: show lookup table filling process in tools page.
The status is displayed in the disabled "Regenerate table" button
as follows: "Filling in progress (X)", where X is the number of
products processed so far.
2021-04-29 11:49:43 +02:00
Nestor Soriano eb7fb42888
Add a new debug tools page entry to delete the lookup table.
Also, use $wpdb->prefix instead of hardcoded "wp_" for the table name.
2021-04-29 10:57:31 +02:00
Nestor Soriano 83fed1eab5
Implement the LookupDataStore::create_lookup_table_entries_for_variable_product method. 2021-04-28 16:57:47 +02:00
Nestor Soriano 94f5dfaa11
Make the DataRegenerator::delete_all_attributes_lookup_data method public. 2021-04-28 16:56:29 +02:00
Nestor Soriano 21053afec1
Partially implement LookupDataStore::update_data_for_product
For now it only creates data for non-variable products.
2021-04-28 12:25:56 +02:00
Nestor Soriano d1744ac99a
Add the ProductAttributesLookup\DataRegenerator class.
This class creates and fills the product attributes lookup table
from the existing products. It does so by in small chunks by using
Action Scheduler; it handles all the batches and the scheduling
by itself.

It also adds two entries to the debug tools menu:

- Initiate lookup table regeneration (deleting the existing table first)
- Enable or disable the actual usage of the lookup table
  for product filtering

The first one is the only way to generate the lookup table for now
(there's no explicit data migration).

The actual filling of the table is delegated to a LookupDataStore class
that is not implemented yet, so for now the table isn't actually filled.
Also enabling/disabling the lookup table usage has no real effect yet.
2021-04-28 10:30:11 +02:00
Nestor Soriano 10adec6b88
Improvements in the engine behind the debug tools page.
Two new optional keys have been added to the tool definition array:

- 'disabled': when true the tool button will appear disabled.
- 'needs_refresh': when running a tool, by default the tool definitions
  are retrieved first, then the selected tool is executed,
  then the definitions previously retrieved are rendered.
  When this key is true the tool definitions are retrieved again
  after execution, useful for cases where the tool description
  or button enable/disable state changes after the tool execution.

Also now if a tool execution throws an exception a notice will be
shown with the execption message, previously the exception
was unhandled.
2021-04-28 10:24:23 +02:00
Nestor Soriano 3a895c9eed
Move ThemeSupport class to Internal namespace, and use in 2021 theme. 2021-04-21 12:57:56 +02:00
Nestor Soriano d11a20b5b4
Merge branch 'trunk' into fix/25900-take-2 2021-04-20 16:08:45 +02:00
roykho 78a57e53ec
Update to use closure per review comment 2021-04-20 06:17:50 -07:00
roykho c73ce8ea04
Convert to using internal DI container 2021-04-16 12:23:40 -07:00
Claudio Sanches d6e3cf6de9 Update default GIT branch 2021-02-25 20:51:14 -03:00
Nestor Soriano 9ef18fea0e Change the calculate_refund_amount_from_line_items method
to return the calculated amount instead of setting it in the request.
2021-02-16 15:44:51 +01:00
Nestor Soriano fae00e2bdf Make the refunds creation REST API behave more as documented
- Allow the list of line items to be a non-associative array
  where each item is identified by an "id" field
- Same for taxes inside line items, specify amount to refund in
  a "refund_total" key as in the case of line items
- Allow "quantity" keys as synonyms of "qty"

Also calculate "amount" automatically if missing and when all the
line items and taxes have a valid "refund_total" key.
2021-02-11 09:51:13 +01:00
Nestor Soriano 2c957d2531 Merge branch 'master' into fix/25900-take-2 2021-01-29 10:00:51 +01:00
Fernando Marichal a3471b47d6 Fixed method adjust_download_permissions
This commit fixes the method "adjust_download_permissions" since we're getting an error if the received product id is not valid.
2021-01-27 13:25:06 -03:00
Claudio Sanches bf7fe82da4 Fixed woocommerce_activated_plugin docblock 2021-01-18 17:37:42 -03:00
Claudio Sanches e9abfa1669 Fixed docblock of new hooks of 5.0 2021-01-18 13:44:15 -03:00
Roy Ho 4c548951f4
Merge pull request #28521 from woocommerce/fix/26475
Create additional download permissions on product save if needed
2021-01-18 06:51:57 -08:00
Claudio Sanches d60ffa1e73
Merge pull request #28405 from szepeviktor/patch-5
Fix .gitignore
2021-01-15 11:19:37 -03:00
Nestor Soriano 8b0bd248d6 Attach hook for adjust_download_permissions from within init_hooks
The DownloadPermissionsAdjuster class hooks to adjust_download_permissions
from within its init method. However this method is executed only
if the class is resolved, otherwise the hooks doesn't get attached
and then the scheduled action is not serviced.

To solve this, the class is resolved from WooCommerce::init_hooks.
This requires a change in DownloadPermissionsAdjuster::init
to use wc_get_container()->get( LegacyProxy::class )->get_instance_of
instead of WC()->get_instance_of, since WC() can't be used from
WooCommerce::construct (which invokes init_hooks).
2021-01-14 11:40:11 +01:00
Nestor Soriano 2ec002defa Add unit tests for DownloadPermissionsAdjuster::adjust_download_permissions 2021-01-13 12:11:15 +01:00
Ilyas Foo 0e5596d1fc Transient and action passes plugin filename 2021-01-13 09:52:17 +08:00
Nestor Soriano 2d83db8b66 Add tests for DownloadPermissionsAdjuster::maybe_schedule_adjust_download_permissions
Also replace direct invocations of functions with usages of the
LegacyProxy whenever needed, and code style ajustments.
2021-01-12 12:07:38 +01:00
Nestor Soriano 10eb9f832e Remove one of the duplicate handlers for 'adjust_download_permissions' 2021-01-12 10:15:53 +01:00
Ilyas Foo 7f76d91b07 Delete transient before action to prevent race condition 2021-01-08 16:03:38 +08:00
Ilyas Foo d49783871a Update to signature compatible with activated_plugin hook 2021-01-01 12:24:04 +08:00
Ilyas Foo 0e590d1bdb Add transient and action for proxying WC plugin activation hook 2020-12-31 14:30:29 +08:00
Nestor Soriano f0b834d1ec Move the download permissions adjustment process to a scheduled action.
Also, move all the new code from the 'WC_Product_Data_Store_CPT' class
to a new separate 'DownloadPermissionsAdjuster' class.
2020-12-10 15:40:38 +01:00
Viktor Szépe 70e2a16c6f
Fix .gitignore 2020-11-25 06:48:13 +01:00
Christopher Allford c9f413d297 Created dummy `woocommerce/woocommerce-lib` package to contain dependencies
In order to avoid problems posed by potentially including the unconverted dependencies in the root autoloader, this package will hold all dependencies that require conflict avoidance.
2020-11-18 13:54:20 -08:00
Nestor Soriano 5509e2185c Add src/Internal/Vendor/League to source control. 2020-11-05 17:21:38 +01:00
Nestor Soriano 8bb0f196e6 Change the strategy for moving packages
Since the Mozart package requires PHP 7.2, and we need to support 7.0
and 7.1, the moving step has been removed from the composer install
stage. Instead, now it has to be triggered manually via
`composer run move-vendor-namespaces`, and the moved package must be
added to source control. See the updated src/Internal/Vendor/REAMDE.md
for details.
2020-11-05 17:19:14 +01:00
Nestor Soriano d620f1d232 Fix #25900 - image size customisation controls not shown
- Added the `ThemeSupport class`, with methods to add and get
  theme support options.
  - It also has a new `add_default_options` method that adds the
    options under a `_defaults` key.
- The `WC_Twenty_*` classes now use `ThemeSupport` instead of
  the `add_theme_support` function to define image and thumbnail sizes.
  - The values are defined as default options.
- The `WC_Shop_Customizer` class now uses `ThemeSupport` instead of
  `wc_get_theme_support` to check if image and thumbnail sizes UI
  should be rendered.
  - The check is made excluding default values.

With these changes the UI to change the image and thumbnail sizes
is hidden only if the options are added as non-defaults elsewhere.

Additional changes:

- The code of the `wc_get_theme_support` function is replaced with
  a simple call to `get_option` in `ThemeSupport`.
- Added the utility class `ArrayUtil`.
2020-11-04 13:01:53 +01:00
Nestor Soriano 96fce186e7 Use Mozart instead of a script to renamespace packages.
A custom fork of the coenjacobs/mozart package is now used to change
the namespace of the appropriate packages (only league/container
for now) instead of the previously used prefix-vendor-namespaces script.

The packages are now moved to the src/Internal/Vendor namespace instead
of being modified in-place in the vendor directory. The namespaces
are thus now prefixed with Automattic\WooCommerce\Internal\Vendor
(previously it was just Automattic\WooCommerce\Vendor).
2020-10-30 12:28:26 +01:00
Nestor Soriano 9aaee3dab9 Fix for compatibility of reflection function with PHP 7.0 2020-10-19 08:44:47 +02:00