Fredrik Forsmo
0f74f805b0
Improve docblock comments in WC_Coupon class
...
* Added missing throws tags to various methods
2016-01-06 15:53:59 +01:00
Mike Jolley
9aee0ac1cb
Functions and filters to determine which coupons need product and cart validation rules.
...
Closes #9854
2015-12-16 11:47:56 +00:00
Mike Jolley
3b409f1bbf
For coupons with category restrictions, respect the category hierarchy.
...
Closes #9704
2015-11-30 12:29:16 +00:00
Claudio Sanches
753014da5a
Merge pull request #9631 from woothemes/transient-tweaks
...
Transient tweaks
2015-11-21 22:48:14 -02:00
Mehdi Esmaeili
101c7f47e1
Better Documentation: Put throws tag
2015-11-17 16:21:42 +03:30
Mike Jolley
e6859dc0f4
Change get_coupon_id_from_code to use wp_cache instead of transient
...
Persistent caching is more relevant here. Smaller stores won’t see much
gain from using the transient.
This commit also removes the woocommerce_coupon_code_query filter due
to limitations of it being within a prepare() call. Checked github and
no plugins appear to use this filter so should have minimal impact.
woocommerce_get_coupon_id_from_code filter added in place.
2015-11-13 23:09:35 +00:00
Nicola Mustone
c9da4f928a
check if ABSPATH is defined
2015-11-06 10:22:19 +01:00
Claudio Sanches
5893875b0c
Removed period for file headers
2015-11-03 11:53:50 -02:00
Claudio Sanches
ee30b5b308
Fixed php docs standards
2015-11-03 11:31:20 -02:00
Jeff Stieler
883170e261
Cache coupon id from code lookup in a transient.
2015-10-20 21:42:46 -06:00
Mike Jolley
3e55364e3a
Merge pull request #8940 from woothemes/issues/8482
...
Tidy up how we're dealing with coupon postmeta around `_used_by` which can get big.
2015-09-15 16:42:51 +01:00
Geoffrey de Vlugt
9d7d40ced1
Coupon usage count can become negative
...
This commit fixes issue #9086
2015-09-09 09:56:32 +02:00
George Stephanis
f71af3b1de
Account for the fact that when fetching all meta, maybe_unserialize() hasn't run yet.
...
@see
https://github.com/WordPress/WordPress/blob/a7b38bf90a8b4e070ae98faa076e
41403c59f951/wp-includes/meta.php#L499-L508
2015-08-24 16:08:04 -04:00
George Stephanis
6ef4cf0d18
Optimization. Don't call `get_post_meta` 17+ odd times.
...
As @pmgarman remarked here:
https://pmgarman.me/blog/woocommerce-and-coupon-_used_by-logging/ — for
very large values of postmeta, when using memcached that cannot handle
data stores of over 1M, the store seems to fail at pulling it back in,
resulting in large query results on each call.
At the least, this change should avoid those cache misses and
re-queries, although I do feel that not being able to keep the cached
in php’s memory and losing it in the cache is indeed a failing here of
the object cache plugin.
Still, this should have some optimizations, as we’re caching the data
right here, closer to usage.
2015-08-24 15:06:19 -04:00
George Stephanis
a17addae0a
Migrate the actual querying of the underlying data structure.
...
Move it into the relative class for tidiness, and have it be called via
an access function.
2015-08-24 14:30:13 -04:00
George Stephanis
4692afacdd
Add a conditional to match `inc_usage_count()`
...
Otherwise, for empty $used_by values, it will fire off a needless db
query.
2015-08-24 14:20:30 -04:00
George Stephanis
40dfb59bde
Clarify a comment as to why we're not using a core method.
2015-08-24 14:19:08 -04:00
George Stephanis
fd3ceb3e04
Allow a user to be specified for validating the limit of.
2015-08-24 13:08:44 -04:00
George Stephanis
e6b7d5c49a
Simplify the data we're working with.
...
This provides slightly safer bounds for large data sets.
2015-08-24 13:08:23 -04:00
Mike Jolley
d222dd4c37
Don't apply product discount if price is already 0
...
Closes #8725
2015-08-05 13:45:32 +01:00
Claudio Sanches
9e41552342
Removed all "@return void"
2015-07-16 16:55:48 -03:00
Mike Jolley
d1db647c05
Fix validate_sale_items logic for variable products
...
Closes #8591
2015-07-16 17:53:52 +01:00
Mike Jolley
a148e867b0
[2.3] Fix sale item exclusion logic for variations
...
Closes #8324
2015-06-09 16:10:46 +01:00
Mike Jolley
f1af777368
[2.3] Fix typo in validate_maximum_amount
...
Closes #8207
2015-05-26 17:40:07 +01:00
Nikki DelRosso
940c2369b0
Added method to check if cart is empty
2015-05-14 14:18:53 -07:00
Mike Jolley
af6998fe4d
[2.3] Correct coupon % calc. Added inline note to prevent regression.
...
Closes #8074
2015-05-05 14:33:35 +01:00
Mike Jolley
c8467b143a
[2.3] Use exclusive price and exclusive subtotal to work out % of discount
2015-04-17 20:42:18 +01:00
Mike Jolley
809573af41
[2.3] Coupon product id and category id checks should run for all coupon types
...
Closes #7936
2015-04-14 10:21:52 +01:00
Mike Jolley
2ddd07b252
FIx fixed product discount
2015-04-10 10:55:40 +01:00
Mike Jolley
68194bf0ed
Round discount totals
2015-04-10 10:28:46 +01:00
Caleb Burks
3728f8b001
Enhanced Error Message
...
As pointed out by jnachtigall (https://github.com/woothemes/woocommerce/issues/7870 ), this could help customers who may have accidentally mis-typed the coupon.
2015-04-01 16:56:10 -07:00
Mike Jolley
65bc9db763
Tweak get_coupon() method
...
Closes #7830
2015-03-27 15:36:53 +00:00
Mike Jolley
f23f1bbd27
format values to prevent issues due to floats
...
Closes #7822
2015-03-27 15:15:00 +00:00
Mike Jolley
457050ae9d
Improved coupon percent calculation for fixed discounts.
...
Closes #7669
2015-03-09 17:05:09 +00:00
justinstern
809f4be1a3
get_coupon_error vs get_coupon_message
2015-03-06 11:36:34 -05:00
justinstern
9f3ae48b8f
Skip coupon notices if there's no message
...
Handy for defining programmatic coupons to apply cart discounts, when
you wouldn't necessarily want to have a notice displayed
2015-03-06 00:36:01 -05:00
Mike Jolley
b6e7e4e8ad
Improve category coupon message.
...
Closes #7463
2015-02-18 11:17:58 +00:00
Mike Jolley
62cb430eaa
Run coupon codes through html_entity_decode.
...
Closes #7395
2015-02-12 22:50:22 +00:00
Mike Jolley
e99b3a9bf8
limit_usage_to_x_items option in coupons.
...
Closes #7396
2015-02-12 22:39:40 +00:00
Mike Jolley
c71bff2844
Only apply product/cat coupon checks for cart to cart coupons.
...
Closes #7389
2015-02-12 16:15:28 +00:00
Mike Jolley
a54b9c61e2
Define coupon magic props
2015-02-03 14:20:46 +00:00
Claudio Sanches
d6023818fd
Fixed the increase and decreate of coupons usage count
2015-01-30 12:14:34 -02:00
Mike Jolley
147258d5b8
Fix cart coupon on-sale checks for variations.
...
Closes #7078
2015-01-13 16:12:54 +00:00
Mike Jolley
549d7ab2c0
Removed 'apply before tax' options for coupons - this should be the default core behaviour
2014-11-24 17:24:25 +00:00
Mike Jolley
537233efcc
Split is_valid() into separate methods
2014-11-14 17:18:02 +00:00
Mike Jolley
f600c5ec05
Limit coupons to X needs to persist across lines during calc
...
Fixes #6745
2014-11-14 16:38:33 +00:00
Mike Jolley
1d3b8db754
Move formatting logic
2014-11-14 16:22:01 +00:00
Mike Jolley
668e5ffb5c
Some refactoring of the coupon class to load data with less code
2014-11-14 16:22:01 +00:00
Marin Atanasov
5ad973eac2
fixing small typo
2014-11-11 22:52:45 +02:00
Mike Jolley
0bc3ad868d
[2.2] Fix error message with maximum amount
...
Fixes #6567
2014-10-21 14:55:43 +01:00