Commit Graph

128 Commits

Author SHA1 Message Date
Mike Jolley 31cd2dcb90 Merge pull request #13853 from woocommerce/crud-security-hardening
CRUD security/hardening
2017-04-03 11:09:38 +01:00
Mike Jolley 8a201b64c5 Only set dates if set/not null
Fixes #13848
2017-03-31 12:38:18 +01:00
Mike Jolley 14802a0307 Remove double unserialization 2017-03-31 12:10:20 +01:00
Mike Jolley 399c141377 Fix slug updating in CRUD
Fixes #13824
2017-03-29 13:41:23 +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 0ad1f6a63f Merge pull request #13709 from woocommerce/fix-13708
Timezone/DST fixes
2017-03-24 10:25:08 +00:00
Mike Jolley 7e462b9cca Data store date handling 2017-03-23 00:10:29 +00:00
Mike Jolley 3b35d95c6a Use gmdate and GMT in data stores so times are not changed 2017-03-22 12:01:38 +00:00
Mike Jolley c4c8edee5f Remove order and product factory cache 2017-03-21 23:37:38 +00:00
Mike Jolley 9bcfcb82c5 Merge branch 'master' into remove-product-internal-meta-keys
# Conflicts:
#	includes/data-stores/class-wc-product-data-store-cpt.php
2017-03-20 16:13:45 +00:00
Claudio Sanches 2d400bffd2 Remove post related internal post keys froom products 2017-03-17 17:37:38 -03:00
Claudio Sanches 1a87792109 Remove some product internal meta keys 2017-03-17 17:30:38 -03:00
Claudio Sanches 59c2849736 Changed version 2.7 to 3.0 2017-03-15 13:36:53 -03:00
Mike Jolley 9bee678819 API updates 2017-03-13 21:36:31 +00:00
Mike Jolley 1bac579df7 Date getters and setters 2017-03-13 19:52:44 +00: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 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 b69988fe39 Correct changes in variation data update and fix context 2017-02-16 16:07:11 +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
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
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 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
Justin Shreve 8a6bae374f Switch from get_the_title to the post objects post_title. 2017-02-09 08:43:48 -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 dce81b4d4e Use store's decimal settings when figuring out what's a sale product 2017-02-08 09:04:13 -08: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 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 90fd0da7d0 Fire actions for updated props 2017-01-24 21:38:02 +00: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 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
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 b749b654bc Fire action on type change 2017-01-11 11:48:31 +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
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 6858824de1 missing variable 2016-12-20 13:37:20 +00:00
Mike Jolley 2f9aeed248 Missing variable 2016-12-20 12:48:13 +00:00
Mike Jolley c78e5cf2ec Trigger actions after data is saved
#12648
2016-12-19 16:40:53 +00:00
Mike Jolley 95794b720c Only set date_created if empty
Fixes #12579
2016-12-13 14:22:59 +00:00
Mike Jolley 1e80db6021 Force meta to be written on creation
#12567
2016-12-12 13:56:35 +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
Mike Jolley 767a1e500e Helper to get term ids 2016-12-08 17:01:39 +00:00
Mike Jolley 12608af03a Sorting handling 2016-12-08 14:28:51 +00:00
Mike Jolley 56e9244b8b Update vis during create 2016-12-08 12:38:30 +00:00
Mike Jolley 47fbae4d26 Product Visibility Taxonomies (#12527)
* Convert visibility and featured to taxonomy

* Comment

* Add missing tax_queries

* Only check SKU after read.

* Added visibility term for outofstock products to speed those queries up al

* wc_bool_to_string
2016-12-08 10:56:45 +00:00
Justin Shreve f9891b1744 Pass product slug to wp_set_object_terms directly 2016-12-07 12:55:34 -08:00
Manos Psychogyiopoulos 08b81f73c6 add $product argument to `woocommerce_[variation_]set_stock_status` action 2016-11-28 19:03:33 +02:00
Mike Jolley b9bb8eabba Fix order item meta 2016-11-24 11:50:34 +00:00
Mike Jolley 885dad605a Interface naming 2016-11-22 13:54:51 +00:00
Justin Shreve 174aa38be6 Start moving meta to normal stores, instead of a separate meta store. 2016-11-22 04:05:05 -08:00
Mike Jolley 32de28355a Merge branch 'master' into order-data-store
# Conflicts:
#	includes/admin/meta-boxes/class-wc-meta-box-order-data.php
2016-11-21 14:45:46 +00:00
Mike Jolley 73287b08a0 Move product query to store
Closes #12402
2016-11-21 12:25:00 +00:00
Mike Jolley b1565cf0d6 Download update routine and interface 2016-11-18 19:29:37 +00:00
Claudio Sanches e1aeba9f21 Remove all wp_get_post_terms() and wp_get_object_terms() terms occurrences 2016-11-17 17:02:05 -02:00
Justin Shreve 20fca44334 Handle product quick and bulk edit. 2016-11-16 12:54:53 -08:00
Mike Jolley 76b32c9aa5 WIP - Product CRUD (#12065)
* Created function to get the catalog visibility options

* First methods for WP_Product crud

* Product set methods

* Fixed several erros while setting data

* First methods for WP_Product crud

* Product set methods

* Fixed several erros while setting data

* Hardcode the get_type per product class

* Initial look through getters and setters and abstract data

* Missing var

* Add related product functions and deprecate those in class.

* No need to exclude ID

* Fixed coding standards and improved the docblocks

* Get cached terms from wc_get_related_terms()

* Fixed wrong variable in wc_get_related_terms

* Use count() instead of sizeof()

* Sanitize ids later

* Remove unneeded comments

* wc_get_product_term_ids instead of related wording and use in other places.

get_the_terms is used here and also handles caching, something
wp_get_post_terms does not.

* Clean up the abstract product class a bit, deprecate two functions we have renamed, make update & create work properly, and add some tests for it.

* Bump template version

* Handle PR feedback: Remove duplicate regular_price update, allow changing of post status for products, remove deprecation for get_title since we might still offer it as a function

* Made abstract function useful

* External Product CRUD

* _virtual meta should be 'no', not taxable, in product unit test helper

* Grouped product class

* Tests

* Move children to meta and update test

* Use get_upsell_ids

* Spacing in query

* Moving and refactoring methods

* Availability html

* Tidy/add todos

* Rename method

* Put back review functions (still todo)

* missing $this

* get_price_including_tax/excluding_tax functions

* wc_get_price_to_display

* Price handling

* [Product CRUD] Variable (#12146)

* [Product CRUD] Variable Products

* Handle PR feedback.

* [Product CRUD] Grouped Handling (#12151)

* Handle grouped product saving

* Update routine

* [Product CRUD] Product crud terms (#12149)

* Category and tag id handling

* Replace template functions

* Remove todo

* Handle default name in save function

* Product crud admin save routine (#12174)

* Initial props

* Work on admin saving

* Set/get attributes

* Atom was moaning about this before but no longer.

* Update get_shipping_class

* WC_Product_Attribute

* Use getter in admin panel

* Fix attribute saving

* Spacing

* Fix comment

* wc_implode_text_attributes helper function

* [Product CRUD] Product crud admin use getters (#12196)

* Initial props

* Work on admin saving

* Set/get attributes

* Atom was moaning about this before but no longer.

* Update get_shipping_class

* WC_Product_Attribute

* Use getter in admin panel

* Fix attribute saving

* Move settings into new files

* Refactor panels and use getters

* Use getters for variation panel

* Revert save variation changes for now

* Add todos

* Fix downloads

* REST API CRUD Updates

* Additional API updates/fixes. Added some todos

* Fix final failing tests and implementing setters/getters and attributes functionality.

* Fix comparison for is_on_sale and remove download_type from WC_Product.

* Add a wc_get_products wrapper.

* Remove the download type input from the product data metabox for downloadable products. (#12221)

* [Product CRUD] Variations - setters, getters and admin. (#12228)

* Started on variation changes

* Stock functions

* Variation class

* Bulk change ->id to get_id() to fix variation form display

* Missing status

* Fix add to cart

* Start on stored data save

* save variation

* Save_variations

* Variation edit panel

* Save variations code works.

* Remove stored data code and fix save

* Improve legacy class

* wc_bool_to_string

* prepare_set_attributes

* Use wc_get_products

* More feedback fixes

* Feedback fixes

* Implement CRUD in the legacy REST API

* Handle PR feedback

* [Product CRUD] Getter setter proxy methods (#12236)

* Started on variation changes

* Stock functions

* Variation class

* Bulk change ->id to get_id() to fix variation form display

* Missing status

* Fix add to cart

* Start on stored data save

* save variation

* Save_variations

* Variation edit panel

* Save variations code works.

* Remove stored data code and fix save

* Improve legacy class

* wc_bool_to_string

* prepare_set_attributes

* Use wc_get_products

* More feedback fixes

* get_prop implementation in abstract and data classes

* Implement set_prop

* Change handling

* Array key exists

* set_object_read

* Use get_the_terms() instead of wp_get_post_terms()

wp_get_post_terms() is a wrapper around wp_get_object_terms() which does not
use the object cache, and generates a database query every time it is used.

get_the_terms() however can use data from the object cache if present.

* Allow WP_Query to preload post data, and meta in wc_get_products()

Allow WP_Query to bulk query for post data and meta if more than
just IDs are requested from wc_get_products(). Reduces query count
significantly.

* [Product CRUD] Variable, variation, notices, and stock handling (#12277)

* No longer needed

* Remove old todos

* Use getters in admin list

* Related and upsells update for CRUD

* Fix notice in gallery

* Variable fixes and todos

* Context

* Price sync

* Revert variation attributes change

* Return parent data in view context

* Defer term counting

* wc_find_matching_product_variation

* Stock manage tweaks

* Stock fixes

* Correct id

* correct id

* Better sync

* Data logic setter fix

* feedback

* First methods for WP_Product crud

* Product set methods

* Fixed several erros while setting data

* Hardcode the get_type per product class

* Initial look through getters and setters and abstract data

* Missing var

* Fixed coding standards and improved the docblocks

* Get cached terms from wc_get_related_terms()

* Fixed wrong variable in wc_get_related_terms

* Use count() instead of sizeof()

* Add related product functions and deprecate those in class.

* No need to exclude ID

* Sanitize ids later

* Clean up the abstract product class a bit, deprecate two functions we have renamed, make update & create work properly, and add some tests for it.

* Remove unneeded comments

* wc_get_product_term_ids instead of related wording and use in other places.

get_the_terms is used here and also handles caching, something
wp_get_post_terms does not.

* Handle PR feedback: Remove duplicate regular_price update, allow changing of post status for products, remove deprecation for get_title since we might still offer it as a function

* External Product CRUD

* _virtual meta should be 'no', not taxable, in product unit test helper

* Bump template version

* Made abstract function useful

* Grouped product class

* Tests

* Move children to meta and update test

* Use get_upsell_ids

* Spacing in query

* Moving and refactoring methods

* Availability html

* Tidy/add todos

* Rename method

* Put back review functions (still todo)

* missing $this

* get_price_including_tax/excluding_tax functions

* wc_get_price_to_display

* Price handling

* [Product CRUD] Variable (#12146)

* [Product CRUD] Variable Products

* Handle PR feedback.

* [Product CRUD] Grouped Handling (#12151)

* Handle grouped product saving

* Update routine

* [Product CRUD] Product crud terms (#12149)

* Category and tag id handling

* Replace template functions

* Remove todo

* Handle default name in save function

* Product crud admin save routine (#12174)

* Initial props

* Work on admin saving

* Set/get attributes

* Atom was moaning about this before but no longer.

* Update get_shipping_class

* WC_Product_Attribute

* Use getter in admin panel

* Fix attribute saving

* Spacing

* Fix comment

* wc_implode_text_attributes helper function

* [Product CRUD] Product crud admin use getters (#12196)

* Initial props

* Work on admin saving

* Set/get attributes

* Atom was moaning about this before but no longer.

* Update get_shipping_class

* WC_Product_Attribute

* Use getter in admin panel

* Fix attribute saving

* Move settings into new files

* Refactor panels and use getters

* Use getters for variation panel

* Revert save variation changes for now

* Add todos

* Fix downloads

* REST API CRUD Updates

* Additional API updates/fixes. Added some todos

* Fix final failing tests and implementing setters/getters and attributes functionality.

* Fix comparison for is_on_sale and remove download_type from WC_Product.

* Add a wc_get_products wrapper.

* Remove the download type input from the product data metabox for downloadable products. (#12221)

* [Product CRUD] Variations - setters, getters and admin. (#12228)

* Started on variation changes

* Stock functions

* Variation class

* Bulk change ->id to get_id() to fix variation form display

* Missing status

* Fix add to cart

* Start on stored data save

* save variation

* Save_variations

* Variation edit panel

* Save variations code works.

* Remove stored data code and fix save

* Improve legacy class

* wc_bool_to_string

* prepare_set_attributes

* Use wc_get_products

* More feedback fixes

* Feedback fixes

* Implement CRUD in the legacy REST API

* Handle PR feedback

* [Product CRUD] Getter setter proxy methods (#12236)

* Started on variation changes

* Stock functions

* Variation class

* Bulk change ->id to get_id() to fix variation form display

* Missing status

* Fix add to cart

* Start on stored data save

* save variation

* Save_variations

* Variation edit panel

* Save variations code works.

* Remove stored data code and fix save

* Improve legacy class

* wc_bool_to_string

* prepare_set_attributes

* Use wc_get_products

* More feedback fixes

* get_prop implementation in abstract and data classes

* Implement set_prop

* Change handling

* Array key exists

* set_object_read

* Use get_the_terms() instead of wp_get_post_terms()

wp_get_post_terms() is a wrapper around wp_get_object_terms() which does not
use the object cache, and generates a database query every time it is used.

get_the_terms() however can use data from the object cache if present.

* [Product CRUD] Variable, variation, notices, and stock handling (#12277)

* No longer needed

* Remove old todos

* Use getters in admin list

* Related and upsells update for CRUD

* Fix notice in gallery

* Variable fixes and todos

* Context

* Price sync

* Revert variation attributes change

* Return parent data in view context

* Defer term counting

* wc_find_matching_product_variation

* Stock manage tweaks

* Stock fixes

* Correct id

* correct id

* Better sync

* Data logic setter fix

* feedback

* Prevent notices

* Handle image_id from parent

* Fix error

* Remove _wc_save_product_price

* Remove todo

* Fixed wrong variation URLs

* Fixed undefined $image_id in WC_Product_Variation::get_image_id()

* Allow wc_rest_prepare_date_response() handle timestamps

* Updated get methods on REST API for variations

* Use variations CRUD to save variations metadata

* [Product CRUD] Abstract todos (#12305)

* Get dimensions and weights, with soft deprecation

* Product attributes

* Ratings

* Fix read method

* Downloads

* Feedback

* Revert "[Product CRUD] Abstract todos (#12305)"

This reverts commit 9a6136fcf8.

* Remove deprecated get_variation_id()

* New default attributes method

* [Product CRUD] Product Datastore (#12317)

* Fix up tests in the product/* folder.

* Handle data store updates for grouped, variable, external, simple, and general data store updates for products.

* Variations & variable changes.

* Update -functions.php calls to use data store.

* Add an interface for the public product data store methods.

* Finished product factory tests

* Correctly delete in the api, fix up some comments, and implement an interface for the public variable methods.

* Fix up delete in all versions of the api

* Handle feedback

* Match protected decloration to parent

* Product crud abstract todos (#12316)

* Get dimensions and weights, with soft deprecation

* Product attributes

* Ratings

* Fix read method

* Downloads

* Feedback

* Fix up store

* Fixed method returning in write context

* Fix error in variation admin

* Check for parent value - fixes tax class

* Remove old/complete todos

* Allow set tax class as "parent"

* Removed duplicated sync

* Fixed wrong variation URLs

* Fixed undefined $image_id in WC_Product_Variation::get_image_id()

* Allow wc_rest_prepare_date_response() handle timestamps

* Updated get methods on REST API for variations

* Use variations CRUD to save variations metadata

* Remove deprecated get_variation_id()

* New default attributes method

* Fixed method returning in write context

* Allow set tax class as "parent"

* Removed duplicated sync

* Fixed coding standards

* TODO is not accurate.

* Should pass WC_Product instancies to WC_Comments methods (#12327)

* Use new method in abstract order class to prevent headers sent issue in tests

* Fixed variable description in REST API

* Updated how create initial product variation

* Fixed a few fatal errors and warnings in Products CRUD (#12329)

* Fixed a few fatal errors and warnings in Products CRUD

* Fixed sync functions

* Add variations CRUD to legacy API (#12331)

* Apply crud to variable products in legacy API v1

* New REST API do not need fallback for default attributes

* Apply variations CRUD to legacy API v2

* Legacy v2 - save default attributes

* Variations in legacy API v2 do not have descriptions

* Fixed legacy API v2 variations params

* Applied variations CRUD to legacy API v3

* Sync before save in legacy apis

* Punc

* Removed API todos

* Removed test

* Products endpoint tweaks (#12354)

* Var type already normalized on CRUD

* Let Product CRUD handle with validation, sanitization and conditional checks

* Set downloads using WC_Product_Download

* Stop try catch exceptions more than one time

* Handle WC_Data_Exception in legacy API

* Complete remove products when fails on creating

* On creating I mean!

* Already have a method to complete delete products

* Fixed standards using WP CodeSniffer

* get_the_terms() returns false when empty

* get_manage_stock returns boolean

@claudiosanches

* Merge conflict

* Variations API endpoint fixes

* Product CRUD improvements (#12359)

* args is not used any more - remove todo

* Added test for attributes

* wc_get_price_excluding_tax usage

* parent usage

* Fix rating counts

* Test fixes

* Cleanup after tests

* Make sure status transition code runs even during API calls, not just in admin.

* Default visibility

* Fix attribute setting in API

* Use get name instead of get title

* variation id usage

* Improved cross sell templates

* variation_data

* Grouped product sync

* Notices

* Sync is not needed in API

* Delete

* Rename interfaces

* Update counts in data store
2016-11-16 12:38:24 +00:00
Mike Jolley 599a2ad296 Product CRUD improvements (#12359)
* args is not used any more - remove todo

* Added test for attributes

* wc_get_price_excluding_tax usage

* parent usage

* Fix rating counts

* Test fixes

* Cleanup after tests

* Make sure status transition code runs even during API calls, not just in admin.

* Default visibility

* Fix attribute setting in API

* Use get name instead of get title

* variation id usage

* Improved cross sell templates

* variation_data

* Grouped product sync

* Notices

* Sync is not needed in API

* Delete

* Rename interfaces

* Update counts in data store
2016-11-16 12:17:00 +00:00
Claudio Sanches 096622c9e4 Should pass WC_Product instancies to WC_Comments methods (#12327) 2016-11-11 18:13:56 +00:00
Mike Jolley ac6bda2f62 Product crud abstract todos (#12316)
* Get dimensions and weights, with soft deprecation

* Product attributes

* Ratings

* Fix read method

* Downloads

* Feedback

* Fix up store
2016-11-11 15:31:00 +00:00
Justin Shreve 90e43d97de [Product CRUD] Product Datastore (#12317)
* Fix up tests in the product/* folder.

* Handle data store updates for grouped, variable, external, simple, and general data store updates for products.

* Variations & variable changes.

* Update -functions.php calls to use data store.

* Add an interface for the public product data store methods.

* Finished product factory tests

* Correctly delete in the api, fix up some comments, and implement an interface for the public variable methods.

* Fix up delete in all versions of the api

* Handle feedback

* Match protected decloration to parent
2016-11-11 14:31:15 +00:00