Commit Graph

143 Commits

Author SHA1 Message Date
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
Christopher Allford ed55034867 Added a check to prevent coupon cent remainders from decreasing the item cost below zero 2020-03-16 21:32:25 -07:00
Peter Fabian 150c77ba29 Improve coupon name output handling. 2020-02-26 12:24:04 +01:00
MD Sultan Nasir Uddin 95ef4544a2
Fix get_discount function return type (#25567)
* Fix get_discount function return  type
2020-02-04 16:59:26 -03:00
vedanshujain 9b7343d23b Applied coding standards 2019-12-17 19:13:19 +05:30
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
Mike Jolley 33b1c4205b Fix cart tests - move round so taxes are correct 2019-04-17 16:49:46 +01:00
Mike Jolley 807878692b Add precision to tax 2019-02-27 13:43:01 +00:00
Mike Jolley e171718534
Merge pull request #22529 from james-allan/custom_coupon_usage_limit
Keep count of the number of times custom coupons apply
2019-01-23 21:36:19 +00:00
James Allan 767abb3a8a Keep count of the number of times custom coupons apply 2019-01-23 16:47:52 +10:00
Ron Rennick 343a217939 move add order tax to get_object_subtotal() 2019-01-22 13:42:37 -04:00
Ron Rennick 0f94bed1ec only add tax when comparing coupon against order 2019-01-15 11:33:44 -04:00
Ron Rennick d654107cb0 include taxes in subtotal when validating tax inclusive coupon maximum as well 2019-01-15 10:33:57 -04:00
Ron Rennick acf46fa28d phpcs sniff fixes for class-wc-discounts.php 2019-01-15 10:21:21 -04:00
Ron Rennick 5f2bc29e3d include taxes in subtotal when coupon price includes taxes 2019-01-15 10:17:31 -04:00
claudiulodro e24aa057ad Revise coupon behavior and add unit tests 2018-08-31 08:35:41 -07:00
kakshak 4d17ebeadc fix(woocommerce): per cart coupon condition updated 2018-08-22 11:09:58 +05:30
kakshak 6c57b59353 fix: ability to apply coupon on a sale item even when the coupon is restricted to only non sale items 2018-08-18 13:02:51 +05:30
Chunkford 0d9bf1e19c
Update class-wc-discounts.php 2018-06-26 17:22:09 +01:00
Chunkford 469c8f2d10
Add filter to a coupon's user usage limit
I need to be able to mark a coupon as unlimited use per user if a certain criteria is met
2018-06-26 16:32:08 +01:00
Jeremy Pry 01e1ef73e7 Handle item limit for custom coupon types
Fixes #20455
2018-06-08 14:18:16 -04:00
Mike Jolley 869415763c
Merge pull request #20396 from rnaby/060618-005642-wc-discounts-object-var-type
WC_Discounts | object Property Type PHPDoc Fix
2018-06-06 12:15:46 +01:00
Mike Jolley f9d9c395c7
Merge pull request #20397 from rnaby/060618-010003-wc-discounts-set_items_from_order
WC_Discounts|set_items_from_order Param Type Fix
2018-06-06 12:15:33 +01:00
Mike Jolley 833df18dff
Merge pull request #20398 from rnaby/060618-010246-wc-discounts-constructor
WC_Discounts | __construct PHPDoc and Param Fix
2018-06-06 12:15:19 +01:00
Mike Jolley 113d7ad781
Merge pull request #20400 from rnaby/060618-014013-wc-discounts-apply_coupon
WC_Discounts | apply_coupon Removed Unused Variable
2018-06-06 12:14:32 +01:00
Khan M Rashedun-Naby ad7bc84c2b WC_Discounts | apply_coupon PHPDoc @throws Fix 2018-06-06 01:47:16 +06:00
Khan M Rashedun-Naby ba5671c052 WC_Discounts | apply_coupon Removed Unused Variable 2018-06-06 01:41:54 +06:00
Khan M Rashedun-Naby 1ce8338572 WC_Discounts|__construct PHPDoc and Param Fix 2018-06-06 01:08:35 +06:00
Khan M Rashedun-Naby 9310970938 WC_Discounts|set_items_from_order Param Type Fix 2018-06-06 01:01:39 +06:00
Khan M Rashedun-Naby a89161c8bf WC_Discounts| Type PHPDoc Fix 2018-06-06 00:57:49 +06:00
Claudio Sanches a1a82b09bb Fixed includes/class-wc-discounts.php PHPCS violations 2018-03-21 00:00:54 -03:00
Chunkford 5416c58f4e
Update class-wc-discounts.php 2018-03-07 13:36:43 +00:00
Mike Jolley 58c87e3fcd
Merge pull request #19148 from woocommerce/tweak/post-processing-custom-coupons
Add filter to allow post processing on custom coupons
2018-03-05 19:18:04 +00:00
Chunkford dce96daa84
Add filter to a coupon's expiry date check
I need the ability (and hopefully others now or in the future) to intercept the expiry date check for a coupon.
This pull request offers that ability.
2018-03-03 11:46:14 +00:00
Boro Sitnikovski 1a1f62c952 Separate coupon custom logic into its own method 2018-02-28 13:42:52 +01:00
Boro Sitnikovski b2e9fbb22d Add filter to allow post processing on custom coupons 2018-02-28 13:41:18 +01:00
Frédéric Demarle ac199889f2 Fix fatal error in PHP < 5.5 2018-02-27 20:55:40 +01:00
Claudiu Lodromanean 5346f63abc
Merge pull request #19159 from woocommerce/fix/19124
Use subtotal for discounts in admin/orders
2018-02-27 11:27:01 -08:00
Mike Jolley a6431c86d3 Use subtotals when applying discount logic to match cart. 2018-02-27 18:48:05 +00:00
Kathy Darling d494daf3cd Merge branch 'master' of github.com:woocommerce/woocommerce into exclude-products-from-coupon-validation 2018-02-23 22:09:06 -06:00
Caleb Burks 9ba4ae7ad7 Remove unnecessary conditional 2018-02-22 14:39:37 -05:00
Kathy Darling caf03064ac add getter for class' object property 2018-02-16 15:52:04 -06:00
Kathy Darling 8dc3d689c6 Follow up to #18971. Pass cart/order items through a filter. 2018-02-16 15:51:35 -06:00
Gerhard Potgieter 97ca671efa Validating user usage limit should check that of customer and not logged in user when applying coupons in admin area. 2018-01-26 12:37:23 +02:00
Mike Jolley 0363312084 spacing 2018-01-11 15:01:07 +00:00
Mikalai Okun 2e2e5d60e5
Updated strval() to round() 2018-01-11 08:49:54 -05:00
Mikalai Okun cd8c09769d
Workaround for precision on floating values. 2018-01-11 01:38:36 -05:00