Commit Graph

204 Commits

Author SHA1 Message Date
vedanshujain f248276a89 Use correct syntax for translators comments. 2020-12-21 15:33:10 +05:30
vedanshujain 6fa77b3d8e Fixup for myaccount page logic, it should be > 0 ot be considered as set. 2020-12-16 19:48:09 +05:30
vedanshujain 6b550ffb23 Better error messages for when coupon are held in other transactions.
Earlier, we were just showing an "Usage limit reached message", however in some cases, specially when user is logged in, we can also ask them to go to MyAccount page and cancel order if they'd like to (to free up the coupon). This will hopefully make for a better user experience.
2020-12-16 15:19:40 +05:30
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
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
Claudio Sanches d48f1d4e2e Fixed package tag usage 2020-08-05 13:36:24 -03:00
Peter Fabian 150c77ba29 Improve coupon name output handling. 2020-02-26 12:24:04 +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
Claudio Sanches 17da960abe
Merge pull request #23137 from woocommerce/fix/23051
Change coupon amount field type based on coupon type
2019-05-22 21:19:03 -03:00
Viktor Szépe 9e7fc0a35d
Fix stray char in PHPDoc of WC_Coupon
`|`
2019-03-30 00:48:17 +01:00
Mike Jolley eb45b94edb Switch data_type 2019-03-25 15:10:56 +00:00
Daniel Bitzer 2b57f95552
Add coupon object param to get coupon data filter
This makes it easier to manage virtual coupon objects created through the woocommerce_get_shop_coupon_data filter
2018-09-26 12:43:27 +09:30
Mike Jolley 9237353a83 Made constructor more readable with protected method 2018-05-24 18:19:42 +01:00
Gerhard Potgieter 288b5d9117 Refactor WC_Coupon constructor to allow for passing in coupon objects 2018-05-24 11:21:41 +02:00
Claudio Sanches 877cc29604 Ensure coupon amount is always a float value
Closes #19889
2018-04-27 18:03:04 -03:00
Claudio Sanches 96ec4d6215 Fixed includes/class-wc-coupon.php PHPCS violations 2018-03-19 19:59:20 -03:00
Caleb Burks ae0f5fc76d Ensure coupon amount is not empty 2018-02-22 14:33:06 -05:00
Boro Sitnikovski 3cd1bedade Set coupon virtual state on when initializing virtual coupons during recalculation 2017-08-25 17:07:07 +02:00
Mike Jolley b84efc1acd is_virtual to track manual coupons 2017-08-24 17:07:39 +01:00
claudiulodro fa35104486 Coupon amount validation 2017-08-10 11:00:57 -07:00
Mike Jolley 51fbb1aec3 set_items_from_cart 2017-07-28 13:02:39 +01:00
Mike Jolley 9b458f9368 Remove private validation methods from coupon and use discounts class 2017-07-28 12:20:49 +01:00
Claudiu Lodromanean 74d33bd510 Merge pull request #16275 from woocommerce/feature/discounts-class-totals-refactored
Cart totals class and calculation improvements
2017-07-27 09:01:55 -07:00
Claudio Sanches fc5f199906 Deprecated WC_Coupon validation methods 2017-07-27 11:46:17 -03:00
Mike Jolley ded2be8d28 Legacy filters 2017-07-27 15:31:10 +01:00
Jaydeep Rami 3522857d23 Fix typo in WooCommerce plugin (#16135)
* Fixed typo

* Fixed more typo

* Fixed more typo

* Fix tyop

* Fix more typo

* Fix more typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo datatime object

* Fix short name of compat

* Fix typo: update short name

* Fix typo "deactive" to "deactivate" and short BW - Compat

* Fix typo "Backwards compat"

* Fix typo 'parameters'

* Fix more typo 'pararmeters'

* Fix typo 'compund'

* FIx typo order

* Fix typo

* Fix typo 'incorrecly'

* Fix typo 'genarate'

* Fix typo 'reletive'

* Fix typo 'Handly'

* Fix typo 'rotatated'

* Fix typo

* Fix typo 'additonal'

* Fix typos
2017-07-17 11:10:52 +01:00
Claudio Sanches 0a8a64f10c Merge pull request #15679 from woocommerce/update/coupon-cart-logic
Use the product object rather than function wc_get_product_ids_on_sale
2017-07-04 17:29:30 -03:00
claudiulodro 4e7d3333cf Use type check in coupon constructor 2017-06-27 13:53:56 -07:00
Mike Jolley 31fccea25c Exclude sale products from category checks in coupon class
Fixes #15715
2017-06-21 11:55:12 +01:00
Mike Jolley b47e1ee728 Use the product object rather than function wc_get_product_ids_on_sale 2017-06-19 11:53:26 +01:00
Mike Jolley d9e34d4e86 Normalise emails on set 2017-06-19 10:48:00 +01:00
Mike Jolley d3666738d8 Merge branch 'pr/15069' 2017-05-23 18:56:58 +01:00
Rasmus Bengtsson 185934fad9 Fix phpdoc to include params and correct types 2017-05-15 13:50:52 +02:00
Rasmus Bengtsson 6a7fc8650f Remove unused local variables 2017-05-15 12:06:52 +02:00
Mike Jolley 1b5cad3d78 Fix variation category restriction and limit to x uses
Fixes #14068
2017-04-06 21:51:11 +01:00
Ivo Santos b7dfc10dee Update class-wc-coupon.php
Updated get_amount() method description.
2017-04-05 16:32:02 +02:00
Mike Jolley dea59579bb description changes, and usage of ID's instead of IDs 2017-03-20 15:47:51 +00:00
Claudio Sanches 59c2849736 Changed version 2.7 to 3.0 2017-03-15 13:36:53 -03:00
Mike Jolley d55653a408 Merge branch 'master' into fix-13498
# Conflicts:
#	includes/class-wc-order.php
#	tests/unit-tests/crud/data.php
2017-03-15 15:52:40 +00:00
Claudiu Lodromanean 258845fb7b Use GMT timestamp when comparing expiry 2017-03-13 13:40:58 -07:00
Claudiu Lodromanean 7d9227d3af Update coupon object with new date 2017-03-13 13:31:40 -07:00
Claudiu Lodromanean 73ed273189 Use active voice 2017-03-10 10:32:27 -08:00
Claudiu Lodromanean d630b948e3 Better increase/decreasing 2017-03-10 10:28:56 -08:00
Claudiu Lodromanean e6a17a0fb3 Dont use set_prop on increase/decrease to prevent overwriting data 2017-03-10 09:27:39 -08:00
Claudiu Lodromanean e36ee46dea Make increase_usage_count work correctly on concurrent checkoutt 2017-03-08 15:27:37 -08:00
Claudio Sanches de77bddcfb limit_usage_to_x_items should be integer 2017-03-06 18:14:15 -03:00
Boro Sitnikovski 428e32bfa9 Reintroduce virtual coupons by "un"deprecating the filter.
We also need to return to skip CRUD processing.
2017-03-01 22:49:21 +01:00
Claudio Sanches 6af3b2255e Fixed default used_by 2017-02-17 00:10:46 -02:00
Justin Shreve dcecf0f228 Fix get_hook_prefix format 2017-01-24 11:02:06 -08:00
Justin Shreve e4937b898d Fix PHP 7.1 warnings/notices. 2017-01-04 10:45:45 -08:00