Commit Graph

491 Commits

Author SHA1 Message Date
Claudio Sanches e2478b7c76 Use product already loaded 2021-02-23 21:10:34 -03:00
Claudio Sanches 76e1ba4bf0 Validate variation ID while adding products to the cart 2021-02-23 16:27:57 -03:00
Albert Juhé Lluveras 23db1a0e1f Fix typos in comments 2021-01-22 17:13:49 +01:00
vedanshujain 507e7a27b2 Better error messages when coupons are stuck in a pending order.
We hold coupons when payment is failed if the setting "hold stock for checkout" is enabled for some minutes. This is to allow the customers to try again if they want, and to give time to complete payment for gateways where it could take some time.

Unfortunately this cause for some bad UX user retries by starting the order from scratch again, and then if they apply the coupon, usage limit gets hit because the earlier coupon is still held and is counted towards the usage. This commit improves the error message in these cases when usage is applied per customer and is hit, by stating to go to my account to complete/cancel payment (in case of logged in user) or to wait for some time in case of guest users.
2020-12-15 16:01:14 +05:30
Claudio Sanches 918750fffb Validate variation ID while adding products to the cart 2020-11-24 19:32:58 -03:00
Rodrigo Primo 3ed300a4aa
Merge pull request #27607 from wpdesk/bugfix/cart-weight-float
Fixed cart weight return type.
2020-10-24 14:12:03 -03: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
Nestor Soriano b1e81d02da Fix code style/sniffer errors in a few files. 2020-10-01 11:08:51 +02:00
Grzegorz Rola 75d9a8942c Fixed cart weight return type. 2020-09-14 11:32:05 +02:00
Christopher Allford ae697f9fe2 Prevented zero from being considered empty when validating posted variation attributes 2020-09-09 11:29:31 -07:00
vedanshujain 7f2b322085 Check for state and postcode fields only if required
We were doing state and postcode even for countries where its not required, but unfortunately as an unintended effect we were ending up not checking shipping requirements if this was not met.
2020-09-09 18:21:14 +05:30
Grzegorz Rola 4cfedf3968 Fixed cart weight return type. 2020-09-07 18:14:01 +02:00
Ron Rennick bbdafb5cb1
Merge pull request #26196 from fitimvata/master
Add filter woocommerce_cart_item_required_stock_is_not_enough
2020-08-28 15:34:46 -03:00
Ron Rennick af162d8bed
Updated `@since` for the filter 2020-08-28 15:33:43 -03:00
Claudio Sanches 37291abc54 Added since tag in new filters introduced in 4.5 2020-08-17 18:01:41 -03:00
Claudio Sanches e102ec3d83 Merge branch 'master' into fix/25133 2020-08-17 14:59:49 -03:00
Claudio Sanches 29bc98816e
Merge pull request #27143 from woocommerce/fix/26876
Fix "Hide shipping costs until an address is entered"
2020-08-11 20:06:17 -03:00
Ron Rennick 8a1b8d6a3d
Merge pull request #26439 from kevinruscoe/add-additional-stock-cart-filter-messages
Add additional cart filters for stock actions
2020-08-10 16:34:24 -03:00
Claudio Sanches 02cf0dfaed
Merge pull request #27239 from woocommerce/fix/package-tag
Fix usage of "package" tag in file headers
2020-08-07 13:37:24 -03:00
Claudio Sanches d48f1d4e2e Fixed package tag usage 2020-08-05 13:36:24 -03:00
Claudio Sanches 08620cf846 Make "woocommerce_shipping_cost_requires_address" strict 2020-07-27 21:49:33 -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
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 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
Claudio Sanches 64f4fb85e2 Move variation validation logic to add to cart 2020-07-23 19:10:42 -03: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
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
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
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
Fitim 963bbcfca3 [woocommerce_cart_has_enough_stock_for_product] Invert the logic, change hook name 2020-06-26 09:38:44 +02:00
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
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
Kevin Ruscoe 6fa5977579 Add filters
Adds woocommerce_cart_product_cannot_add_another_message, woocommerce_cart_product_out_of_stock_message, woocommerce_cart_product_not_enough_stock_message
2020-05-09 12:03:43 +01:00
Claudio Sanches 77c6ddda92 Make display_prices_including_tax() aware of tax display changes 2020-05-07 00:03:48 -03:00
Vedanshu Jain ee119e0a7e
Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout" 2020-04-21 15:37:21 +05:30
Fitim c28c8e6472 Add filter woocommerce_cart_has_enough_stock_for_product in WC_Cart::check_cart_item_stock method 2020-04-16 12:16:11 +02:00
Vedanshu Jain 3bf473517d
Merge pull request #25708 from woocommerce/update/reserve-stock-for-checkout
Introduce a `reserved stock` class and database table to prevent race conditions during checkout
2020-04-07 02:16:22 +05:30
Vedanshu Jain 237463c39b
Merge pull request #25800 from woocommerce/fix/25748
Fixes tax rounding issues
2020-04-07 00:24:34 +05:30
Mike Jolley 02cf328afe Remove check for held stock minutes during stock checks - this will be handled elsewhere 2020-04-03 15:55:14 +01:00
vedanshujain 8adb474149 Enforce per user coupon usage limit for guest user checkout.
In a previous commit, a regression was introduced where we were no
longer checking for usage limit of guest user in an install. This
commit adds back that check.
2020-04-02 15:00:06 +00:00
vedanshujain 15d4bd7381 Don't individual tax lines to honour "Round at subtotal" setting. 2020-03-02 15:19:16 +05:30
Peter Fabian 150c77ba29 Improve coupon name output handling. 2020-02-26 12:24:04 +01:00
Peter Fabian 46dd915044 Improve coupon notice handling. 2020-02-05 18:50:40 +01:00
vedanshujain 72545c44b7 Add support for `_held_for_checkout` records to improve performance.
This will also improve transactional stability and avoid race conditions by providing a way to lock usage counts.
2019-12-17 19:13:19 +05:30
Arnaud Faucon e8b1d617a1 pass the clear persistent cart variable to the cart emptied actions 2019-10-30 09:14:45 +01:00
Rodrigo Primo d89e0cee84
Merge pull request #24176 from woocommerce/fix/issue-23750
Add more specific reason for why products cannot be purchased so plug…
2019-08-23 11:13:31 -03:00
David Stone 487b38e0ae Use two different filters instead to avoid unexpected behavior 2019-07-24 16:54:51 -06:00