Commit Graph

1158 Commits

Author SHA1 Message Date
Mike Jolley a6329fa68c Merge pull request #14752 from woocommerce/pr/14732
revert price handling of get_price_html()
2017-04-27 13:03:15 +01:00
Mike Jolley db5e2572f6 clean up 2017-04-27 13:01:52 +01:00
claudiulodro 2fad12221d Better comments 2017-04-26 11:04:28 -07:00
Cesar Rodas 91de312eb2 Make sure the meta data cache is not shared among instances
See #14620 for more context. In there I thought this was the desired behaviour and I enhanced it. After talking with @mikejolley he explained to me that it was not by designed.

This commit makes sure the meta data cache is not shared among instances
2017-04-26 13:51:52 -04:00
Kathy Darling 36dbe64170 revert price handling so null price still is filtered by woocommerce_get_price_html. closes #14727. 2017-04-26 12:37:30 -05:00
Cesar Rodas 6eb7dcabf2 Added WC_Meta_Data object
It wraps an array, and tells if there were any changes before saving it
2017-04-26 10:18:41 -04:00
Cesar Rodas 7f357b18ba Fixed typo
This expression had a typo from the refactoring
2017-04-26 03:21:10 -04:00
Cesar Rodas d3fd16617c Improved phpdoc 2017-04-26 02:57:00 -04:00
Cesar Rodas 38f379a7d7 Make get_item() consistent (like get_items())
Right now get_item() is loading an item from the database directly. It doesn't
take advantage of our cache and it doesn't check if the item is already loaded in memory.

There is also another bug (or feature?) that it will let you load any item, even if the item is not related to the current order. I believe this is a bug, if somebody really wants to load any item regardless of the order they should use `WC_Order_Factory::get_order_item`.

Another bug is that items loaded with get_item() are not related to the order object, therefore any calls to Order::save() won't persist the changes made to the item.

This commits makes sure the item returned by get_item is loaded similarly like get_items() does, taking advantage of the cache and the $items protected property (chances are the item is already in memory, ready to be used).

If a given item is not found false will be returned. If item exists but it is not related to the current object it will return false as well (If this behaviour is wanted, I can easily change it load the item anyways instead of returning false).
2017-04-26 02:54:14 -04:00
claudiulodro efa1dbbda5 Basic working order queries 2017-04-25 14:52:17 -07:00
Petar Petrov fdb28218ea items_type_key filter and woocommerce_order_line_item_object fix 2017-04-25 18:07:40 +03:00
Mike Jolley 9923612832 Prevent orders being their own parent (!)
Closes #14660
2017-04-25 14:18:27 +01:00
Petar Petrov 2b3ec357ad fix-14302 2017-04-25 14:12:36 +03:00
claudiulodro 553a12203b WC_Order_Query 2017-04-24 16:28:13 -07:00
claudiulodro 29fa59a0b7 WC_Object_Query 2017-04-24 11:33:17 -07:00
Mike Jolley 4a6c87d1cc docblock 2017-04-20 16:03:40 +01:00
Mike Jolley 8e28af8b87 define get_user_id/get_user methods for bw compat
Closes #14543
2017-04-20 16:02:10 +01:00
Mike Jolley 69a8b6c9b5 When on backorder without notifications, hide the text
Fixes #14530
2017-04-19 16:57:49 +01:00
Claudio Sanches d94f3883da Merge pull request #14497 from woocommerce/fix/14416
Fixed docblocks in REST API v1
2017-04-18 18:43:06 -03:00
Claudio Sanches 81dcd6e79e Fixed docblocks in REST API v1 for #14416 2017-04-18 13:40:10 -03:00
Mike Jolley de016c6615 Fix call to is_compound method
Fixes #14484
2017-04-18 12:00:21 +01:00
Govind Kumar 200cd2de63 Fixed: get_term() returns objects not array. 2017-04-18 13:00:04 +05:30
Mike Jolley 71929666ac Merge pull request #14404 from thenbrent/fix_get_meta_returning_deleted_values
Don't return deleted meta in get_meta_data()
2017-04-17 11:38:12 +01:00
Beka Rice d35621f166 Cast unmodified tax as float as well 2017-04-15 12:01:37 -04:00
Brent Shepherd 0e40d2c764 Don't return deleted meta
By using $this->get_meta_data() which passed meta through the
WC_Data::filter_null_meta() method, rather than $this->meta_data
which still has null values set.
2017-04-14 13:58:00 -07:00
Beka Rice 9de8589c9c Fix PHP 7.1 warnings when manually adding order items 2017-04-14 11:12:53 -04:00
Mike Jolley 76d962b606 since 2017-04-10 21:52:06 +01:00
Mike Jolley e14d85d0a3 __clone meta correctly on object clone
Fixes #14118
2017-04-10 17:12:17 +01:00
Claudiu Lodromanean 19361127a9 Array filter before saving 2017-04-06 14:47:22 -07:00
Mike Jolley fbcb46b273 filter items which are false
https://wordpress.org/support/topic/call-to-a-member-function-is_type-cl
ass-wc-order-php-on-line-1305/
2017-04-06 22:15:42 +01:00
Claudiu Lodromanean 94814a0b03 Dont throw exceptions when reading 2017-04-06 13:39:36 -07:00
Mike Jolley fe42b2565c Defer variation parent sync to shutdown rather than cron 2017-04-06 12:25:34 +01:00
Gregory Karpinsky 37c7e2a615 Docblock fix
`get_availability` returns array of strings
2017-04-06 00:32:36 -04:00
Claudiu Lodromanean 87b71b0653 Merge pull request #13941 from woocommerce/fix/hook-deprecated-function-calls
Use wc_deprecated_function so notices are not triggered on ajax requests
2017-04-05 09:36:01 -07:00
Mike Jolley e66efc1dcc Use wc_deprecated_function so notices are not triggered on ajax requests 2017-04-05 13:06:43 +01:00
Claudio Sanches cf954fac1e Fixed missing array declaration 2017-04-04 14:53:05 -03:00
Mike Jolley d917856378 Validate status if object_read
#13891
2017-04-04 12:39:35 +01:00
Mike Jolley c06fdc2e2e If product has_options, don't show qty in grouped product add to cart form
Fixes #13875
2017-04-03 12:05:28 +01:00
Akeda Bagus 0b416439c8
Fixed all typos of all files in includes/ directory.
Scanning and fixing were done automatically by codespell,
https://github.com/lucasdemarchi/codespell.
2017-03-29 00:58:51 +07:00
Mike Jolley 7857fbe41f Cast values to float
Fixes #13752
2017-03-24 12:05:28 +00:00
Mike Jolley 0ad1f6a63f Merge pull request #13709 from woocommerce/fix-13708
Timezone/DST fixes
2017-03-24 10:25:08 +00:00
Mike Jolley ba07d53768 Remove guesswork from timezone handling so offsets work correctly regardless of DST 2017-03-23 00:11:15 +00:00
Mike Jolley c4c8edee5f Remove order and product factory cache 2017-03-21 23:37:38 +00:00
Mike Jolley 98f5ba44e8 Protection against removed objects. 2017-03-21 18:31:38 +00:00
Mike Jolley 991927c2d8 Handle sleep and wakeup in WC_Data class 2017-03-21 17:42:34 +00:00
JeroenSormani 373bdda4f8 Add required filters to allow custom order item types 2017-03-20 10:37:06 +01:00
Claudio Sanches 59c2849736 Changed version 2.7 to 3.0 2017-03-15 13:36:53 -03:00
Mike Jolley 75a5b062cf Merge pull request #13577 from woocommerce/fix-13498
Timezone/Date method handling
2017-03-15 16:09:41 +00: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
Mike Jolley 77cade928a Merge pull request #13596 from woocommerce/fix/payment-token-crud-pattern
Update Payment Tokens to follow the same pattern for custom data as other objects.
2017-03-15 15:38:31 +00:00
Justin Shreve b917a87a73 Deprecated $context on get_display_name. 2017-03-15 08:21:02 -07:00
Mike Jolley 20b857bfbf Merge pull request #13602 from JeroenSormani/fix-false-deprecated
Remove @(deprecated) sign from docblock to prevent false notice in ed…
2017-03-15 09:55:13 +00:00
JeroenSormani 08e441149b Remove @(deprecated) sign from docblock to prevent false notice in editors 2017-03-15 09:46:17 +01:00
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
Mike Jolley a3cc5cc9bb has_meta -> meta_exists
#13590

Avoid has_meta conflict with old method.

#13581
2017-03-14 16:49:13 +00:00
Mike Jolley 8f2746049d has_meta method 2017-03-14 12:08:33 +00:00
Mike Jolley 02c826ba5e Correctly handle null values 2017-03-13 22:14:20 +00:00
Mike Jolley 1bac579df7 Date getters and setters 2017-03-13 19:52:44 +00:00
Rami Yushuvaev d2457fe922 i18n: escape translation strings and fix wrong usage of i18n functions 2017-03-13 07:39:46 +02:00
Mike Jolley 53962f1143 Other date_date call replacements 2017-03-10 16:43:05 +00:00
Mike Jolley 66e8d9b054 Merge pull request #13530 from woocommerce/alt-fix-13496
Avoid filters during construct
2017-03-10 12:22:22 +00:00
Claudiu Lodromanean 8a18702c27 Just use array_replace_recursive in apply_changes 2017-03-09 09:06:05 -08:00
Mike Jolley 6848fad224 Merge branch 'timezone-poc' into fix-13498 2017-03-09 16:10:07 +00:00
Mike Jolley 9427eb048d Set default status in getter, not during contruct.
Prevents loops like in Prospress/woocommerce-subscriptions#1902
2017-03-09 13:45:33 +00:00
Claudiu Lodromanean 3b8eb75c93 Better handling of nested arrays in apply_changes 2017-03-08 11:51:38 -08:00
Mike Jolley c7dc8ae2b4 date_created and date_modified getters and setters 2017-03-08 16:51:10 +00:00
Mike Jolley 1a9c49db25 set_date_prop helper to convert dates in setters 2017-03-08 16:50:38 +00:00
Michael Pretty 6150ee2fde Validate the parent order ID by calling wc_get_order() instead of get_post() 2017-03-08 08:02:18 -05:00
Mike Jolley 5bdeddcb32 Hide suffix on variable product when dynamic.
Closes #13494
2017-03-07 13:25:52 +00:00
Mike Jolley e5ed116e33 Split total row methods to avoid calling total row filter twice
Fixes #13456
2017-03-06 13:44:52 +00:00
Claudio Sanches 7adb472a1c Fixed extra argument on array_map while setting categories and tags ids 2017-03-03 16:26:57 -03:00
Claudio Sanches a4b7cc5f0d Accept only list of terms IDs for product categories and tags 2017-03-03 16:19:32 -03:00
Mike Jolley 8440083fef Merge pull request #13443 from woocommerce/cache-groups
Standardize cache group names
2017-03-03 10:44:34 +00:00
Claudiu Lodromanean d5fd1e46ee get_meta should return empty array sometimes 2017-03-02 11:16:49 -08:00
Mike Jolley 1a8737fdeb Standardize cache group names 2017-03-02 17:15:39 +00:00
Mike Jolley f5a36778fd Move refund/payment method code out of abstract 2017-02-27 17:06:09 +00:00
Mike Jolley c5697f2d59 Logic error with used id 2017-02-23 15:25:49 +00:00
Mike Jolley 134df2f4a0 Save existing rates rather than recreate all
Fixes #13264
2017-02-23 14:14:50 +00:00
Mike Jolley ded2accace Allow trash status to be set/returned rather than pending 2017-02-22 11:53:47 +00:00
Claudio Sanches 486a81bf12 Fixed coding standards 2017-02-17 16:10:15 -02:00
Mike Jolley a5ddccf814 Merge pull request #13229 from woocommerce/remove-filter-for-v2
Allow filter query parameter only in REST API v1
2017-02-17 16:29:57 +00:00
Mike Jolley 6201c7e22b Add get_min_purchase_quantity and max helper 2017-02-17 15:52:39 +00:00
Claudio Sanches 8db3f3eaf0 Allow filter query parameter only in v1 2017-02-17 13:13:17 -02:00
Claudio Sanches b0e6a5ab5d Get object again after saved 2017-02-17 01:46:42 -02:00
Claudio Sanches a46aea1b77 Fixedd status 2017-02-17 01:17:52 -02:00
Claudio Sanches 18dc63757b BCheck if object exists 2017-02-17 00:09:46 -02:00
Claudio Sanches 01a5296e7e Fixed how CRUD delete items by REST API 2017-02-16 22:25:07 -02:00
Claudio Sanches d4ce22cb76 Created WC_REST_CRUD_Controller 2017-02-16 20:27:07 -02:00
Mike Jolley b37e4da43c Move legacy classes to correct dir 2017-02-16 16:39:56 +00:00
Claudio Sanches 9c15ca936b Merge pull request #13206 from woocommerce/rest-api-v2
REST API v2
2017-02-16 12:53:46 -02:00
Claudiu Lodromanean dda98da4ad Merge pull request #13192 from woocommerce/deprecated-hooks
Deprecated hook handling
2017-02-15 08:40:16 -08:00
Boro Sitnikovski 5dd607023b Fix PHP notice when there are shipping taxes. 2017-02-15 15:17:04 +01:00
Mike Jolley 0c7218047c Fix error message 2017-02-14 19:31:14 +00:00
Mike Jolley e0d1cfc7b0 Actions 2017-02-14 19:23:57 +00:00
Mike Jolley 6add2f9a64 WC_Deprecated_Hooks abstract 2017-02-14 18:56:09 +00:00
Mike Jolley 1a61f20785 Add actions to trigger legacy actions 2017-02-14 18:55:56 +00: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 ad442567d6 Remove isset rule 2017-02-13 14:39:00 +00:00
Mike Jolley bdf567e90d Adjust how product_type is deprecated 2017-02-13 14:31:43 +00:00
Mike Jolley 6cf98a7e4d Avoid read after updating meta in the database
@justinshreve Was there a reason this was added? I don’t see a reason
why it needs to be re-read if the array is up to date?
2017-02-11 15:45:13 +00:00
Mike Jolley eb518ec06d Only append tax price suffix if taxable 2017-02-11 00:08:49 +00:00
Claudio Sanches 5d87a28407 Restored shipping zones base controller 2017-02-09 18:46:57 -02:00
Claudio Sanches 4b156ab1ae Merge old REST API branch 2017-02-09 18:19:56 -02:00
Claudiu Lodromanean 3120a19dae Switch isset back to array_key_exists to keep null-default props working 2017-02-09 10:13:44 -08:00
Claudio Sanches 4352484ed7 REST API v2 2017-02-09 15:06:13 -02: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
Mike Jolley b391e64453 Fix; Deprecated methods should return 2017-02-08 16:18:42 +00:00
Mike Jolley 5888ef5b93 Convert standard to '' in CRUD
Closes #12896
2017-02-07 17:22:04 +00:00
Mike Jolley b19be41994 Added since to WC_Data docblocks
Closes #13056
2017-02-06 17:06:20 +00:00
Mike Jolley 1ef593ff16 Merge pull request #13046 from thenbrent/merge_extra_data
Merge WC_Data::$extra_data in WC_Data::__construct()
2017-02-06 13:08:53 +01:00
Mike Jolley 09f7b0493e Merge pull request #13042 from woocommerce/legacy-order-date-format
Fix legacy order dates format
2017-02-06 12:51:41 +01:00
Mike Jolley 244b42eae8 Merge pull request #13048 from woocommerce/fix/cart-discount-call
Fix call to non-existent method for cart_discount.
2017-02-03 11:00:54 +01:00
Claudio Sanches 5eb08aeda6 [REST API] Cast int for batch delete 2017-02-02 19:09:45 +01:00
Mike Jolley 2ec4b8cf7f Revert "Get rating count should use is_array"
This reverts commit 0625a2b759.
2017-02-02 18:43:43 +01:00
Mike Jolley 0625a2b759 Get rating count should use is_array 2017-02-02 18:35:30 +01:00
Boro Sitnikovski 5f05b2e3d8 Fix call to non-existant method for cart_discount. 2017-02-02 09:45:09 +01:00
Brent Shepherd 010a208e88 Merge WC_Data::$extra_data in WC_Data::__construct
Rather than requiring child classes to merge it as well as define it.
If it's not defined in a child class, then the merge call will have no
effect as it will be an the empty array set in WC_Data, if they do define
it, WC_Data will now take care of it automatically rather than requiring
manually merging it in the child class's constructor before it has any
effect on that objects data.

This helps reduce duplicate code by removing this from child classes, and
in some cases, being able to remove the child constructor definitions
entirely. It also avoids a gotcha for developers setting their own
$extra_data values only to find they aren't being set on the $data
property.
2017-02-01 12:48:27 -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
Claudio Sanches 54e35648e2 Fixed legacy date format 2017-02-01 10:11:19 +01:00
Brent Shepherd 7a7c0fbce6 Add WC_Abstract_Order::get_valid_statuses()
So that classes which extend WC_Abstract_Order can define custom statuses
specifically for their order type and have those used for validation in
WC_Abstract_Order::set_status() instead of only the order statuses defined
by wc_get_order_statuses().

For example, the subscription order type has a number of custom order statuses,
like 'wc-active' and 'wc-expired', which do not apply to orders but are valid
statuses for WC_Subscription objects, which extend WC_Abstract_Order.
2017-01-31 15:00:03 -08:00
Caleb Burks df7f3533bc Fix wording on deprecation messages 2017-01-30 23:40:21 -06:00
Claudio Sanches 346e1ea1e0 Merge pull request #12996 from woocommerce/rest-api-missing-types-args
REST API Types
2017-01-27 14:49:35 -02:00
Brent Shepherd 0e393da2cd Fix woocommerce_order_add_product deprecation msg 2017-01-26 16:58:47 -08:00
Brent Shepherd 5e77311384 Fix deprecated action messages
Don't end sentence with double .. and instead of "Replace with Use CRUD"
just say "Replace with CRUD"
2017-01-26 16:44:28 -08:00
Mike Jolley e930ccd16e object types to fix unit tests 2017-01-26 20:58:55 +00:00
Mike Jolley 82d7fe6e73 Added more missing args and types 2017-01-26 20:33:39 +00:00
Mike Jolley b727c61da7 Missing arg and setting types 2017-01-26 20:06:18 +00:00
Mike Jolley 2d23705431 ID arg definitions 2017-01-26 19:22:57 +00:00
Mike Jolley def35a5aa2 Cast request ids to int 2017-01-26 18:34:11 +00:00
Justin Shreve 474a307420 Introduce get_tax_class_slugs. 2017-01-25 13:38:13 -08:00
Mike Jolley 0df50c59a3 Merge pull request #12972 from woocommerce/log-handler-interface
Add log handler interface
2017-01-25 00:42:50 +00:00
Mike Jolley 3a104df5bd Merge pull request #12966 from thenbrent/dry_get_data
Remove redundant WC_Product::get_data() method
2017-01-25 00:12:16 +00:00
Justin Shreve dcecf0f228 Fix get_hook_prefix format 2017-01-24 11:02:06 -08:00
Brent Shepherd 2cf401f60f Delete WC_Product::get_data()
It's identical to WC_Data::get_data(), which is already inherited from
WC_Abstract_Legacy_Product (which extends WC_Data::get_data()).
2017-01-24 10:44:51 -08:00
Jon Surrell 8e0f40d3d1 Add WC_Log_Handler_Interface
Abstract class `WC_Log_Handler` implements interface
2017-01-24 14:10:05 +01:00
Mike Jolley eb2b9d78f8 Merge pull request #12947 from woocommerce/improve-rest-api-error-data
Allow pass error data using WC_Data_Exception
2017-01-24 12:45:49 +00:00
Claudio Sanches bac0b299c4 Include conflicted product ID when trying to create a product with duplicated SKU 2017-01-23 17:34:49 -02:00
Claudio Sanches e23ddabfea Allow WC_Data_Exception have extra error data 2017-01-23 17:29:16 -02:00
Claudio Sanches 03b34fb738 [REST API] Improved messages for term_exists error 2017-01-23 17:07:36 -02:00
Claudio Sanches 10a9baeada [REST API] Fixed PHP notices while trying to set product category parent as 0 2017-01-23 16:44:22 -02:00
Mike Jolley 66914966fb Adjust meta saving code throughout
#12885
2017-01-23 11:30:53 +00:00
Brent Shepherd a1cd7eee42 Fix get_price_html_from_to() deprecation
WC_Product::get_price_html_from_to() was incorrectly using
wc_format_sale_price() as its replacement in WC 2.7; however,
wc_format_price_range() is a more suitable replacement.
2017-01-19 13:51:23 -08:00
Claudio Sanches bd655af072 Restore attributes ordering, closes #12847 2017-01-16 21:11:56 -02:00
Claudio Sanches 20032fd170 Fixed declaration of is_on_sale() compatible with WC_Product::is_on_sale 2017-01-16 19:59:53 -02:00
roykho 11d0d26df7
Fix typo on variable when it should be 2017-01-16 12:54:59 -08:00
Manos Psychogyiopoulos 892d5da7e9 get prices in 'edit' context when updating meta 2017-01-16 17:33:30 +02:00
Claudio Sanches 9c27661dea Synchronized with master 2017-01-12 17:53:15 -02:00
Mike Jolley b240e10b91 Merge branch 'pr/12756' 2017-01-11 12:19:30 +00:00
Mike Jolley 11015c4b06 Pass products around and change how wc_format_stock_for_display gets called so $product is available. 2017-01-11 12:17:18 +00:00