Commit Graph

20538 Commits

Author SHA1 Message Date
Nestor Soriano 86c88f1750 Fix: incorrect adjustment of post count in WC_Query.
PR #26260 introduced a handler for 'found_posts' filter in WC_Query
class in order to adjust the count depending on the visibility
of variation products. However the handler incorrectly assumed
that the filter was triggered only when listing products, when
actually it's also triggered for any post type e.g. pages.
In these cases the post count was set to zero, which caused bugs.

Now the handler starts with the originally supplied posts count,
and only decrements it when a post is a product AND is not visible.
2020-07-30 09:32:28 +02:00
Claudio Sanches bb131ace69 Clean cache 2020-07-29 23:14:50 -03:00
Claudio Sanches 5b48191eac Batch update coupons 2020-07-29 23:07:00 -03:00
Claudio Sanches a464b7aeab Improved wc_get_current_admin_url()
- Replace "/wp-admin" with regex like on WP core.
- Remove "wc-hide-notice" from query args.
2020-07-29 21:01:39 -03:00
Christopher Allford 78bff3b2da Added the parent's SKU to product searches for variations
Since the parent's SKU is used when the variation does not have one, we should fall back when searching for consistency.
2020-07-29 16:53:36 -07:00
Claudio Sanches c9f52a45eb New wc_get_current_admin_url() function 2020-07-29 20:52:36 -03:00
Claudio Sanches e26076af7b Return to the current page after enabled or disabling db update notices 2020-07-29 20:37:27 -03:00
Claudio Sanches d498341f0e Added function to get current admin page 2020-07-29 20:37:12 -03:00
Claudio Sanches 97c7937fd9 Fixed "Product type" dropdown on WP 5.5
WP 5.5 doesn't introduce a <span> tag inside metaboxes headings
2020-07-29 19:12:02 -03:00
xristos3490 6485fc337c Add docblock param 2020-07-29 18:30:26 +03:00
xristos3490 4d4b9e3432 Filter found_posts only on wc_query context 2020-07-29 18:21:36 +03:00
Néstor Soriano d5bedd82b2
Merge pull request #27148 from woocommerce/fix/dont-request-translations-with-no-locales
Don't request empty locales list for plugin translations.
2020-07-29 16:23:06 +02:00
Néstor Soriano 0f134ca6a2
Merge pull request #27054 from woocommerce/fix/27036
add/update correct deprecated notices on existing deprecations
2020-07-29 15:20:24 +02:00
Joel Rowley 61abc7caab
Add dockblock to the woocommerce_file_download_method filter
Co-authored-by: Claudio Sanches <contato@claudiosanches.com>
2020-07-28 14:28:15 -04:00
Claudio Sanches 008e41170b Improved UX to highlight order data when there's some refund 2020-07-28 15:13:00 -03:00
Joel Rowley ae5bd1e14f Add file path to woocommerce_file_download_method filter 2020-07-28 13:52:21 -04:00
Claudio Sanches 119b5d6568
Merge branch 'master' into fix/23790 2020-07-28 13:07:17 -03:00
Claudio Sanches cc42af2f6e Fixed phpcs flag 2020-07-28 10:36:28 -03:00
budzanowski 57aeff0a71 Update comment. 2020-07-28 11:49:01 +02:00
budzanowski ac501dea64 Don't request empty locales list for plugin translations. 2020-07-28 11:37:51 +02:00
Nestor Soriano bc7085b3c4 Fixes after rebasing.
- Fix a call to get_available_variations with incorrect optional arguments.
- Add code that has been removed in WC_Product_Variable::get_available_variations.
2020-07-28 09:29:01 +02:00
Nestor Soriano 2283a4c7fd Revert woocommerce_product_loop to use have_posts instead of wc_get_loop_prop( 'total' ). 2020-07-28 09:01:55 +02:00
Nestor Soriano 681401850a Adjustments in the items count calculation on the nav filtering widget.
The calculations are now consistent with the change made to the
visibility of the variable products when using one or multiple filters.
2020-07-28 09:01:55 +02:00
Néstor Soriano e9d692f455 Apply suggestions from code review
Mostly adding "since 4.4.0" annotations and updating
db update functions from 4.2 to 4.4.

Co-authored-by: Claudio Sanches <contato@claudiosanches.com>
2020-07-28 09:01:55 +02:00
Nestor Soriano 29843b9396 Change in the logic of is_visible_core for variable products
Now, if there are filters present the logic is as follows:

- For multiple filtering values of the same attribute:
  the product is visible if there's at least one variation
  that has one of the filtering values associated to the attribute,
  or if there's at least one variation having the attribute
  with a value of "Any".

- For filtering by more than one attribute:
  the product is visible if there's at least one variation that
  is visible for ALL the attributes according to the above rule.

Note that this is irrespective of the type of logic configured for
the filter (OR or AND).
2020-07-28 09:01:52 +02:00
Nestor Soriano 3fefe84a51 Fix: WC_Query()::adjust_posts_count failing when posts list is null. 2020-07-28 08:55:55 +02:00
Nestor Soriano c074f085cc Remove two phpcs:ignores, improve code instead 2020-07-28 08:55:55 +02:00
Nestor Soriano 9142e27a19 Adjustments in WC_Query::adjust_posts_count
Two adjustments were needed:

- Adjust the count even when there's no nav filtering in the query.
  This is necessary to present the proper products count.
  even when the woocommerce_product_is_visible filter is used.
- Account for the case where $GLOBALS['wp_query']->posts
  returns objects instead of ids (for example when viewing
  a product page).
2020-07-28 08:55:55 +02:00
Nestor Soriano 9de1306c21 Fix counters in nav filtering widgets for variable products.
After the change that registers variation attributes as terms
(in addition to reigstering them as post meta) it is now time
to modify the get_filtered_term_product_counts methods in
WC_Widget_Layered_Nav so that it works consistently for both
variable and non-variable products. The logic for the counters
is now as follows:

with OR operator:
- Simple products: count the attributes of all visible products
  (unchanged behavior).
- Variable products: count attributes corresponding to
  visible variations.

with AND operator:
- Simple products: count the attributes of visible products but only
  for products that have all the selected (unchanged behavior).
- Variable products: find all the products for which all the variations
  corresponding to the selected attributes exist and are visible,
  then count the attributes corresponding to the visible variations
  of those products.

A product is "visible" if it's published, not excluded for catalog,
and has stock. Additionally, a variable product will not be considered
visible if the parent product is not.
2020-07-28 08:55:55 +02:00
Nestor Soriano 9c6c0d73d8 Record attribute terms for product variations in wp_term_relationships.
Product attributes are currently recorded as terms in
wp_term_relationships (product attributes are actually taxonomies).
In the case of variable products this is true for the main product,
but not for the variations. The attributes used to define variations
are stored as post meta, but nothing is recorded in the term
relationships table.

This is a problem when using the layered nav filtering plugin,
since the attribute counters displayed are calculated based solely
on the contents of the term relationships table. Adding meta queries
would be really messy (especially when the widget is configured
with AND operator) and would probably also hurt performance.

This commit adds a change to store the attributes for variations
as term relationships, additionally to storing them as post meta.
Terms are stored on variation creation, and updated/deleted together
with the variation as appropriate. "Any" variations (stored in meta
as empty values) are not stored as terms.

Additionally, a database upgrade is included in order to backfill
terms for already existing products.
2020-07-28 08:55:55 +02:00
Nestor Soriano 752b47513d Fix code sniffer errors in some files.
Fixed files:

includes/data-stores/class-wc-product-variable-data-store-cpt.php
includes/wc-update-functions.php
2020-07-28 08:55:55 +02:00
Nestor Soriano 50e8f27bc7 Fix visibility of variable products with layered nav filtering.
The layered nav filtering doesn't work well with variable products
when some variations have stock and other don't. When a term is
selected in the widget, a variable product having no stock for
the variation corresponding to that term but having stock for
other variations will be displayed, but it shouldn't.

This commit fixes that by introducing two changes:

- A new override of "is_visible" for WC_Product_Variable that
  looks at the supplied filters, compares them against the corresponding
  available variations and calculates the visibility based on
  the query type (OR or AND).

- A hook on the "found_posts" filter in WC_Query, that adjusts
  the posts count based on the found products visibility
  when there are filters available; this is needed to sync the
  "displaying X posts" messages and the paging when variable
  products are hidden due to stock status.

Additionally, the visibility calculated in "found_posts" is cached
as loop variables so that it isn't calculated again when actually
displaying the products.
2020-07-28 08:55:52 +02:00
Nestor Soriano c27283dffe Fix code sniffer errors in some files.
Fixed files:

includes/abstracts/abstract-wc-product.php
includes/class-wc-query.php
includes/wc-template-functions.php
includes/widgets/class-wc-widget-layered-nav.php
templates/loop/result-count.php
tests/unit-tests/util/class-wc-tests-wc-query.php
2020-07-28 08:47:29 +02:00
Claudio Sanches 2df7324b0d Fixed "virtual" and "downloadable" checkboxes pointers 2020-07-27 22:43:04 -03:00
Claudio Sanches 283c82b6b4 Fixed coding standards 2020-07-27 22:42:15 -03:00
Claudio Sanches 08620cf846 Make "woocommerce_shipping_cost_requires_address" strict 2020-07-27 21:49:33 -03:00
Claudio Sanches 134ab5c184 Fixed coding standards 2020-07-27 20:21:41 -03:00
Claudio Sanches 4f90307e2e Fixed "Paid By Customer" data when the orders contains refunds 2020-07-27 20:18:33 -03:00
Andy Skelton 3e5ce05d86
Faster foreign key check when installing/upgrading
Using WooCommerce on a multisite network using the hyperdb drop-in, the foreign key check fails although there is a foreign key.

32037e37dd/includes/class-wc-install.php (L745-L763)

The first problem is that hyperdb wasn't designed to route `information_schema` queries. After patching hyperdb, the query is routed to the correct database.

The second problem is that the query still finds zero foreign keys because `$wpdb->dbname` is blank when the query is generated. Hyperdb only has a dbname in the context of a query being executed; hyperdb extracts the table name, then maps that to the correct database.

Although we could find a way to support such `information_schema` queries, they are also not preferred because they are notoriously slow. On WordPress.com they take 300ms, versus 3ms for a `SHOW CREATE TABLE` which similarly reveals the existence of the foreign key.

The proposed changes simplify the check, make it faster, and make it work with hyperdb.
2020-07-27 16:39:42 -05:00
Claudio Sanches e94196cea8 Sanitize coupon code in coupon ID by code functions 2020-07-27 17:33:15 -03:00
Claudio Sanches be106af910 Added upgrade routine to sanitize all coupon codes 2020-07-27 16:50:23 -03:00
Ron Rennick d8edcb4551 update from review feedback 2020-07-27 16:48:39 -03:00
Claudio Sanches 6ee47b0356 Prevent breakage if coupons code get updated while there's some cart sessions 2020-07-27 16:48:15 -03:00
Christopher Allford c84f2b987b
Merge pull request #26750 from woocommerce/implement/core-language-packs-updates
Add language packs automatic delivery code.
2020-07-27 12:45:58 -07:00
Claudio Sanches 42321924f0 Update the coupon code sanitization
This makes match with WP sanitization for post_title.
WP sanitize post_title using kses_init_filters() when
the current user can't use unfiltered HTML.
2020-07-27 16:45:15 -03:00
Claudio Sanches d073b9d1e3 Always run wp_filter_kses() on coupon codes.
By default it only get sanitized when editing the coupon with an user
that doesn't have unfiltered_html capability.
2020-07-27 16:42:00 -03:00
Matt Harrison 9f8be6e2d8
Switch to use WordPress' shutdown action instead of register_shutdown_function 2020-07-27 12:11:40 -04:00
Matt Harrison e696ac7824
Queue all webhooks on shutdown.
It is possible for a later duplicate webhook to be fired too early if
the same webhook triggers in one request more than once with the updated
changes from the second one missing if it happens too quickly.
This queues all webhook to be register on shutdown instead of just
syncronous ones to make sure all data from the request is updated first
before the webhook gets queued.
2020-07-27 12:11:40 -04:00
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
Claudio Sanches 7bd34e3545
Merge branch 'master' into fix/25843 2020-07-24 17:04:28 -03:00
Ron Rennick 3c6cff4b1c
Merge pull request #26961 from LeGaS/patch-1
Extend BACS accounts filter with order ID
2020-07-24 16:27:57 -03:00
vedanshujain cd09e91817 Applied coding standards 2020-07-24 19:12:25 +05:30
vedanshujain fc6ae313e3 Do not use `wc_round_tax_total` in shipping tax for accuracy.
`wc_round_tax_total` is for when prices are inclusive of taxes, however, shipping taxes can never include taxes so they should always use `round( $price, wc_price_get_decimals() )` instead.
2020-07-24 19:12:25 +05:30
vedanshujain a413952784 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
vedanshujain 57c105a3fe 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
vedanshujain 853539df12 Remove wc_round_tax_total from shipping item because shipping price are never inclusive of taxes 2020-07-24 19:12:24 +05:30
vedanshujain 541d9ca483 Remove individual rounding because lines would have already rounded.
When rounding at subtotal is enabled, line items are already rounded where they need to, so we only should do any further rounding when displaying values and no where else.

This is part of our larger attempt to remove individual rounding as much as possible.
2020-07-24 19:09:59 +05:30
Néstor Soriano 8c2412ea7d
Merge pull request #26731 from woocommerce/feature/introduce-dependency-injection
Introduce a dependency injection framework
2020-07-24 15:12:16 +02:00
Peter Fabian 03230ecf01
Merge pull request #26642 from woocommerce/fix/26607
Limit stock changes for order items to status methods for consistency.
2020-07-24 13:23:53 +02:00
Nestor Soriano e55ef052a2 Add documentation about the container and good coding practices.
- src/README.md largely expanded
- tests/README.md expanded
- includes/README.md added
- src/Internal/REAMDE.md added

src/README.md and includes/README.md have TODO placeholders to add
guidelines regarding to actions and filters.
2020-07-24 09:25:12 +02:00
Nestor Soriano 71462e33f3 Improevements on ExtendedContainer and LegacyProxy documentation.
Also, remove a not really needed `try` block in LegacyProxy::get_instance_of.
2020-07-24 09:25:11 +02:00
Nestor Soriano 6fd84a0401 Add shortcut methods for the LegacyProxy in the WooCommerce class.
The following methods are added and can be invoked using `WC()`,
they just redirect to the same methods in LegacyProxy:

call_function
call_static
get_instance_of
2020-07-24 09:25:11 +02:00
Nestor Soriano 29cf161415 Small changes after review feedback:
- Method and class renames.
- Removed unnecessary autoloader registration.
- Add a unit test for classes with non-object type hints
  in constructor arguments.
2020-07-24 09:24:06 +02:00
Nestor Soriano d5d02a7175 Fix code sniffer errors in wc-core-functions.php 2020-07-24 09:23:05 +02:00
Nestor Soriano 064ae558ab Changes in the overall organization of the dependency injection:
- The `Container` class now implements `Psr\Container\ContainerInterface`
  (and registers itself as such), holding a private instance of the
  real container. This way it's a read-only container from the point
  of view of plugins (which should use their own containers, but
  can still use this to get WooCommerce classes).
- All registrations are now done in the `Container` constructor via
  service providers.
- The container instance is now held in a global variable, set in
  `woocommerce.php`
- Added the `wc_get_container` function for old code.
- Added the `AbstractServiceProvider` class, which inherits with the
  corresponding League's class and adds some utility methods,
  most notably `add/shareWithAutoArguments`.
- Added the `ActionsProxy` and `LegacyProxy` classes, they are
  registered via a dedicated service provider.
- `WC_Queue_Interface` is no longer resolvable via the container
  (which is for classes inside `src` only).
- All the method names in the new classes have the format `fooBarFizz`
  to be PSR4 compliant, so the MethodNameInvalid error has been
  disabled in phpcs.xml for the `src` directory.
- Introduced the `@public` annotation for public API classes
  (classes that plugins can use and whose backwards compatibility
  we guarantee), applied to `ActionsProxy` and to `LegacyProxy` for now.
- Removed the hack for the autoloader as now it doesn't work anyway.
  For the changes in this branch to work, now WP_DEBUG must be false.
2020-07-24 09:23:01 +02:00
Nestor Soriano 23df8a4d17 Revert a couple of files to its original content after a messed rebase 2020-07-24 09:20:24 +02:00
Nestor Soriano a7829525eb Changes in the dependency injection container:
- Renamed from `ObjectContainer` to `Container`.
- It now inherits from PHP League's `Container`.
- It has now a `defineAsSharedAutowired` method.
- Initialization moved to the `WooCommerce::init_container` method.
- The static method for object resolution is now `WooCommerce::get_instance_of`.
2020-07-24 09:20:24 +02:00
Nestor Soriano 281ec18158 Undo the registration of old singletons in the DI container.
The container will in principle be used only to register classes
in the `src` directory.

Also, CustomerProvider class removed.
2020-07-24 09:20:24 +02:00
Nestor Soriano 312383ae47 First steps towards introducing a dependency injection framework.
- Add PHP League's Container package via Composer.
- Add an ObjectContainer class that encapsulates all the configuration
  and insulates the codebase from the concrete DI engine used.
- Add an improved ReflectionContainer class that will allow to
  register individual classes as singletons while autowiring.
- Use ObjectContainer to resolve the WooCommerce class, everything
  instantiated with "new" inside it, and all singletons that are
  usually obtained via WC() function.
- Introduce the CustomerProvider class.
- Introduce a service provider to resolve WC_Queue_Interface,
  this replaces the WC_Queue class.
- Mark as obsolete all the replaced "instance()" methods,
  and the entire WC_Queue class.
2020-07-24 09:20:21 +02:00
Claudio Sanches 64f4fb85e2 Move variation validation logic to add to cart 2020-07-23 19:10:42 -03:00
budzanowski 7bc30512a4 Remove extra tab. 2020-07-23 23:22:16 +02:00
budzanowski 623363ba50 Check for if new locale has language pack installed. 2020-07-23 22:52:59 +02:00
vedanshujain e1e5acfe1f Add 'includes/api/' from commit '880b82a0373b5b019294409b4d29f861b8964261'
git-subtree-dir: includes/api
git-subtree-mainline: 5a784bc1e4
git-subtree-split: 880b82a037
2020-07-23 00:34:46 +05:30
budzanowski 70c65f60f2 Don't process if there are no plugins to check. 2020-07-22 12:16:20 +02:00
budzanowski ed1a181eca Update api url. 2020-07-22 10:56:04 +02:00
budzanowski 2d8f308a08 Remove redundant check. 2020-07-21 18:41:34 +02:00
Claudio Sanches 133462d645
Update class-wc-cart.php 2020-07-21 13:13:10 -03:00
Claudio Sanches 7b7102c9de
Fixed typo 2020-07-21 13:12:39 -03:00
Claudio Sanches 85f81d0e0b
Add docblock 2020-07-21 13:10:43 -03:00
Claudio Sanches f758b2bb31
Fixed coding standards 2020-07-20 18:08:02 -03:00
Christopher Allford 840554d788
Merge pull request #27017 from woocommerce/fix/25480
Fixed the `shipping_zone_method` CLI command's instance_id parameter
2020-07-20 11:00:08 -07:00
Damir Ha 4c7a0f1580 Remove country label 2020-07-20 18:18:14 +02:00
budzanowski 0a10d64394 Update code to the new server setup. 2020-07-20 17:16:18 +02:00
Mike Dent 541f68363e Test code updated, with thanks to @ObliviousHarmony 2020-07-20 15:45:13 +01:00
Ron Rennick d3ab19b7cf eliminate internal use of deprecated functions
- remove deprecation of offsetGet as it is used throught abstract order
- eliminate use of offsetGet in unit tests, structured data, order functions
-
2020-07-17 17:14:26 -03:00
Brian 78b2141bf5
Update class-wc-countries.php 2020-07-17 13:39:26 +02:00
Brian e27fc1a8fe
Update class-wc-countries.php 2020-07-17 13:38:47 +02:00
Brian a1e0959e09
Update class-wc-countries.php 2020-07-17 13:37:56 +02:00
Damir Ha d37a82fec8 Add Locale info and Hide state 2020-07-17 13:04:20 +02:00
Brian bf92d07442
add postcode validation for liechtenstein
added the postcode validation for liechtenstein.
max. 4 digits
has to start with 94**
second * can only be a 8 or a 9
2020-07-17 11:50:51 +02:00
Brian 601c7263b8
hide state for liechtenstein
hide the state field for liechtenstein
2020-07-17 10:26:48 +02:00
Ron Rennick 5ee0eccb7b add/update correct deprecated notices on existing deprecations 2020-07-16 17:13:08 -03:00
Claudio Sanches 86311a9903
Merge pull request #27046 from woocommerce/fix/26860
[Importer/Exporter] Fixed the value display of "Published" for children of draft variable products
2020-07-16 13:15:31 -03:00
Ron Rennick dbf3e99292
Merge pull request #26964 from woocommerce/fix/24604
add rating count to order by rating clause
2020-07-16 10:51:20 -03:00
Damir Ha 9a5d920bdb Add postcode validation for Bosnia and Herzegovina 2020-07-16 13:52:01 +02:00
Néstor Soriano 24bd19c517
Merge pull request #27038 from woocommerce/add/26192
Add existing meta keys to woocommerce_duplicate_product_exclude_meta filter
2020-07-16 11:02:09 +02:00
Claudio Sanches 2947700029 Removed Features settings and home screen option 2020-07-15 22:58:51 -03:00
Claudio Sanches 37777432d4 [Importer/Exporter] Fix "Published" column values
While variations only uses "published" and "private" statuses when
exporting we should display the variations as "draft" in case the parent
product it's also a draft.
2020-07-15 21:45:51 -03:00
Vedanshu Jain a34835e489
Merge pull request #26932 from woocommerce/fix/25442
Show community forum link if wccom is not connected
2020-07-16 00:14:52 +05:30
vedanshujain 4500e86198 Shorten class and method names to reduce redundancy in naming. 2020-07-15 15:20:18 +05:30
Christopher Allford c9f754f5a3 Added the existing meta keys to the `woocommerce_duplicate_product_exclude_meta` filter 2020-07-14 13:57:21 -07:00
vedanshujain 1e68ce5dc9 Move function to src for better code architecture 2020-07-14 23:31:56 +05:30
Christopher Allford 9c492853b5
Merge pull request #26998 from woocommerce/fix/is-tax-displayed-private
Fixed the accessibility of WC_Cart::is_tax_displayed()
2020-07-14 09:05:19 -07:00
Nestor Soriano d2787818e3 Rename `quick-edit-warning` style with `wc-` prefix, and add styling. 2020-07-14 16:02:59 +02:00
Nestor Soriano c53d6daed1 Fix error when `screen` not set in request, remove redundand `round`s. 2020-07-14 11:42:22 +02:00
Nestor Soriano a39e15f92b Small adjustments in WC_Admin_Post_Types
- Remove no longer needed phpcs disablers.
- Rename method.
- Remove no longer needed logic.
- Simplify some logic.
2020-07-14 11:42:21 +02:00
Nestor Soriano fc0be07e0f Add unit test for WC_Admin_Post_Types::bulk_and_quick_edit_save_post.
The test added checks that the new regular or sale price is
appropriately set when bulk saving.
2020-07-14 11:42:21 +02:00
Nestor Soriano 4531af3382 Small fix in WC_Tests_Admin_Post_Types::bulk_and_quick_edit_stock_status_for_variable_product.
At some point the 'change_stock' key is assumed to be present
in the request data, but it might not. Fixed to test for existence
before using the value.
2020-07-14 11:42:21 +02:00
Nestor Soriano b71a9c33b6 Extract $_REQUEST to a method in WC_Admin_Post_Types.
Create a new `request_data` method in WC_Admin_Post_Types that
just returns $_REQUEST. This is intended to ease unit testing,
as this method can be easily mocked to return test data.
2020-07-14 11:42:21 +02:00
Nestor Soriano fd34cf76b2 Fix stock status setting for variable products on bulk & quick edits.
For bulk edit: even if stock status was left as "No change", the
status of all variations was being changed to whatever the status
of the product was before it was converted to variable. Now
no change is performed when "No change" is selected, and all
variations change to whatever is selected otherwise.

For quick edit: a new "No change" option is added that will be
preselected when the product is variable. Previously, whatever
status the product had before being converted to variable was being
shown, and that's the status that would be set when saving.
Also, a "This will change the stock status of all variations"
message is displayed before the selector.
2020-07-14 11:42:21 +02:00
Nestor Soriano ae0d269128 Refactor duplicate code & add rounding to price calculations in WC_Admin_Post_Types.
Two methods have been created:

- update_stock_status, replaces code that was duplicated in the
  quick_edit_save and bulk_edit_save methods.

- set_new_price, replaces code that was duplicated-ish in the
  bulk_edit_save for setting the new regular and sales prices
  (code was not identical but very similar).

Also, `round` is now used on sale price calculations that involve
multiplying by a percent, the same was as it was done already
to calculate the regular price.
2020-07-14 11:42:21 +02:00
Nestor Soriano 7d5b59953c Fix code sniffer errors in WC_Admin_Post_Types. 2020-07-14 11:42:21 +02:00
Christopher Allford 2ef15f02e3 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
Peter Fabian 23028a90a1 Schema has not been updated, so revert. 2020-07-13 15:34:54 +02:00
Mike Dent 53d9085c16 Fixed indent and incomplete test code. 2020-07-12 19:26:57 +01:00
Mike Dent cf9db99a9f "Hidden" field type added to woocommerce_form_field() #26468 2020-07-12 16:38:36 +01:00
Christopher Allford 933cdd7a7b Removed the default `id` field added to all CLI commands
Some of our endpoints don't have an "<id>" parameter but we're expecting one in the CLI. Since the `id` is already part of the supported IDs we don't actually need this since it will pull it from the route.
2020-07-10 14:16:30 -07:00
Christopher Allford c3618cad47 Added the `instance_id` parameter to the CLI runner
This is used for shipping zone methods and so we need to be able to parse it too!
2020-07-10 07:21:05 -07:00
azzy9 c6d31e5459
Fix the error message shown for the max setting
Fix the error message shown when the max setting for rows is shown. before it stated "The minimum allowed setting is 8" when it should be "The maximum allowed setting is 8"
2020-07-10 12:58:57 +01:00
Christopher Allford c2bf58a739 Fixed the accessibility of WC_Cart::is_tax_displayed()
Since we're calling the function from the base class we need it to be protected or this throws a fatal exception.
2020-07-09 13:39:16 -07:00
Peter Fabian 6bc0ca724f Update versions and changelog from latest releases. 2020-07-09 13:18:51 +02:00
Claudio Sanches 864f451775
Merge pull request #26338 from woocommerce/fix/25561
Fixed user cap required to view the order count indicator
2020-07-08 12:09:28 -03:00
Claudio Sanches eeb08467af
Merge pull request #26877 from woocommerce/fix/26547
Fixed WooCommerce menu for users that can only manage orders on WooCommerce
2020-07-08 12:08:29 -03:00
Jory Hogeveen cde1bd019b
Allow public access to get_core_capabilities()
Allow role manager plugins to get these capabilties
2020-07-08 13:44:27 +02:00
Ron Rennick 625857e9e1 add rating count to order by rating clause 2020-07-06 11:19:17 -03:00
Szabolcs Légrádi 5174baca35
Extend BACS accounts filter with order ID 2020-07-06 13:36:24 +02:00
Kevin Ruscoe 0a47926418
Update types
Fixed #26537
2020-07-05 13:39:26 +01:00
Claudio Sanches 85580cfb4f
Merge pull request #26935 from woocommerce/fix/26822
[Tracker] Added order_total to orders_edit_status_change
2020-07-02 16:29:13 -03:00
Néstor Soriano 7fa34c6770
Merge pull request #26400 from woocommerce/fix/26242
Make WC_Cart::display_prices_including_tax() aware of tax display changes
2020-07-02 14:56:50 +02:00
vedanshujain 50b08a75ab Show community forum link if wccom is not connected 2020-07-02 16:28:33 +05:30
Claudio Sanches 0d9b6786fd [Tracker] Added order_total to orders_edit_status_change 2020-07-01 18:24:47 -03:00
Claudio Sanches e20a69c35c Fixed missing comma 2020-07-01 17:56:19 -03:00
hadi khosrojerdi 1893fb755a Edit get_review_count_for_product method
Get review count for product from wp_comments db, where comment type is `review` not all.
2020-07-01 22:20:15 +04:30
Claudio Sanches a1eb697bd3
Merge pull request #26634 from corsonr/fix-26633
Fix #26633 - Adds Custom Messages Upon WC Taxonomies Update
2020-07-01 14:36:38 -03:00
Claudio Sanches 101a8ae243
Added context 2020-07-01 14:36:22 -03:00
Claudio Sanches f17535fabd
Merge pull request #26589 from mariovalney/fix/26588
Fixes issue #26588
2020-07-01 14:18:06 -03:00
Claudio Sanches 1de6bf0c28
Merge pull request #26515 from koko-ng/patch-1
Fix error message in wc_get_template
2020-07-01 13:27:05 -03:00
Claudio Sanches 1194225d71
Merge pull request #26503 from Knyazevich/origin/fix/wc_update_product_stock_status-phpdoc
Fix parameter type and add an empty line in wc_update_product_stock_s…
2020-07-01 13:21:21 -03:00
Claudio Sanches 0351aa546e
Merge pull request #26462 from db2000ro/fix/24885
Fix 24885 currency position RTL
2020-07-01 13:20:01 -03:00
Claudio Sanches fddaed2899
Merge pull request #26325 from twoelevenjay/master
Conditionally change my account dashboard desc
2020-07-01 13:13:22 -03:00
Claudio Sanches 4d2bafcc49
Merge pull request #26219 from woocommerce/fix/wc-load-cart
`wc_load_cart` should load it's own dependencies and include required core files
2020-07-01 13:10:04 -03:00
Claudio Sanches dec50429b4
Merge pull request #25240 from shamalisulakhe/issue-24266-solution
Issue 24266 solution - with rerf of
2020-07-01 13:00:58 -03:00
Claudio Sanches cadbc759fe
Merge pull request #26680 from MihaiCraciun/master
Added missing closing select tag to the product exporter category select
2020-07-01 12:57:33 -03:00
Claudio Sanches 950b2253cb
Merge pull request #26846 from woocommerce/add/new_order_note_action
Add `woocommerce_order_note_added` action
2020-07-01 12:56:55 -03:00
Claudio Sanches 9ac5bcb586
Merge pull request #26697 from passatgt/master
Fixes for Hungarian address format and name order
2020-07-01 12:55:50 -03:00
Claudio Sanches e736ac4145
Merge pull request #26837 from gamebits/patch-1
Add login link for existing account
2020-07-01 12:54:24 -03:00
Claudio Sanches 94d23605b8
Merge pull request #26658 from zackkatz/patch-1
Fix undefined index PHP warning
2020-07-01 12:48:13 -03:00
Claudio Sanches 2874915339
Merge pull request #26553 from szepeviktor/patch-2
Fix PHPDoc in WC_Notes_Run_Db_Update
2020-07-01 12:46:48 -03:00
Claudio Sanches 9c4ac29137
Merge pull request #26565 from woocommerce/fix/26510
Allow set "order key" while creating order via CRUD
2020-07-01 12:42:18 -03:00
Claudio Sanches 54f91a5a59
Merge pull request #26566 from woocommerce/update/26510-generate-order-key
Allow custom values in wc_generate_order_key()
2020-07-01 12:41:24 -03:00
Claudio Sanches cac529c393
Merge pull request #26567 from woocommerce/fix/26510-created-date
Allow set "date_created" while creating orders via CRUD
2020-07-01 12:40:43 -03:00
Claudio Sanches 4450d2239f
Merge pull request #26660 from woocommerce/add/status-tools-prompt
Adds a prompt to confirm if should run tools in the Status page.
2020-07-01 12:39:54 -03:00
Claudio Sanches f6cd453840
Merge pull request #26669 from woocommerce/fix/filter-params
Normalize parameters for woocommerce_product_importer_parsed_data filter
2020-07-01 12:39:17 -03:00
Claudio Sanches ab8a1b78a3
Merge pull request #26668 from woocommerce/fix/typo
Fixed typo in WC_Product_CSV_Importer class
2020-07-01 12:39:03 -03:00
Claudio Sanches 6fc008c104
Merge pull request #26698 from woocommerce/fix/26643
Puerto Rico: Remove "City" field and rename "State" to "Municipality"
2020-07-01 12:38:28 -03:00
Claudio Sanches 32a3d29bd9
Merge pull request #26798 from danielmorell/patch-1
Fixed wc_get_order function name in doc block
2020-07-01 12:37:06 -03:00
Claudio Sanches 7647a122ab
Merge pull request #26920 from alamgircsebd/fix/wrong-capabilites-use-on-add-order-note
Fix - wrong capabilities use on add order note issue fixed
2020-07-01 11:42:45 -03:00
vedanshujain 8ded6a3057 Applied coding standards 2020-07-01 19:09:50 +05:30
vedanshujain 1b3f1d75ba Limit stock changes for order items to status methods for consistency.
Methods `wc_maybe_increase_stock_levels` and `wc_maybe_reduce_stock_levels` already reduce/increase stock levels when statuses are changed, so no need to do this here.
2020-07-01 19:09:07 +05:30
Ron Rennick 84f5e61dbf
Merge pull request #26858 from woocommerce/fix/25833-2
add Google weblight user agent check
2020-07-01 09:31:35 -03:00
Alamgir 5cda3967ff Fix - wrong capabilites use on add order note issue fixed 2020-07-01 10:14:22 +06:00
Claudio Sanches c3608f3b57
Merge pull request #26878 from woocommerce/fix/26787
Moved synchronous webhook execution into a shutdown function
2020-06-30 16:34:12 -03:00
Claudio Sanches 0de1d4f9c0 Updated docblock 2020-06-30 13:32:11 -03:00
Claudio Sanches 54a94152ec Map all deprecated keys in __isset() 2020-06-30 13:25:30 -03:00
Claudio Sanches 701490b13e
Apply suggestions from code review
Co-authored-by: Néstor Soriano <nestor.soriano@automattic.com>
2020-06-30 13:05:56 -03:00
Peter Fabian 64bbb09eb2
Merge pull request #26518 from lipemat/patch-1
Fix set cache loop when no attributes exist
2020-06-30 12:03:37 +02:00
Néstor Soriano 3a77066262
Merge pull request #26554 from jeffreyscottfrench/Fix--select_country-default-value
Sets "Select a country / region..." option element's value attribute to default in checkout page.
2020-06-30 10:34:06 +02:00
Nestor Soriano 9aa3c54bd9 Fix variable product stock status not being properly set on save
When a product is saved its validate_props method is invoked,
and this recalculates the stock_status property based on whether
the product manages stock or not, the stock quantity, and the
value of the woocommerce_notify_no_stock_amount option.

In the case of variable products, and when stock is managed, the stock
was set to "instock" when the current stock was enough, but only
if the "stock_quantity" property was in the list of changed properties
for the object (the method in the base product class doen't check
for changed properties). This is a problem because the
wc_update_product_stock function updates stock_quantity but via direct
database modification, and thus stock_quantity isn't considered
modified. Therefore stock modifications via wc_update_product_stock
don't update stock_status on the product (e.g. when going from 0 to 1
after a refund the stock status will remain as "outofstock").

The fix consists of removing the check for changed properties since
it's not done anyway in the other cases (when stock is below the
woocommerce_notify_no_stock_amount threshold) nor in the base class.

Also, validate_props is refactored for readabiliyy, and an useless
set_stock_status() call placed right before save()
in wc_update_product_stock is removed.
2020-06-29 14:32:17 +02:00
Néstor Soriano 7b3e902952
Merge pull request #26629 from woocommerce/fix/25552
Schedule a deferred product sync for products with parent on delete.
2020-06-29 14:15:10 +02:00
James Collins 3a3cc35506
Fix for REST API requests where the authentication doesn't execute 2020-06-29 17:10:27 +08:00
budzanowski 114ce81757 Use singular batch update endpoint. 2020-06-26 11:09:41 +02:00
Fitim 963bbcfca3 [woocommerce_cart_has_enough_stock_for_product] Invert the logic, change hook name 2020-06-26 09:38:44 +02:00
Fitim 45c387e39c Merge remote-tracking branch 'upstream/master' 2020-06-26 09:21:21 +02:00
Christopher Allford 7331036d17 Moved synchronous webhook execution into a shutdown function
One of the problems with synchronous webhooks is that they are executed as soon as the related action is. Since we may call an action multiple times in the process of updating something, this causes only the first action to trigger the hook. This differs from asynchronous execution because in that case, the web hook will be executed after the entire request has completed.
2020-06-25 16:54:17 -07:00
Claudio Sanches 0757f711de Need to use edit_others_shop_orders also for coupons menu item 2020-06-25 20:34:28 -03:00
Claudio Sanches 8609500cc2 Check for the correct cap for shop_coupon 2020-06-25 20:31:06 -03:00
Claudio Sanches f5b9af8591 Keep WooCommerce menu structure if user can edit others shop orders 2020-06-25 20:01:12 -03:00
Ron Rennick ce70d6ad7a add Google weblight user agent check 2020-06-24 14:26:25 -03:00
Dan Bitzer 25fbe58872 Add order note action docblock 2020-06-24 09:35:46 +09:30
Claudio Sanches f4d11c89f3
Merge branch 'master' into issue-24266-solution 2020-06-23 16:47:30 -03:00
Ron Rennick aaae319a65 deprecate wc-setup 2020-06-23 15:29:58 -03:00
Ron Rennick e9f71ac24c
Merge pull request #26802 from woocommerce/fix/25833
introduce woocommerce_enable_nocache_headers filter
2020-06-23 13:35:13 -03:00
Ron Rennick e56ef185b0
Merge pull request #26809 from woocommerce/fix/25606
remove privacy page dropdown
2020-06-23 13:34:33 -03:00
Claudio Sanches 6890251b0e
Fixed typos and coding standards 2020-06-23 11:51:19 -03:00
Claudio Sanches 3bb7f30c01
Merge branch 'master' into fix/25561 2020-06-23 11:23:29 -03:00
Claudio Sanches f2299ecfa8
Fixed coding standards 2020-06-23 11:09:21 -03:00
Dan Bitzer 9cddd9ae18 Add `woocommerce_order_note_added` action
This action provides an easier way to perform an action when a non-customer order note is added.
2020-06-23 16:55:08 +09:30
Ken Gagne bc210d6db1
Add login link for existing account
When a logged-out user tries to check out with an email address associated with an existing account, they are prompted to log in. This PR updates that prompt with a link to the login form. Though other opportunities to log in should already exist elsewhere on the checkout page (such as `form-login.php`'s "Returning customer?" prompt), this change makes it more explicit and intuitive.
2020-06-22 09:57:28 -06:00
Ron Rennick 4a9fb66a39 update comment to accurate description 2020-06-18 10:56:31 -03:00
Ron Rennick a88a708286 remove privacy page dropdown 2020-06-18 10:40:17 -03:00
Ron Rennick 6743073a0f introduce woocommerce_enable_nocache_headers filter 2020-06-17 15:02:09 -03:00
Daniel Morell 94e317f9f8
Fixed wc_get_order function name
The WC_Abstract_Order __construct() method doc block had the wc_get_order() method referred to as get_order().
2020-06-17 10:49:40 -05:00
Ron Rennick 3763d3b428
Merge pull request #25982 from leewillis77/feature/add-label-to-taxonomies
Add label to unlabelled taxonomies
2020-06-17 10:54:50 -03:00
Peter Fabian 14a26aca2c Update min files and selectWoo 2020-06-16 17:15:12 +02:00
Peter Fabian 418d95298a Merge branch 'master' into update/wc-admin-1.3.0-beta-1
# Conflicts:
#	composer.lock
2020-06-16 14:58:43 +02:00
Peter Fabian 35ee21f837
Merge pull request #26754 from woocommerce/fix/25544
Encode HTML entities in product attributes
2020-06-16 14:29:19 +02:00
Peter Fabian bb2cf2e8dc Removed deprecated method call. 2020-06-16 13:18:05 +02:00
Peter Fabian ce740fdb44
Merge pull request #26739 from woocommerce/fix/24800
Export: properly escape commas in attribute values
2020-06-16 12:56:40 +02:00
Peter Fabian dc0d567137
Merge pull request #26775 from woocommerce/update/php7.2
Show notice to update to latest PHP if version is < 7.2
2020-06-16 12:56:15 +02:00
Peter Fabian c35c4f1f08
Merge pull request #26395 from woocommerce/revert-26226-revert-25708-update/reserve-stock-for-checkout
Introduce a `reserved stock` class and database table to prevent race conditions during checkout
2020-06-16 11:38:10 +02:00
Peter Fabian 32037e37dd
Merge pull request #26625 from woocommerce/add/homescreen-option
Homescreen: Enable for new stores and add Features Setting section
2020-06-15 21:54:06 +02:00
Peter Fabian 0c96b1452d
Merge pull request #26685 from woocommerce/fix/26248
Removed the notice for untested minor version updates
2020-06-15 21:40:22 +02:00
Vedanshu Jain 8dcb48219b
Merge pull request #26752 from woocommerce/fix/25143
Add template cache clearing
2020-06-15 23:47:24 +05:30
vedanshujain 513b517b5b Show notice to update to latest PHP if version is < 7.2 2020-06-15 21:51:03 +05:30
vedanshujain 34e5d3daa3 Use single sentence for easier translations. 2020-06-15 19:09:52 +05:30
vedanshujain b8a1a69b2b Updated annotations to 4.3 2020-06-15 18:55:00 +05:30
Paul Sealock c7ad889f93 Homescreen: add option and setting 2020-06-15 13:38:02 +12:00
budzanowski 8f4e1a90c1 Typo fix. 2020-06-14 11:38:57 +02:00
budzanowski bb7e5d1018 Connect the translations server. 2020-06-14 11:14:29 +02:00
jonathansadowski 386eecda62
Merge pull request #26729 from woocommerce/fix/26367
Update saving of comment_type for reviews to account for WP 5.5 changes
2020-06-12 10:36:28 -05:00
Vedanshu Jain 60ffc7ab99
Merge pull request #26583 from woocommerce/fix/26582
Fix regression caused by merging #25092 conflicting with #24828
2020-06-12 15:13:21 +05:30
Ron Rennick 4a8af2ec5d
Merge pull request #26706 from dorelidan/patch-1
Update wc-template-functions.php
2020-06-11 16:23:39 -03:00
Jonathan Sadowski 4d6aad4ecb Encode HTML entities in product attributes 2020-06-11 14:10:05 -05:00
Ron Rennick dd5cd361bc introduce wc_set_template_cache(), wc_clear_template_cache() 2020-06-11 14:06:56 -03:00
budzanowski 5277bf8b60 Add language packs automatic delivery code. 2020-06-11 14:31:55 +02:00
Peter Fabian 296112cbea
Merge pull request #26237 from woocommerce/fix/24000
Fix adding product variant to cart using `add-to-cart` parameter (#24000)
2020-06-11 13:13:12 +02:00
Peter Fabian 439562e854
Merge pull request #23971 from woocommerce/refactor/23783
Better template caching for container environments
2020-06-11 10:13:46 +02:00
Peter Viszt 4a60386560
Removed duplicated class from the HU city field 2020-06-10 17:54:12 +02:00
Jonathan Sadowski 5b232ff489 Export: properly escape commas in attribute values 2020-06-09 16:01:32 -05:00
Jonathan Sadowski f9731bb2ed 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
Julia Amosova 6d3ce36fb4
Merge pull request #26720 from woocommerce/fix/26665
Remove check for existing term when parsing category via CSV & instead catch an existing term error when adding new category to the database
2020-06-08 16:04:31 -04:00
Julia Amosova 7982efb3df Fix the @return description of the CSV Import categories parsing function 2020-06-08 15:03:00 -04:00
Julia Amosova ea17484e42 Remove check for existing term when parsing category & add better error handling 2020-06-07 20:59:23 -04:00
Claudio Sanches 5dc84e6d0f
Update includes/class-wc-countries.php
Co-authored-by: jonathansadowski <jonathansadowski@users.noreply.github.com>
2020-06-05 14:46:03 -03:00
Dor Elidan 4b6e56b02a
Update wc-template-functions.php 2020-06-05 18:22:34 +03:00
vedanshujain 79e13edff0 This commit adds two changes for reserved stock functionality:
1. Use '0000-00-00 00:00:00' instead of CURRENT_TIMESTAMP as default value to support MySQL 5.6
2. Return early if DB version is less than 430 because then it would mean that required wc_reserved_stock table might not be present.
2020-06-05 19:20:06 +05:30
Claudio Sanches a240547fda Puerto Rico: Make city hidden and change state to Municipality 2020-06-05 10:14:52 -03:00
vedanshujain e00f79417f Alert in status report if base table is not present.
Also add a tool to rerun the check. This needs newer API version to work.
2020-06-05 18:26:49 +05:30
Vedanshu Jain b45373fe0c Revert "Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout"" 2020-06-05 15:18:01 +05:30
Vedanshu Jain 6564847802
Merge pull request #26454 from woocommerce/enhancement/verify-db
Add `verify_base_db` method to check if all base tables are present.
2020-06-05 15:15:39 +05:30
Claudio Sanches 418896ea86 Removed States from Puerto Rico and better address formatting 2020-06-04 17:18:17 -03:00
Viszt Péter 1724507a0e Fixes for Hungarian address format and name order
Missing address-field class for Japan's postcode and state field
Checkout layout fixes on country change
2020-06-04 19:21:41 +02:00
vedanshujain e0de059f23 Use seperate db version to better track changes 2020-06-04 22:38:13 +05:30
vedanshujain 4fce106f14 Use `_` instead of `-` as per convention. 2020-06-04 20:33:38 +05:30
Christopher Allford ffe2257f2d Removed the notice for untested minor version updates
With the increased cadence of releases it becomes necessary that we address the `WC tested up to` header's usefulness. It isn't practical to require everyone to update their extensions every month, especially given that we are only doing backwards compatible minor releases. The only case I can think of where we might want to check the minor version is if the Stable tag on Core is downgraded, but due to the naming of the header, this doesn't make any sense.

I considered making this a wildcard of some kind but I think most would bind to a full major version anyway and so this isn't worth the time to add it. As an aside, the tests in `plugin-updates.php` seem to indicate that a header of `WC tested up to: 4` would apply to the entire major version cycle, so wildcards already exist!
2020-06-03 14:36:06 -07:00
Ron Rennick 0265e027ef
Merge pull request #26637 from woocommerce/fix/wc_timezone_string
use wp_timezone_string when available
2020-06-03 15:41:47 -03:00
Claudio Sanches 3701f0a82b
Merge pull request #26542 from woocommerce/tweak/add-shipping-actions
Add actions before/after shipping calculation
2020-06-03 11:25:10 -03:00
Claudio Sanches bf042a428d
Merge pull request #25321 from grey-rsi/status_widget_stock_rows
Add filters for status_widget_stock_rows queries
2020-06-03 11:22:20 -03:00
MihaiCraciun 1df2ba2c7a Added missing closing select tag 2020-06-03 13:40:05 +03:00
Julia Amosova 8fe149d56d
Merge pull request #26670 from woocommerce/tweak/26123
Add note to Products Importer description that TXT files are also supported.
2020-06-02 15:00:36 -04:00
Claudio Sanches adca2cb73d
Merge pull request #26644 from tivnet/patch-6
class-wc-shortcode-products.php - fix spelling in a comment
2020-06-02 15:56:16 -03:00
Claudio Sanches 9020cebdbb Normalize parameters for woocommerce_product_importer_parsed_data filter 2020-06-02 14:21:33 -03:00
Claudio Sanches 5445d34283 Remove deprecated attribute 2020-06-02 13:57:55 -03:00
Claudio Sanches e0105f124f Deprecate WC_Cart->tax_display_cart 2020-06-02 13:55:29 -03:00
Julia Amosova 479cac4fc0 Add note to Products Importer that TXT files are also supported. 2020-06-02 12:55:06 -04:00
Claudio Sanches 5bf9a83e58
Fixed docblock 2020-06-02 12:17:59 -03:00
Claudio Sanches 2267dcfe7e
Updated since tags 2020-06-02 12:16:54 -03:00
Julia Amosova f929bacfc6 Correct grammar mistake in the help tip of the `Connected to WooCommerce.com` field of SSR. 2020-06-02 11:12:47 -04:00
Claudio Sanches f8a050f914 Fixed typo in WC_Product_CSV_Importer class 2020-06-02 11:42:50 -03:00
Sergey Ratushnuy ec91a7c3fc Small fix 2020-06-02 15:05:44 +03:00