Commit Graph

251 Commits

Author SHA1 Message Date
Néstor Soriano de73ec027c
Merge pull request #26303 from netzstrategen/feature/prevent-unnecessary-available-variations-render
Allows avoiding performance bottlenecks caused by get_available_variation().
2020-07-27 08:46:24 +02:00
Nestor Soriano 9aa3c54bd9 Fix variable product stock status not being properly set on save
When a product is saved its validate_props method is invoked,
and this recalculates the stock_status property based on whether
the product manages stock or not, the stock quantity, and the
value of the woocommerce_notify_no_stock_amount option.

In the case of variable products, and when stock is managed, the stock
was set to "instock" when the current stock was enough, but only
if the "stock_quantity" property was in the list of changed properties
for the object (the method in the base product class doen't check
for changed properties). This is a problem because the
wc_update_product_stock function updates stock_quantity but via direct
database modification, and thus stock_quantity isn't considered
modified. Therefore stock modifications via wc_update_product_stock
don't update stock_status on the product (e.g. when going from 0 to 1
after a refund the stock status will remain as "outofstock").

The fix consists of removing the check for changed properties since
it's not done anyway in the other cases (when stock is below the
woocommerce_notify_no_stock_amount threshold) nor in the base class.

Also, validate_props is refactored for readabiliyy, and an useless
set_stock_status() call placed right before save()
in wc_update_product_stock is removed.
2020-06-29 14:32:17 +02:00
Bogdan Arizancu cbf6b33c9e fixup! fixup! Allows avoiding performance bottlenecks caused by get_available_variation(). 2020-04-27 15:46:34 +02:00
Bogdan Arizancu d69cf172db fixup! Allows avoiding performance bottlenecks caused by get_available_variation(). 2020-04-24 17:58:55 +02:00
Bogdan Arizancu 8584ac2638 Allows avoiding performance bottlenecks caused by get_available_variation().
Co-authored-by: Daniel Kudwien <daniel@netzstrategen.com>
2020-04-24 17:57:40 +02:00
Claudio Sanches 01f5a09d27
Merge pull request #23338 from woocommerce/update/23335
More useful actions in during CRUD save events
2019-07-08 18:56:14 -03:00
Mike Jolley a0d4f6174c Consistent CRUD classes with before/after save hooks 2019-04-17 12:47:35 +01:00
Manos Psychogyiopoulos d4f8435106 Prime post caches before looping through variations
Should help when the AJAX variations threshold is set higher.
2019-04-11 10:59:34 +03:00
Ruben 0a0f733a6e
fix lint code style issue 2018-09-06 22:52:48 +02:00
Ruben 081125043d
wordpress coding standards 2018-08-31 19:12:12 +02:00
Ruben d0db74edd5
Fix variable product cache misses
If the child product doesn't have weight or dimensions, the value is not being cached correctly as a ```false``` value is being stored and it always recheck that on every page load.
2018-08-31 19:10:32 +02:00
Claudiu Lodromanean 4c945f2e7e
Merge pull request #20854 from EmranAhmed/master
Prevent JS Issue if `woocommerce_available_variation` filter return false
2018-07-24 10:50:08 -07:00
Emran Ahmed f0151ca873
Re-indexing `get_available_variations` method values when `woocommerce_available_variation` filter return false.
### All Submissions:

* [x] Have you followed the [WooCommerce Contributing guideline](https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md)?
* [x] Does your code follow the [WordPress' coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/)?
* [x] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?

<!-- Mark completed items with an [x] -->

<!-- You can erase any parts of this template not applicable to your Pull Request. -->

### Changes proposed in this Pull Request:

Re-indexing `get_available_variations` method values.

Suppose you made changed with `woocommerce_available_variation` hook and skip returning some specific variation product with false value. There is `array_filter` function to filter empty values from `get_available_variations` but it keeps index which convert to js object rather then array on `single-product/add-to-cart/variable.php` template variation form `data-product_variations` attribute, and select box dropdown doesn't show. I just added `array_values` PHP function to reindex after `array_filter` function which convert to js array rather then js object before `get_available_variations` function return.

Closes # .

### How to test the changes in this Pull Request:

1. Before approving pull req just return false on a specific variation via `woocommerce_available_variation` filter.
2. Now check that variation product dropdown doesn't show. Because it needs to reindex array.

### Other information:

* [x] Have you added an explanation of what your changes do and why you'd like us to include them?
* [ ] Have you written new tests for your changes, as applicable?
* [x] Have you successfully ran tests with your changes locally?

<!-- Mark completed items with an [x] -->

### Changelog entry

> Enter a short summary of all changes on this Pull Request. This will appear in the changelog if accepted.
2018-07-20 20:14:57 +06:00
Emran Ahmed 33949f3c25
Prevent JS Issue if `woocommerce_available_variation` return false for a variation.
After checking some condition if `woocommerce_available_variation` filter return false. Then Option list don't show because of JS issue.
2018-07-20 01:33:25 +06:00
Joey b08b55a651 added changes for low stock notifications per product 2018-05-27 05:40:58 +01:00
Mike Jolley 8e0f0cbc29 Lazy load children and attributes for variable products 2018-05-01 11:57:00 +01:00
Claudio Sanches b2e33b3fb9 Fixed includes/class-wc-product-variable.php PHPCS violations 2018-03-22 15:47:50 -03:00
Amritansh_tact9 10e80c83d1 Applied array_filter() to the $avaiable_variations in WC_Product_Variable::get_available_variations() to ensure only array type values get returned.
Added docbock in favor of boolean false for WC_Product_Variable::get_available_variation()
2018-03-07 17:07:42 +05:30
Amritansh_tact9 7e05af1296 Replaced `WC_Product` with `WC_Product_Variation` for a more specific check in WC_Product_Variable::get_available_variation(). 2018-03-07 15:59:21 +05:30
Amritansh_tact9 da5e31ce2c Updated WC_Product_Variable::get_available_variation() to handle cases when variation ID provided is deleted/invalid. Throwing PHP fatal error on the next line where $variation->get_price() 2018-03-06 16:10:49 +05:30
Mike Jolley 80c07d530d Set woocommerce_hide_invisible_variations to true. 2018-02-09 16:44:41 +00:00
Mike Jolley c3623a9967 Update docblock for $include_taxes
Closes #18053
2017-12-07 11:46:35 +00:00
claudiulodro 9ec24731bb Generalize child_is_in_stock 2017-11-21 15:06:35 -08:00
claudiulodro a73436bdcd Merge remote-tracking branch 'origin/master' into HEAD 2017-11-20 14:43:12 -08:00
claudiulodro b64b26d030 Variable products are on backorder if all children are backordered 2017-11-20 11:19:06 -08:00
claudiulodro dddf0ee473 Variable product sync 2017-11-17 08:46:49 -08:00
claudiulodro be6f9d68bc Automatic transitions for variables 2017-11-15 12:08:19 -08:00
Mike Jolley babde741db Add add_to_cart_description method and aria-labels to cart buttons in the loop 2017-11-14 11:45:16 +00:00
axelmm 59534a09e7
Remove unnecessary html formatting
Dimensions and weight were unnecessary formatted as html (duplicating values of dimensions_html and weight_html), not as expected raw values
2017-11-11 22:33:22 +01:00
axelmm fb94f67b0f
Remove unnecessary formating, fixes #17662
https://github.com/woocommerce/woocommerce/issues/17662
2017-11-11 17:26:09 +01:00
Ville Viklund ae17ccd65f Fix typo 2017-10-03 15:34:44 +03:00
Mike Jolley 1e9e6c461f Unit test for #16653 2017-08-31 11:42:19 +01:00
Jaydeep Rami 3522857d23 Fix typo in WooCommerce plugin (#16135)
* Fixed typo

* Fixed more typo

* Fixed more typo

* Fix tyop

* Fix more typo

* Fix more typo

* Fix typo

* Fix typo

* Fix typo

* Fix typo datatime object

* Fix short name of compat

* Fix typo: update short name

* Fix typo "deactive" to "deactivate" and short BW - Compat

* Fix typo "Backwards compat"

* Fix typo 'parameters'

* Fix more typo 'pararmeters'

* Fix typo 'compund'

* FIx typo order

* Fix typo

* Fix typo 'incorrecly'

* Fix typo 'genarate'

* Fix typo 'reletive'

* Fix typo 'Handly'

* Fix typo 'rotatated'

* Fix typo

* Fix typo 'additonal'

* Fix typos
2017-07-17 11:10:52 +01:00
Akeda Bagus 53807185a8
Fixed typos.
These typos are catched by `misspell` program.

```
find . -type f | grep -v assets | grep -v dummy-data | grep -v i18n | grep -v node_modules | grep -v .git | grep -v apigen |  xargs misspell -w
```

Some results were excluded because of 3rd party ownership and non-english
sentences.
2017-07-10 12:56:28 +07:00
Claudio Sanches e63f42459b Include image_id again 2017-06-09 15:44:32 -03:00
Claudio Sanches 16d342a6a0 Fixed backwards compatibility with WC_Product_Variable::get_available_variation()
Closes #15167
2017-06-08 16:06:06 -03:00
Brent Shepherd a274000d34 Append variable price suffix only once 2017-06-06 13:40:36 -07:00
Brent Shepherd acd6bf9cb7 Apply woocommerce_variable_price_html filter once
To save a bit of duplicate code.
2017-06-06 13:35:41 -07:00
Mike Jolley d3666738d8 Merge branch 'pr/15069' 2017-05-23 18:56:58 +01:00
Mike Jolley cb76f38f11 If backorders are enabled, do not make variable products out of stock.
Fixes #15087
2017-05-16 13:06:38 +01:00
Rasmus Bengtsson 185934fad9 Fix phpdoc to include params and correct types 2017-05-15 13:50:52 +02:00
Mike Jolley db5e2572f6 clean up 2017-04-27 13:01:52 +01: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
Mike Jolley 84c96046f0 Check objects are not false/null 2017-04-07 16:01:51 +01:00
Claudio Sanches 0529e4efab Merge pull request #14026 from woocommerce/fix/13978
Fix variable stock syncing
2017-04-06 16:06:26 -03:00
Claudio Sanches 567a551d83 Fixed shortcode render for variations and backwards compatibility
Fixes #13949
2017-04-06 13:00:02 -03:00
Mike Jolley bf09c7df82 Ensure reg prices are the same 2017-04-06 13:08:18 +01:00
Mike Jolley 7e90a318cd On variable save, sync with children and avoid transient cache 2017-04-06 12:26:10 +01:00
Mike Jolley 93689a8107 Show a sale price on variable products if on sale and all prices are the same
Fixes #13968
2017-04-06 11:01:20 +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