Commit Graph

334 Commits

Author SHA1 Message Date
Justin Shreve fb124232cf Update Payment Tokens to follow the same pattern for custom data as other object types.
Payment tokens was introduced in 2.6 and was updated to use the new CRUD code while some of the CRUD system was still in flux.

While most things were correct, the prop handling for custom fields (like a card's last 4 digits) were directly calling meta functions, instead of delegating to the data store/parent.

This PR moves these props to `extra_data` and follows the same pattern as product types or order items. It also updates some version tags to 3.0.0. Finally, it adds an additional test for saving meta after a create which looks like it was lacking.

To Test:
* Run `phpunit`.
* Go to the "My Account" tab and add a new payment method. You need a payment gateway that supports this, like Simplify.
* Test the add a payment method flow.
* Make a test purchase using the saved payment method.
2017-03-14 12:33:35 -07:00
Claudiu Lodromanean 3476121709 Use local time where appropriate 2017-03-14 10:27:48 -07:00
Claudiu Lodromanean f042305ff7 Update date_expires meta handling 2017-03-14 08:10:31 -07:00
Mike Jolley e13badcdb3 Merge pull request #13584 from woocommerce/13527-update-downloads-dates
Apply WC_DateTime to WC_Customer_Downloads
2017-03-14 12:11:28 +00:00
Claudio Sanches c4134586cd FUpdate how save download dates 2017-03-13 20:54:33 -03:00
Claudiu Lodromanean b3c846da56 Use 2.6-format data for the expiry_date meta value 2017-03-13 14:37:34 -07:00
Mike Jolley 9bee678819 API updates 2017-03-13 21:36:31 +00:00
Claudiu Lodromanean f1925e561a Update coupon data store to use new dates 2017-03-13 14:24:05 -07:00
Mike Jolley 1bac579df7 Date getters and setters 2017-03-13 19:52:44 +00:00
Mike Jolley 38afff0031 Merge pull request #13516 from woocommerce/fix-13505
Make increase_usage_count work correctly on concurrent checkout
2017-03-10 19:07:57 +00:00
Mike Jolley 61484ed711 Update API endpoints 2017-03-10 18:54:59 +00:00
Claudiu Lodromanean d630b948e3 Better increase/decreasing 2017-03-10 10:28:56 -08:00
Claudiu Lodromanean d70723553d CHange vary to update 2017-03-10 09:18:14 -08:00
Mike Jolley c2339e1983 Data store read 2017-03-10 14:48:18 +00:00
Mike Jolley bdc302a9fb Data store write 2017-03-10 14:44:00 +00:00
Claudiu Lodromanean 3aea9a0b2f DRY out the meta bumping functions 2017-03-09 08:51:47 -08:00
Mike Jolley 6848fad224 Merge branch 'timezone-poc' into fix-13498 2017-03-09 16:10:07 +00:00
Mike Jolley 28a8d05285 Handle date paid in getter and during save to avoid filters during construct 2017-03-09 14:40:19 +00:00
Mike Jolley a5c10d07c1 Fix is_purchasable (requires save) when price is null
Fixes #13043
2017-03-09 13:26:12 +00:00
Claudiu Lodromanean e36ee46dea Make increase_usage_count work correctly on concurrent checkoutt 2017-03-08 15:27:37 -08:00
Mike Jolley a490b85d3e Handle saves 2017-03-08 16:51:46 +00:00
Aristeides Stathopoulos 70ee7ae7ea Fix some PHPCS errors 2017-03-07 19:57:28 +02:00
Claudio Sanches 64b45e9909 Prevent update or list _order_count and _money_spent on WC_Customer_Data_Store 2017-03-06 19:03:26 -03:00
Mike Jolley 296daf19c2 Avoid wc_clean
Fixes #13464
2017-03-06 14:53:32 +00:00
Mike Jolley 8440083fef Merge pull request #13443 from woocommerce/cache-groups
Standardize cache group names
2017-03-03 10:44:34 +00:00
Mike Jolley 0a53e0e47f Merge pull request #13444 from woocommerce/fix-13420
Set date paid for old orders
2017-03-03 10:41:33 +00:00
Mike Jolley 35eea95550 Set date paid for old order 2017-03-02 17:47:28 +00:00
Mike Jolley 1a8737fdeb Standardize cache group names 2017-03-02 17:15:39 +00:00
Mike Jolley fd07d06825 Update date created/modified if changed.
Fixes #13419
2017-03-02 16:46:59 +00:00
Mike Jolley 432ca28398 Update cart discount for old orders (#13384)
* Total discount bw compat handling

Fixes #13383

* if
2017-02-28 17:49:54 +00:00
Mike Jolley 41a4bdb181 Fix trashed variation cleanup
Fixes #13388
2017-02-28 15:38:11 +00:00
Mike Jolley fd94ce74bc Rogue exit in data store 2017-02-28 00:53:41 +00:00
Mike Jolley 84a4c3415c Handle auto drafts
Fixes #13361
2017-02-27 14:40:48 +00:00
Mike Jolley 194ed85d0e Change title update logic to look at product version and prefix
Fixes #13363
2017-02-27 14:40:32 +00:00
Mike Jolley 1d9f71fee5 Wrap read with try catch block 2017-02-23 12:09:39 +00:00
Mike Jolley 4e7658a5ba Fix duplication by passing through force
Fixes #13286
2017-02-22 13:15:33 +00:00
Mike Jolley 7aeb151bb6 Fix download count 2017-02-20 13:36:15 +00:00
Claudio Sanches 486a81bf12 Fixed coding standards 2017-02-17 16:10:15 -02:00
pierrebuet 15275130e2 Fix access expires not set (#13227)
* fix user id for download file

* fix access expires for download when not set

‚NULL‘ trigger a 0000-00-00 00:00:00
 as date in the database column. In order to write a real Null to the
database, the quotations must be deleted
2017-02-17 15:04:21 +00:00
Mike Jolley 1348f6efd7 Merge branch 'master' into db-schema-tweaks
# Conflicts:
#	includes/admin/class-wc-admin-duplicate-product.php
2017-02-16 16:33:20 +00:00
Mike Jolley 2505abeb21 Merge pull request #13202 from woocommerce/fix-13199
Duplicate products; fix variation creation and add actions
2017-02-16 16:18:53 +00:00
Mike Jolley b69988fe39 Correct changes in variation data update and fix context 2017-02-16 16:07:11 +00:00
Mike Jolley 5309b4ca7d woocommerce_delete_order_refund 2017-02-16 12:33:47 +00:00
Mike Jolley f664fb955f Refunds cannot be trashed
Avoid trashed status after deleting a refund.

Fixes #13200
2017-02-15 17:02:05 +00:00
Mike Jolley 2f685691a4 Standardise update meta calls, and support forcing
Force allows create to make sure data is set regardless of whether it
was changed. This fixes product duplication.

Fixes #13199
2017-02-15 14:40:57 +00:00
Claudio Sanches 9012fead56 Merge pull request #13136 from woocommerce/improvement-12990
Add logic to variation title generation and remove redundant template info.
2017-02-14 19:15:48 -02:00
Manos Psychogyiopoulos 821b360ac1 remove stray error_log 2017-02-14 18:26:40 +02:00
Manos Psychogyiopoulos 1895f65d2d allow update_post_meta and handle_updated_props to be overriden 2017-02-14 18:14:37 +02:00
Akeda Bagus 840a4b18a6
Fix wrong meta key in recorded_coupon_usage_counts getter/setter.
Fixes #13183.
Fixes #13182.
2017-02-14 17:33:32 +07:00
Claudiu Lodromanean 3068d56bac Remove unused variable 2017-02-13 14:19:26 -08:00
Claudiu Lodromanean a8b491b55b Handle product titles with no attributes 2017-02-13 11:45:25 -08:00
Mike Jolley 00cda91c73 Merge pull request #13164 from woocommerce/lazy-update-products-13157
Lazy update products
2017-02-13 17:24:51 +00:00
Mike Jolley d080e135ee Reduce `select *` usage 2017-02-13 12:58:42 +00:00
Mike Jolley a20c0da580 syntax error 2017-02-11 15:50:21 +00:00
Mike Jolley ca1d49b2b6 Conditional visibility and downloads 2017-02-11 15:35:20 +00:00
Mike Jolley 91ac4a2e56 Remove update_term_counts
This does not look to be necessary because we use wp_set_post_terms
which handles this for us. Seems to be inherited from legacy.
2017-02-11 15:27:52 +00:00
Mike Jolley 8494bf7bee Conditonal post data saving 2017-02-11 15:26:13 +00:00
Mike Jolley 31d428131e Imrpove checkout performance when updating product sales 2017-02-10 23:41:53 +00:00
Claudiu Lodromanean 8a05f72f78 Minor clean-up 2017-02-10 14:35:26 -08:00
Claudiu Lodromanean b6b3f0c217 Modify product title logic 2017-02-10 10:19:05 -08:00
Claudiu Lodromanean e330ab4158 Pass product into filters 2017-02-09 14:05:40 -08:00
Claudiu Lodromanean a3f9207839 Add logic to variation title generation 2017-02-09 14:03:00 -08:00
Justin Shreve 8a6bae374f Switch from get_the_title to the post objects post_title. 2017-02-09 08:43:48 -08:00
Claudio Sanches 094b86c92b Merge pull request #13104 from woocommerce/fix-13015
Inherit shipping class id from parent
2017-02-09 13:37:54 -02:00
Claudio Sanches e3b563c518 Merge pull request #13044 from woocommerce/crud-perf-tweaks
[2.7] CRUD performance improvements for emails
2017-02-09 13:25:29 -02:00
Mike Jolley dcce2a4190 Change order of execution on checkout so shipping is required.
Closes #12992
2017-02-09 12:59:13 +00:00
Mike Jolley 7ff301e2ca Merge branch 'master' into crud-perf-tweaks
# Conflicts:
#	includes/data-stores/class-wc-order-item-data-store.php
2017-02-09 12:31:25 +00:00
Justin Shreve 65b99bf240 moved order item type check to order item data store 2017-02-08 11:42:36 -08:00
Justin Shreve ae5293aeb9 Move the get type logic out of the product factories and into the data stores. 2017-02-08 11:18:39 -08:00
Claudiu Lodromanean 4525f91223 Merge pull request #13112 from woocommerce/fix-13106
Don't round values in get_on_sale_products
2017-02-08 10:14:52 -08:00
Claudiu Lodromanean dce81b4d4e Use store's decimal settings when figuring out what's a sale product 2017-02-08 09:04:13 -08:00
Mike Jolley 718149f1d4 Merge pull request #12999 from thenbrent/add_sort_variation_prices
Move price sorting into WC_Product_Variable::sort_variation_prices()
2017-02-08 10:29:30 +00:00
Claudiu Lodromanean 06c17d6be4 Add whitespace between parens 2017-02-07 13:57:01 -08:00
Claudiu Lodromanean 8ce5356943 13106 Dont round values in get_on_sale_products 2017-02-07 13:46:00 -08:00
Mike Jolley a4f87293ca Inherit shipping class id from parent 2017-02-07 12:35:24 +00:00
Brent Shepherd 8431b2ac86 Remove 'edit' param on get_visible_children()
The WC_Product_Variable::get_visible_children() method accepts no parameters.
2017-02-03 14:53:03 -08:00
Mike Jolley 3529d7cafd Cache items 2017-02-01 14:54:18 +01:00
Mike Jolley 31308403d4 Use variables to save values in item crud. 2017-02-01 10:53:53 +01:00
Mike Jolley 5a2b07763d Update metadata directly 2017-02-01 02:03:18 +01:00
Mike Jolley 5e2f1de36b get id once 2017-02-01 01:44:16 +01:00
Mike Jolley 2d013eb5be Handle wp prefix in php 2017-02-01 01:43:52 +01:00
Mike Jolley 5b221b4ed0 Edit context
#12936
2017-01-31 17:26:49 +01:00
Mike Jolley dee73d4056 Use edit context on load
Closes #12936
2017-01-31 09:39:19 +01:00
Mike Jolley abe87d9bfa Merge pull request #12967 from woocommerce/fix/variation-get-name
Clean up variation names.
2017-01-27 17:01:34 +00:00
Brent Shepherd e7e434da4b WC_Product_Variable::sort_variation_prices()
To keep variation sorting logic inside the variable product, and separate
from the database storage logic in WC_Product_Variable_Data_Store_CPT
2017-01-26 12:47:46 -08:00
Justin Shreve 7b1adfb98f Bake out of get_title deprecation changes 2017-01-26 07:46:59 -08:00
Justin Shreve 32651f638c When updating payment tokens, only update the props that have changed + fire off a hook of the changed props. 2017-01-25 11:05:54 -08:00
Justin Shreve 318046789c Comment clarifying translation wrapper. 2017-01-25 10:40:14 -08:00
Justin Shreve 9889efec75 Catch Product # titles and remove error logs 2017-01-25 10:37:48 -08:00
Justin Shreve f344143b63 Catch variation text and update 2017-01-25 10:27:28 -08:00
Mike Jolley 5746c87580 Merge pull request #12968 from woocommerce/updated-props-action
Fire actions for updated props
2017-01-25 00:10:48 +00:00
Mike Jolley 3afb00da06 Fixed Typo 2017-01-25 00:09:57 +00:00
Mike Jolley ea817a5c88 Merge pull request #12970 from thenbrent/check_variation_post_type
Check post type during read of product variations
2017-01-25 00:08:54 +00:00
Mike Jolley 90fd0da7d0 Fire actions for updated props 2017-01-24 21:38:02 +00:00
Brent Shepherd 49095f0a6c Check post type during read of product variations
Continuation of #12795
2017-01-24 12:28:02 -08:00
Brent Shepherd f2cb083bd6 Read extra data for variation products
So that classes can extend WC_Product_Variation and use the existing
WC_Product_Variation_Data_Store_CPT class, rather than having to create
a new data store class to set the WC_Product_Variation::$extra_data
values.
2017-01-24 12:20:15 -08:00
Brent Shepherd 56c427acba Add WC_Product_Data_Store_CPT::read_extra_data()
So that a product's $extra_data can also be read by child classes of
WC_Product_Data_Store_CPT, like WC_Product_Variation_Data_Store_CPT,
without duplicating the code to read it.
2017-01-24 12:18:35 -08:00
Justin Shreve 2b464d2e52 Deprecate get_title and it's hook, use get_name instead and pull name from parent. 2017-01-24 12:10:36 -08:00
Justin Shreve 2cdf950963 Merge pull request #12950 from woocommerce/fix/meta-update
Data Stores & update_post_meta: Update changed & keys that don't exist.
2017-01-24 07:14:54 -08:00
Justin Shreve 711a381ff6 Remove error log 2017-01-23 13:16:49 -08:00
Justin Shreve 3d55efffac Move order logic to wc-order 2017-01-23 13:08:55 -08:00
Justin Shreve 1ab0b34926 Fix meta handling logic for update_post_meta: Only update keys that have changed or don't exist. 2017-01-23 12:20:29 -08:00
Brent Shepherd 1ac2c1a94f Move price hash to separate function
So that it can be used by child classes without copy/pasting code.
2017-01-23 11:57:49 -08:00
Mike Jolley 1e9659b235 Merge pull request #12884 from kreamweb/master
Fix: usermeta table name, in a multisite the usermeta table is common…
2017-01-23 11:54:59 +00:00
Brent Shepherd ff627b31f6 Make variable data store private methods protected
So they can be inherited by other variable product types, like
variable subscriptions.
2017-01-20 11:09:49 -08:00
Mike Jolley fa9fed4e4d Merge pull request #12908 from thenbrent/fix_refund_data_store_read
[2.7] Fix WC_Order_Refund_Data_Store_CPT::read() and Abstract_WC_Order_Data_Store_CPT's support for other custom order types
2017-01-20 10:44:18 +00:00
Mike Jolley f44b4f6e9f Merge pull request #12907 from thenbrent/get_order_count_param
[2.7] Fix name of get_order_count() param
2017-01-20 10:43:06 +00:00
Brent Shepherd c8f003d5b0 Fix WC_Order_Refund_Data_Store_CPT::read()
Abstract_WC_Order_Data_Store_CPT::read() hardcoded its validation against
the 'shop_order' post type. However, custom order types created via the
wc_register_order_type() API can use different post types. For example,
refunds have the post type: 'shop_order_refund'.

This patch changes the Abstract_WC_Order_Data_Store_CPT::read() validation
to check that the post type is any of the registered order types.

This fixes refunds and 3rd party custom order types, like subscriptions.
2017-01-19 16:18:42 -08:00
Brent Shepherd f9569df1ee Fix naming of get_order_count() param
The parameter is actually an order status, not type.
2017-01-19 15:40:20 -08:00
Justin Shreve 98343ffe26 Fix docblocks and cast the order ID as int after our query. 2017-01-19 09:38:23 -08:00
Justin Shreve a1446c9591 Add method for getting order id from order item id. 2017-01-19 09:30:19 -08:00
emanuela castorina c4c78442cf Fix: usermeta table name, in a multisite the usermeta table is common to all sites 2017-01-18 18:11:21 +01:00
Justin Shreve b660eda4b8 Add date searching to wc_get_orders. 2017-01-17 12:52:27 -08:00
Claudio Sanches fbfb195f2f Fixed interfaces file names and location 2017-01-16 19:33:21 -02:00
Manos Psychogyiopoulos 892d5da7e9 get prices in 'edit' context when updating meta 2017-01-16 17:33:30 +02:00
Mike Jolley ba8f308100 Merge branch 'master' into orphan-variations-fix-12614
# Conflicts:
#	includes/class-wc-post-data.php
2017-01-11 15:42:20 +00:00
Mike Jolley 80f79ae98d Trash and untrash variations handling
Fixes #12774
2017-01-11 15:41:19 +00:00
Mike Jolley de11be2b6c space 2017-01-11 12:37:03 +00:00
Mike Jolley 9706104128 Fix test case 2017-01-11 12:33:38 +00:00
Mike Jolley 8e7687b9fc Add method to delete variations 2017-01-11 11:48:39 +00:00
Mike Jolley b749b654bc Fire action on type change 2017-01-11 11:48:31 +00:00
Mike Jolley 4e12ca6332 Merge pull request #12775 from kahanit/patch-1
Actions on delete of zone and zone method
2017-01-11 11:06:42 +00:00
Justin Shreve cddcb7841e Check post type during read of coupons, posts, and products. 2017-01-10 14:43:33 -08:00
Manos Psychogyiopoulos 022fbe4183 add 'include' arg to wc_get_products 2017-01-09 14:10:47 +02:00
Amit Sidhpura 887aa5fe1b sorry change zone in action to shipping_zone 2017-01-07 11:16:31 +05:30
Amit Sidhpura 8de220beeb Actions on delete of zone and zone method
Hooks on delete of zone and zone method.
I have named it 'woocommerce_delete_zone' and 'woocommerce_delete_zone_mehod' making it same format as customer delete action
'woocommerce_delete_customer'.
2017-01-07 11:10:36 +05:30
Mike Jolley 5dba3d5bfe Sync variation names 2017-01-04 15:18:02 +00:00
Mike Jolley 5272f836a4 Merge branch 'read-price-data-caching' 2017-01-04 13:56:14 +00:00
Mike Jolley a46ddc5dd2 Merge branch 'pr/12710' 2017-01-03 11:24:41 +00:00
Mike Jolley e149509f55 Products can have parents too 2017-01-03 11:24:36 +00:00
Manos Psychogyiopoulos d250d3f149 distinguish between trash and delete object hooks 2016-12-30 00:22:12 +02:00
Manos Psychogyiopoulos 96d7272065 include parent if entering variation id and variations excluded 2016-12-28 16:44:57 +02:00
Manos Psychogyiopoulos 5fa4846f5e fix inclusion of variation included in product search 2016-12-28 16:41:21 +02:00
Manos Psychogyiopoulos ae9f4eacc4 fix get_post_parent fatal error 2016-12-27 10:34:32 +02:00
Mike Jolley ceee6c37ca Change how non-crud props get stored 2016-12-23 14:06:51 +00:00
Mike Jolley 50b1a9d378 woocommerce_update_order 2016-12-20 15:44:37 +00:00
Mike Jolley 54ca822e57 Fix variable names 2016-12-19 17:13:25 +00:00
Mike Jolley c78e5cf2ec Trigger actions after data is saved
#12648
2016-12-19 16:40:53 +00:00
Mike Jolley 910d6d9900 Store custom checkout fields prefixed with shipping or billing in meta
Closes #12634
2016-12-19 14:51:56 +00:00
Mike Jolley 218689d9c3 woocommerce_order_data_store_cpt_get_orders_query
Closes #12643
2016-12-19 14:24:20 +00:00
Manos Psychogyiopoulos 03fac5231f set order item object as read after reading child class data 2016-12-18 20:04:14 +02:00
Mike Jolley 95794b720c Only set date_created if empty
Fixes #12579
2016-12-13 14:22:59 +00:00
Mike Jolley 6cf565c122 IDs for products were stored as strings in legacy 2016-12-12 15:29:53 +00:00
Mike Jolley 1e80db6021 Force meta to be written on creation
#12567
2016-12-12 13:56:35 +00:00
Mike Jolley 2c6bef3ce1 Reverse query so missing stock status meta does not break sync
Fixes #12567
2016-12-12 13:37:51 +00:00
Mike Jolley 0ce99fbdbb Merge pull request #12558 from woocommerce/crud-reduce-queries
CRUD reduce queries
2016-12-10 12:35:45 +00:00
Mike Jolley e0e0c9e832 Replace rating filters with taxonomy 2016-12-09 15:43:25 +00:00
Mike Jolley 5562cfc1f6 Lazy load product meta data 2016-12-09 12:18:21 +00:00
Mike Jolley 563dda505a Use real cache keys 2016-12-08 17:57:07 +00:00
Mike Jolley 709d314ca7 Add caching to product factory 2016-12-08 17:17:23 +00:00