Justin Shreve
f65c9305bf
Update WC_Coupon to use the new WC_Data class and meta methods.
2016-03-17 09:38:56 -07:00
Justin Shreve
60085e582a
Fix some comments/spacing issues.
2016-03-17 09:19:29 -07:00
Justin Shreve
f973b9d122
Make some improvements to metadata. Don't return [0] array, allow setting custom meta with a WC_Coupon method. Fix up some tests.
2016-03-17 09:19:29 -07:00
Justin Shreve
7e97ee94c1
Update deprecated and doing it wrong version numbers
2016-03-17 09:19:28 -07:00
Justin Shreve
69973d520e
Update version strings
2016-03-17 09:19:28 -07:00
Justin Shreve
5ea607e236
Handle the rest of the PR feedback:
...
* Run get_code through the woocommerce_coupon_code filter
* Convert expiry dates to timestamps in set_expiry_date
* Simplify product ID array explodes to get an empty array
2016-03-17 09:19:28 -07:00
Justin Shreve
0268a67c4b
Address a few of the feedback items from the PR:
...
* Switch all coupon fields to _data
* Move coupon custom fields to _meta_data
* Shorten the 'yes' -> true checks
* Add a test for getting custom fields
2016-03-17 09:19:28 -07:00
Justin Shreve
61ae531de0
Add hooks for create, update, and delete.
2016-03-17 09:19:28 -07:00
Justin Shreve
50e1bc7117
Add tests for the getter/setter methods
2016-03-17 09:19:28 -07:00
Justin Shreve
7a0c8d146b
Add the ability to create coupons via code (so things like Points & Rewards will still work).
2016-03-17 09:19:27 -07:00
Justin Shreve
3eacb992bc
Address issues from Mike's Feedback:
...
* Rename individual use, free shipping, and exclude sale items to match their meta names closer.
* Sanitize emails when using set_email_restrictions
* Remove some unnecessary explict true checks
* Move ID into _data with the rest of the fields
* Fixed some spacing issues
2016-03-17 09:19:27 -07:00
Justin Shreve
447462b274
Allow access to coupon properties directly to allow for back-compat usage, but throw a deprecated notice. Also adds a test to make sure these properties work as they should.
2016-03-17 09:19:27 -07:00
Justin Shreve
d738dec05d
Coupon CRUD (WIP).
2016-03-17 09:19:27 -07:00
Mike Jolley
f1eefa902c
[2.5] When getting coupon by code used twice, latest should be queried
...
Closes #10487
2016-03-07 13:08:02 +00:00
Mike Jolley
1979138666
Use unformatted coupon post title for comparison
...
Fixes #10476
2016-03-04 15:55:46 +00:00
Mike Jolley
f9d019df87
[2.5] Fix query/missing variable in validate_user_usage_limit
...
Closes #10122
2016-01-21 19:06:42 +00:00
Mike Jolley
e15c123510
Fix - Missing validation rule for product cat exclusion coupons (validate_excluded_product_categories)
...
Fixes #10058
2016-01-12 09:49:46 +00:00
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