Commit Graph

1553 Commits

Author SHA1 Message Date
Saggre 24167a5eed Fix typos in docs 2021-03-05 11:19:58 +02:00
roykho 93e528f8ea
Type cast floats to prevent string addition errors in PHP 8 closes #29087 2021-02-10 10:06:25 -08:00
roykho b2eb2d8724
Update tax rate label when saving order closes #28649 2021-01-28 14:42:40 -08:00
Claudio Sanches 6701ce9c9d
Merge pull request #26983 from woocommerce/fix/25082
Use tax location from order while computing tax in discount.
2021-01-28 16:59:59 -03:00
Gregory Karpinsky 6cb569047a
abstract_wc_order:add_product() - removed `throws`
Exception 'WC_Data_Exception' is never thrown in the function
2020-12-21 11:26:50 -05:00
Viktor Szépe ac3acc3df0
Fix CS 2020-11-20 18:53:39 +01:00
Viktor Szépe 996fb293a8
Fix types in WC_Payment_Gateway 2020-11-20 18:37:45 +01:00
vedanshujain 00b7b40c37 Add method to get rates based on order.
This method will prioritize getting rates from billing/shipping address instead of `WC()->customer` which in irrevelant in context of editing order from admin screen.
2020-11-12 22:58:05 +05:30
vedanshujain 74de152535 Use tax location from order while computing tax in discount.
We were not passing tax location while computing discount in orders, hence it was defaulting to shop's base address resulting in incorrect tax calculation.

This commit refactors `get_rates` method into another method that allows getting rates from location directly.
2020-11-12 22:57:56 +05:30
vedanshujain 6ed8ffe850 Addressed PR review comments #27734 2020-11-10 14:23:45 +05:30
vedanshujain eeb8851717 Minor fixups for PR #27734 2020-11-10 14:23:44 +05:30
vedanshujain bb1e2f44ae Removed/reverted more unnecessary changes. 2020-11-10 14:23:43 +05:30
vedanshujain a5fb3178f0 Drop CacheHydration class and do it directly.
Primary reason for dropping the cache hydration is that seems like we can acheive the same results without it, so no need to add this additional complexity to our code.
2020-11-10 14:23:43 +05:30
vedanshujain f5d0275786 Refactor methods to break down into smaller units for re-usability.
This commit breaks down `read_meta_data` so that individual methods for cache key and setting raw meta data can be reused.

Also adds set_meta_data_from_raw_data to initialize metadata from manual cache.
2020-11-10 14:23:39 +05:30
Roy Ho 5007d17596
Merge pull request #27514 from helgatheviking/has_options
Add woocommerce_product_has_options filter to has_options() method
2020-10-27 09:48:26 -07:00
Nestor Soriano 52eed70f04 Add a 'NumberUtil' class with a 'round' method.
There's a number of places in the WooCommerce codebase where the
built-in function 'round' is executed passing a non-numeric value
(not a number and not a string that can be parsed as a number),
for example round(''). In PHP 7 this yields a value of 0, but in
PHP 8 this throws an error.

This commit adds a 'NumberUtil' class with a static 'round' method,
this method checks if the passed value is numeric and if so it just
executes the built-in function, otherwise it returns 0. And all the
calls to 'round' in the codebase are replaced with 'NumberUtil::round'.
2020-10-01 11:08:51 +02:00
Kathy Daring 0db54ecec3 Add woocommerce_product_has_options filter 2020-08-28 12:01:11 -06:00
Claudio Sanches d48f1d4e2e Fixed package tag usage 2020-08-05 13:36:24 -03:00
Nestor Soriano c074f085cc Remove two phpcs:ignores, improve code instead 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
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
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
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
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
Peter Fabian 14a26aca2c Update min files and selectWoo 2020-06-16 17:15:12 +02:00
Nestor Soriano b43679c181 Schedule a deferred product sync for products with parent on delete.
Right now, when a product having a parent (e.g. a variation having a
parent variable product) is saved, wc_deferred_product_sync is
executed so that product sync is performed at the end of the request.
This commit implements the same when the product is deleted.
2020-05-28 14:07:51 +02:00
vedanshujain 3dc7df7af9 Use common code and round in subtotal.
We round in `get_subtotal` because its a front-end method. If more precision is required then `get_cart_subtotal_for_order` needs to be called. Also use same `get_cart_subtotal_for_order` method here as well for consistency.
2020-05-27 23:48:47 +05:30
vedanshujain 57d336433a Fix regression caused by merging #25092 conflicting with #24828 2020-05-22 22:08:42 +05:30
Nestor Soriano 0eed82b3b7 Fix code standards violations introduced in #25092 2020-04-07 12:28:30 +02:00
Vedanshu Jain 237463c39b
Merge pull request #25800 from woocommerce/fix/25748
Fixes tax rounding issues
2020-04-07 00:24:34 +05:30
Néstor Soriano 13765d9e91
Merge pull request #25092 from leanzafrancesco/fix/25091
Fix/25091 - Wrong totals in orders with taxable and non-taxable products and percentage coupons
2020-04-06 12:31:07 +02:00
Rodrigo Primo e40ddc5291
Merge pull request #25727 from leanzafrancesco/add/order-tax-location-filter
Add woocommerce_order_get_tax_location filter
2020-03-05 13:48:40 -03:00
vedanshujain a0c209193b Remove rounding because individual lines would already have been rounded at this point if needed. 2020-03-02 15:19:16 +05:30
vedanshujain 740e2c8a92 Treat individual tax totals as line items because they will be totalled later.
This means that we won't round them individually unless we have setting for round at line item enabled.
2020-03-02 15:19:16 +05:30
vedanshujain 48e63adf77 Make rounding methods consistent in orders and cart 2020-03-02 15:19:16 +05:30
Peter Fabian 150c77ba29 Improve coupon name output handling. 2020-02-26 12:24:04 +01:00
Francesco Leanza 5dfb618ff9 Add woocommerce_order_get_tax_location filter 2020-02-21 11:45:06 +01:00
Peter Fabian ee865fe0b4
Merge pull request #25504 from woocommerce/update/order-detail-summary
Enhance order details and payment summary
2020-02-06 11:40:45 +01:00
Peter Fabian 147266f44f Updates to reflect PR feedback. 2020-02-04 21:43:29 +01:00
Christopher Allford 1d1413b4ee Replaced direct access of many constants with the Constants library 2020-01-31 22:18:47 -08:00
Peter Fabian 248e69960b Merge branch 'master' into update/order-detail-summary 2020-01-30 17:41:32 +01:00
Peter Fabian ec8d477b09 PHPCS fix. 2020-01-30 17:09:33 +01:00
Christopher Allford 6ad091a9b7 Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
Peter Fabian 1f9cd9eae9
Merge pull request #24066 from malviyaritesh/fix/24062
Filter meta value even if key not found
2020-01-23 14:59:39 +01:00
Claudio Sanches 85a077b939 Coupon race condition prevention 2020-01-06 19:44:24 -03:00
Claudio Sanches 7701d4b57c
Merge pull request #25286 from woocommerce/fix-phpcs-violations
Fix PHPCS violations automatically using PHPCBF
2019-12-23 12:22:42 -03:00
Rodrigo Primo 7337ab60c2 Fix PEAR.Functions.FunctionCallSignature violations
This commit fixes all violations of the PEAR.Functions.FunctionCallSignature sniff automatically using phpcbf.
2019-12-20 15:25:23 -03:00
Rodrigo Primo 487f96d844 Fix WordPress.DateTime.CurrentTimeTimestamp vilations
This commit fixes all violations of the WordPress.DateTime.CurrentTimeTimestamp sniff automatically using phpcbf.
2019-12-20 14:23:05 -03:00