Commit Graph

263 Commits

Author SHA1 Message Date
Aristeides Stathopoulos 734f284fa4 WordPress.PHP.YodaConditions.NotYoda 2016-09-08 01:32:24 +03:00
Aristeides Stathopoulos d4e3faf014 PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket 2016-09-02 04:51:31 +03:00
Mike Jolley 402d0ff077 Merge branch 'master' into pr/11797
# Conflicts:
#	includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php
#	includes/api/class-wc-rest-coupons-controller.php
#	includes/class-wc-coupon.php
#	tests/unit-tests/api/coupons.php
#	tests/unit-tests/coupon/crud.php
2016-09-01 11:43:31 +01:00
Mike Jolley 0a3506777b Inline comments to make this clearer 2016-08-31 17:52:03 +01:00
Gabor Javorszky 219480b329 Save the version on the property too 2016-08-31 16:21:17 +01:00
Gabor Javorszky 9cfa231167 Fixes reset cache and version assignment for variable product prices
Fixes #11812

$this->array was only used to return to the user. Comparison was done with $prices_array, which did not contain the version information because it was never saved in the transient.
2016-08-31 11:12:49 +01:00
Aristeides Stathopoulos fb62d280b5 WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore 2016-08-27 09:07:42 +03:00
Aristeides Stathopoulos 72ee94d11b WordPress.Arrays.ArrayDeclaration.SpaceBeforeComma 2016-08-27 05:46:40 +03:00
Aristeides Stathopoulos b063bcfe4c last item in a multiline-array should end in a comma 2016-08-27 04:46:45 +03:00
Mike Jolley b0064bddf6 Remove boolval 2016-08-04 11:12:14 +01:00
Mike Jolley 5a9dacd595 Show variable weights/dimensions even when parent values are not set. 2016-08-03 16:07:34 +01:00
Mike Jolley 579175257f Add transient version to price hash
Closes #11520 @claudiosmweb
2016-07-25 13:33:35 +01:00
Claudio Sanches 08f95481e0 Normalize the "Read more" button text, closes #11319 2016-06-30 15:16:26 -03:00
Mike Jolley 594641422d Show read more if variable product is out of stock 2016-06-07 14:34:27 +01:00
Mike Jolley 3fd15ad50f Unused vars and code docs 2016-06-06 18:57:24 +01:00
Manos Psychogyiopoulos 35ff166a85 woocommerce_variation_prices filter runs only for the first hashed prices array loaded from the transient 2016-05-25 00:54:07 +03:00
Mike Jolley e552c3c916 Remove filter to hide variations with no prices in get_children()
#10854
2016-05-10 18:23:16 +01:00
Mike Jolley edbb03a5d8 Only exclude variations with no price if filter is set
Closes #10854
2016-05-05 16:05:40 +01:00
Mike Jolley be9b7bd4b5 If no variation ID is set, do a match
Closes #10737
2016-04-20 12:35:06 +01:00
Mike Jolley 3a5feddbf5 [2.5] Set captions 2016-03-30 11:15:34 +01:00
Mike Jolley 00a6fe8682 [2.5] Allow big selects when getting variations 2016-03-08 11:33:04 +00:00
Mike Jolley c469ab920b Use wpdb query instead of looping over children
Closes #10195

cc @claudiosmweb

Since this uses `$this->get_children( true );` it will also hide out of
stock variation attributes if that setting is enabled.
2016-02-15 15:53:43 +00:00
Mike Jolley 3dba3378c2 Merge pull request #10315 from woothemes/layered-nav-wp-query
Layered Nav Improvements
2016-02-12 11:59:40 +00:00
Mike Jolley fd38adcc36 Format variations to same type
Fixes #10310
2016-02-11 15:22:51 +00:00
Mike Jolley 5b0abaaa1b Sync min and max price for better filtering! 2016-02-09 20:16:08 +00:00
Mike Jolley a78edb2af2 [2.5] If an attribute meta key is not set, technically its 'any', so should match. Prevents issues when meta data is missing after renaming attributes
@claudiosmweb please test :)

#10272
2016-02-04 18:25:06 +00:00
Mike Jolley 35e45e6075 Make price function clearer
@tamarazuk @franticpsyx @daigo75 Hopefully this makes it clearer which
values are returned and when the filter is ran.
2016-01-13 15:07:47 +00:00
Fredrik Forsmo f1920cb882 Improve docblock comments in various WC_Product classes
* Added comments to methods that was `method function`
2016-01-06 16:15:00 +01:00
Mike Jolley 8b9bdbb228 Product version storage to invalidate cache when needed
#9922 for @daigo75
2015-12-31 16:31:20 +00:00
Mike Jolley 7c7e21be50 Only use the 'function' portion when generating price hashes
Keeps hashes the same after page load when a plugin uses a class method
callback or anonymous function Closes #9922 @claudiosmweb
2015-12-31 16:21:12 +00:00
Mike Jolley 429fee1703 JSON instead of serialise should reduce storage size
#9922
2015-12-31 13:15:01 +00:00
Mike Jolley 0b678ab2af Tweak save logic to set _price for variables/groups via sync functions only
Closes #9892
2015-12-23 13:08:45 +00:00
Mike Jolley 496eb3385e srcset sometimes is false. 2015-12-09 10:29:41 +00:00
Mike Jolley 61c3e74d4f srcset should not be set to 'false' 2015-12-07 11:57:02 +00:00
Mike Jolley 12db1d4637 Notify users of no variations but leave status as is.
Closes #9713
2015-12-03 10:14:00 +00:00
Mike Jolley 75529edbe5 Merge branch 'pr/9628' 2015-11-27 13:00:39 +00:00
Mike Jolley 03d9239f40 Correct variable name 2015-11-27 13:00:08 +00:00
Mike Jolley 615c262f6f Function exists for wp_get_attachment_image_srcset and sizes
Sizes #9714
2015-11-27 11:30:47 +00:00
Tiago Noronha 3fdec7f4a8 Init added variables if product doesnt have featured image. 2015-11-24 23:00:25 +00:00
Tiago Noronha 105105db06 Adds support for srcset and sizes attributes in variation images. 2015-11-23 16:35:11 +00:00
Dominic 5ef59c511b Optimize filter loop
The current method loops through every defined hook in the WordPress
environment (over 400 on one of my tests). This method only checks the 3
filters in question.
2015-11-17 00:27:44 -08:00
Mike Jolley b59ec6de76 Move var definition to abstract 2015-11-14 16:39:53 +00:00
Mike Jolley 3a096b3b64 Remove transient from get_total_stock and combine into abstract
Grouped and variable methods were identical. Caching benefit comes from
get_children
2015-11-14 16:34:47 +00:00
Mike Jolley 70d9f58811 Version not needed for wc_var_prices
This transient doesn’t need to expire often because the hashes will be
unique if taxes change.

This change means a variable product will only use 1 transient rather
than many.
2015-11-13 20:01:42 +00:00
Scrutinizer Auto-Fixer 08efaf84df Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
2015-11-05 16:05:03 +00:00
Claudio Sanches ee30b5b308 Fixed php docs standards 2015-11-03 11:31:20 -02:00
Mike Jolley 6027b355ca Further get_variation_prices tweaks
For 2.5, I’ve adjusted the caching to store 1 transient per variable
product. The cache key etc is still needed, but its stored within a
single transient instead of several.

This should prevent exponential growth of transient data for users.

Thoughts?

@daigo75 @franticpsyx @claudiosmweb
2015-10-09 12:49:39 +01:00
Mike Jolley 84f83e0bf4 Fix return value @roykho 2015-10-05 14:39:08 +01:00
roykho 5ba6ff1dac fix variation image flicker issue when default variations are set closes #7904 2015-10-02 03:45:11 +02:00
Diego Zanella 5da98ce782 Fixed loading of variation prices
The original method loaded the prices once, then stored them in a property of the product instance. Any subsequent calls to WC_Product_Variable::get_variation_prices() would get the stored prices, regardless of the value of the $display argument.
2015-09-25 16:11:41 +01:00
Mike Jolley 3dbe9ccd95 Better fallback for ajax variations in case sync_attributes has ran 2015-09-14 16:50:58 +01:00
Mike Jolley fc78f85bc6 Merge branch 'pr/9034' 2015-09-14 15:56:38 +01:00
Mike Jolley 3a1bcd8e7d Store prices in class to prevent running get_variation_prices multiple times 2015-09-14 15:09:57 +01:00
Mike Jolley 2d90e1c6c6 Ensure _product_version checks act the same regardless of the attributes being checked 2015-09-14 12:12:05 +01:00
Mike Jolley 8ec5986d48 Tweak hash logic 2015-09-09 22:29:54 +01:00
Manos Psychogyiopoulos e3dad9106f elseif 2015-09-07 19:17:33 +03:00
Manos Psychogyiopoulos d9d11974fe introduce context in transient with price filters 2015-09-07 19:13:41 +03:00
Manos Psychogyiopoulos 68e24c8f8a no filters allowed when generating variable product price transients 2015-09-03 19:04:31 +03:00
Mike Jolley 28da8a40d8 Tweak wc_var_prices naming to allow them to be flushed on save 2015-08-26 12:28:04 +01:00
Mike Jolley ae21b511f0 Support 0 value attributes 2015-08-24 13:32:20 +01:00
Mike Jolley ae207466d4 Ajax variation < 2.4 attribute name handling. 2015-08-23 21:47:04 +01:00
Mike Jolley dc1798f942 woocommerce_variable_children_args hook. 2015-08-13 23:35:41 +01:00
Diego Zanella 5b29d23daf Added filter for Variable Products, as suggested in #8820
* The new filter allows to alter the query used to retrieve children of a variable product.
2015-08-13 22:42:16 +01:00
Mike Jolley 56b6c0ab9c Link to full image
Closes #8809
2015-08-13 16:55:32 +01:00
Mike Jolley a52619c344 Ajax variation handling when 'any' attribute is set. 2015-08-13 13:57:26 +01:00
Mike Jolley 61f7dd428e use shop_single instead of full image size for variations.
Closes #8764
2015-08-11 12:54:26 +01:00
Mike Jolley 42e99286c7 If all variations are out of stock, maintain pricing. 2015-08-11 10:33:47 +01:00
Mike Jolley 77b2316d80 Merge pull request #8754 from JeroenSormani/is_on_sale
FIx is_on_sale bug on variable products
2015-08-10 15:43:35 +01:00
JeroenSormani 95609928ba FIx is_on_sale bug on variable products 2015-08-10 16:36:40 +02:00
Mike Jolley 7363c85a2c Get filtered variation prices #8753 2015-08-10 15:34:10 +01:00
Mike Jolley 060fb16e2e Move Pre 2.4 handling for attributes - DRY
@claudiosmweb @franticpsyx
2015-07-28 16:20:51 +01:00
Mike Jolley 6626c68175 When syncing OLD products, update the attributes to 2.4 standard 2015-07-28 15:13:25 +01:00
Mike Jolley 794af1c013 When the stock level is changed via update_post_meta ensure the stock_status is kept in sync
Closes #8605
2015-07-27 19:04:08 +01:00
Mike Jolley 9a7893ba23 Moved variation dropdowns logic into wc_dropdown_variation_attribute_options() 2015-07-27 16:42:22 +01:00
Mike Jolley dcd273d343 Rename transient - 45 chars is max legnth 2015-07-27 10:57:14 +01:00
Claudio Sanches 9e41552342 Removed all "@return void" 2015-07-16 16:55:48 -03:00
Claudio Sanches 8d2a98eab1 Improved some docblocks 2015-07-16 16:29:01 -03:00
Mike Jolley 30b01ff9b6 Add filter to force price display 2015-07-09 16:15:05 +01:00
Mike Jolley 5f8a5bcb63 We don't need get_transient_version for children transients because other products do not affect this. 2015-07-09 16:02:26 +01:00
Mike Jolley 65f19d5ca7 Ajax variation handling
If there are more variations than the threshold allows (set to 20
currently) this loads the matching variation via ajax instead of inline
in the HTML. #8477
2015-07-09 15:56:20 +01:00
Mike Jolley 622b11ae9f Add version check to prevent pre-2.4 logic kicking in when not needed
@claudiosmweb
2015-06-16 15:10:53 +01:00
Mike Jolley 12396f4296 Attempted bw compat by comparing sanitised text to real text 2015-06-11 15:42:18 +01:00
Mike Jolley 89f7e15052 Save full version of text based attributes when dealing with variations 2015-06-11 14:43:02 +01:00
Mike Jolley aaaef5bfcf [2.3] Incorrect wc_product_total_stock_ transient
Closes #8337
2015-06-10 18:28:34 +01:00
Mike Jolley 5771969c2c Prevent notices in get_children 2015-06-09 10:32:40 +01:00
Mike Jolley 68974655d6 Tweak visible child product query and cache 2015-06-08 13:18:23 +01:00
roykho b812b2fd94 add dynamic variation description feature 2015-05-14 10:56:26 -07:00
Mike Jolley 906940791a Merge branch 'variation-prices-sync' 2015-05-01 15:01:14 +01:00
Illimar Tambek 3e9c56a5ca Pass current variation to woocommerce_hide_invisible_variations filter 2015-04-29 12:16:58 +03:00
Nicola Mustone d2af01df5b scrutinizer suggested tweaks 2015-03-27 16:15:40 +01:00
Mike Jolley 302fca886c ID needs to be part of transient 2015-03-25 16:27:11 +00:00
Mike Jolley 8cb2ca86d7 Store variation ID in transient 2015-03-25 16:23:19 +00:00
Mike Jolley c76a08aad2 woocommerce_variation_prices filter 2015-03-25 15:48:51 +00:00
Mike Jolley 01c13a52cd Fix price/sale price listings 2015-03-25 15:23:28 +00:00
Mike Jolley 99fcb77262 woocommerce_get_variation_prices_hash array 2015-03-25 14:52:33 +00:00
Mike Jolley 0ab0a12156 _has_multiple_variation_tax_rates no longer needed 2015-03-25 13:37:11 +00:00
Mike Jolley 9f50d41b97 New approach to getting min/max variation prices using transients
New method will get all prices and store in array format. Cached based
on user location (tax) and product transient hash.

Fixes #6504
2015-03-25 13:35:49 +00:00
Mike Jolley d9455994c8 Use 30 days instead of year for transients to avoid bugs in memcache plugins.
Closes #7520
2015-02-24 12:02:56 +00:00
Scrutinizer Auto-Fixer 19f660171e Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
2015-01-23 14:37:20 +00:00
Mike Jolley 186f223d92 Fix indents in #7174 2015-01-23 11:17:27 +00:00
Diego Zanella dbeeb6d7b5 Fixed bug in is_on_sale() method 2015-01-22 16:05:59 +00:00
Diego Zanella 04bf4fecd2 Added/altered product filters to make them work consistently
* WC_Product_Variable::get_variation_regular_price() now always calls the "woocommerce_get_variation_regular_price" filter (removed early exit).
* WC_Product_Variable::get_variation_sale_price() now always calls the "woocommerce_get_variation_sale_price" filter (removed early exit).
* WC_Product_Variable::is_on_sale() now calls the "woocommerce_product_is_on_sale" filter.
* WC_Product_Grouped::is_on_sale() now calls the "woocommerce_product_is_on_sale" filter.
2015-01-22 13:02:43 +00:00
Mike Jolley 36841589cf Merge pull request #7123 from splashingpixels/variation-price-issue
correctly display FREE if all prices are zero ref #6929
2015-01-16 16:14:02 +00:00
splashingpixels eee5d16844 changed comparison type to non strict in case a string is passed 2015-01-16 06:52:49 -08:00
splashingpixels 187f6729e9 correctly display FREE if all prices are zero ref #6929 2015-01-15 20:19:33 -08:00
Brent Shepherd ed0593fc4a Set variable product virtual/downloadable property
Based on whether all children are virtual/downloadable.

Fixes #7072.
2015-01-15 17:06:09 -08:00
Mike Jolley 7ef8f4d156 Invalidate unknown product transients Closes #6815 2014-12-30 15:27:08 +00:00
Mike Jolley 4a57cd3f7d 'Free' for variable products without a range of prices. Closes #6929 2014-12-30 15:13:34 +00:00
Spencer Hill d8c8d37fd6 Using post_status of 'any' causes a conflict with the WP Invoice Plugin by Usability Dynamics resulting in the Select Box for Variable Subscriptions - when the WooCommerce Variable Subscriptons Plugin is installed and activated - not functioning and returning an error to the user on the front end. Since it's filtering out the Trash status, and others, anyway when being displayed on the front end we found that setting the post_status to publish resolved the issue and doesn't appear to have adverse affects elsewhere. 2014-12-19 13:21:15 -08:00
Manos Psychogyiopoulos 4b04701cc8 add display_prices in variation data
The commit introduces 3 changes:
1. It adds 2 extra fields to the available_variations array,
display_price and display_regular_price, to be used by extensions in
cases like
https://github.com/woothemes/woocommerce-product-addons/issues/19
2. Introduces a get_display_price() function in WC_Product to retrieve
product prices incl or excl tax relative to the
woocommerce_tax_display_shop setting.
3. Fixes a minor issue where passing a 0 price to
get_price_including_tax() or get_price_excluding_tax() results in a
wrong output.
2014-12-03 11:28:04 +02:00
Mike Jolley c2ce3b0d88 Tidy 2014-10-14 14:25:53 +01:00
Mike Jolley 26186f815a Fix potential error if variation doesn't exist 2014-10-09 11:20:46 +01:00
Mike Jolley 58904fcf83 Removed deprecated get_product() calls 2014-10-07 11:09:25 +01:00
Manos Psychogyiopoulos 0966519adc woocommerce_get_children filter from 2.2 2014-10-01 19:42:20 +03:00
James Koster 63f45a8720 variation visibility, based on #6182. #5661 2014-09-26 17:22:43 +01:00
Mike Jolley 744549ad13 [2.2] Use variation get_stock_quantity() for max_qty
Fixes #6339
2014-09-24 11:15:56 +01:00
shivapoudel 26d4abb88c Absolute path fix for class-wc-product-variable.php 2014-09-21 00:42:58 +05:45
Mike Jolley 3f53512c7f Fix up visibility of stock options, drop downs, and get_availability() when parent is managing stock for a variation.
Fixes #6017
2014-08-13 15:03:30 +01:00
Mike Jolley b1c76adb56 Send product object to woocommerce_stock_html filter. Closes #6016 2014-08-13 11:30:47 +01:00
Mike Jolley 7f825a98ce Tweak get_children to look for empty transient 2014-08-12 12:06:18 +01:00
Mike Jolley 0f6f04e017 Added wc_stock_amount() core function and replaced intval
#4612
2014-06-25 11:25:28 +01:00
Mike Jolley 21d37e86c2 Handle stock for self and children, as well as syncing status with the children 2014-06-24 13:03:25 +01:00
Mike Jolley b86b4c91c6 Simplify get_children and use stock status rather than stock level 2014-06-20 10:50:31 +01:00
Mike Jolley 3df6a71b96 Removed some transient clears where unnecessary 2014-06-19 12:25:10 +01:00
claudiosmweb 05a6914ebc fixed WC_Product_Variable::set_stock() compatibility with WC_Product::set_stock() 2014-05-10 17:45:14 -03:00
Tamara Zuk 7ba3089909 Backorders at variation level
Added a new select metabox for variations allowing users to control
backorders at the variation level.
Might need more testing.
ref: #5351
2014-04-21 21:13:13 -04:00
Mike Jolley 51482579d1 sync min and max prices for regular and sale prices so prices are displayed correctly when sale price is lower than a regular price of another variation 2014-03-19 10:51:07 +00:00
Mike Jolley 7f7dae0629 get_children visible only arg to hide out of stock items. Moved logic. 2014-03-19 10:06:13 +00:00
Mike Jolley b321d6297b Use is_purchasable to determine if a variation cart button is needed, and potentially show empty_price_html Closes #5137 2014-03-17 12:12:10 +00:00
Mike Jolley 7f417c0e8e Fix sale flash for out of stock sale items Closes #5119 2014-03-14 13:41:25 +00:00
Coen Jacobs 3617316357 Updated expiry times for transients 2014-03-12 12:58:41 +01:00
Coen Jacobs 03163c54b0 set_transient calls should have expiration to prevent autoloading 2014-03-07 09:29:01 +01:00
Mike Jolley ba466b3de9 Fix variation price display by checking if a variation is actually stock managed before comparing to stock amount Closes #5059 2014-03-06 12:07:28 +00:00
Mike Jolley e557ff5aec Use woocommerce_notify_no_stock_amount not 0, Closes #5035 2014-03-04 14:46:17 +00:00
Mike Jolley decfca94a4 Updated sync logic to exclude hidden and out of stock variations from the price display #5035 2014-03-04 14:44:24 +00:00
Mike Jolley a54223f910 Tweak message #4335 2014-01-08 13:38:34 +00:00
Kathy Darling 6544d6b8f9 add $min_or_max and $display params to variation pricing functions 2013-12-07 10:11:23 +01:00
Mike Jolley 00ff09e3a2 sort sale price 2013-12-04 12:45:23 +00:00
Mike Jolley 9e5c0fbf67 Get rid of "FROM" - display a price range, localisable. Closes #4222 2013-12-04 12:08:14 +00:00
Mike Jolley 1ec8b82f69 Prevent error if variation doesn't exist. 2013-12-03 14:54:13 +00:00
Coen Jacobs c1a439eb99 Formatting functions woocommerce to wc refactor 2013-11-25 14:34:21 +01:00
Mike Jolley 6ea8cad430 Related display fixes for attributes #4123 2013-11-18 14:11:40 +00:00
Mike Jolley 97bdb1555f Sync only when needed 2013-11-08 16:02:03 +00:00
Mike Jolley 98d247eb76 Rather than storing prices themselves, store the ID's of variations during price sync - output prices using variation tax class Closes #4032 2013-11-08 15:53:57 +00:00
Kathy Darling b444b42275 pass $children variable (variations) to the woocommerce_variable_product_sync hook 2013-10-31 09:17:00 +01:00
Mike Jolley e143d344e5 Constants 2013-10-24 19:36:22 +01:00
Mike Jolley cc397a89d5 variable_product_sync should reload prices. Closes #3889 2013-10-11 15:56:13 +01:00
Mike Jolley ece95e25ce When handling variations, priority from top to bottom - disabled variations still taking into consideration allow you to exclude certain combinations when using 'all' for variations with lower priority. Message displayed if a variation is unavailable.
@coenjacobs please review
2013-10-10 16:34:44 +01:00
Mike Jolley ef49977905 add_to_cart_url add_to_cart_text and single_add_to_cart_text class methods allowing greater control with custom classes.
Closes #3484 and Closes #3143. Pinging @thenbrent as the handler was
originally his idea and I've killed it.

@helgatheviking In 2.1, add to cart URLs will only be used in loops, so
conditonal logic should no longer be neccessary. Single templates post
to themselves without the need for the URL.
2013-09-25 12:35:06 +01:00
Mike Jolley de9bc28b43 Prevent variable products without variations from being posted and show error in admin. Closes #3763 2013-09-24 16:37:51 +01:00