Commit Graph

384 Commits

Author SHA1 Message Date
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
Nestor Soriano b43679c181 Schedule a deferred product sync for products with parent on delete.
Right now, when a product having a parent (e.g. a variation having a
parent variable product) is saved, wc_deferred_product_sync is
executed so that product sync is performed at the end of the request.
This commit implements the same when the product is deleted.
2020-05-28 14:07:51 +02:00
Rodrigo Primo 487f96d844 Fix WordPress.DateTime.CurrentTimeTimestamp vilations
This commit fixes all violations of the WordPress.DateTime.CurrentTimeTimestamp sniff automatically using phpcbf.
2019-12-20 14:23:05 -03:00
Ian Jenkins 2340f269cf Add support for custom attributes to wc_placeholder_img().
When displaying a list of images you often want a specific class to be
attached to each image, therefore you pass through a custom class using
the attr parameter. Unfortunately this doesn't get passed through to a
placeholder image should one be needed. This means that, for example, if
you're custom class center an image or something, it won't be honoured
for placeholders, which can lead to some wonky image listings.

You can work around this currently by leverging the
`woocommerce_product_get_image` filter, but it's a bit gnarly as you
need to do some regexing or string splitting or something and checking
class names and what not. This provides a much easier way, by
supporting custom attrs on placeholder images as is the case for non
placehodler images.
2019-10-30 15:08:19 +00:00
itzmekhokan dcf3d71c79 Fixed issue #24458 2019-09-02 12:40:44 +05:30
Gerhard Potgieter 52f1eb4060
Revert "Prevent negative prices on products" 2019-07-15 08:50:11 +02:00
Claudio Sanches 77191a97f8
Merge pull request #23705 from woocommerce/fix/23696
Prevent negative prices on products
2019-07-12 12:56:34 -03:00
Claudio Sanches b68b35336f Prevent negative prices for products 2019-05-14 13:22:06 -03:00
Mike Jolley a0d4f6174c Consistent CRUD classes with before/after save hooks 2019-04-17 12:47:35 +01:00
Mike Jolley c56d3ede9f Remove day offsets 2019-03-08 13:35:30 +00:00
Mike Jolley 889cf64ac4 Merge branch 'performance/wc-get-product-class' 2019-02-07 13:34:18 +00:00
Mike Jolley 59e0867afe Add missing post_password prop 2019-01-30 16:01:54 +00:00
Ian Jenkins d7e32e1c77 Remove possibe superfluous wp_attachment_is_image() filter.
The reason to remove this is that this function uses get_post() under
the hood which always assumes the attachment is on the same site, where
as if you're using a plugin such as
https://github.com/humanmade/network-media-library it might not be.

I'm not sure if there's any adverse affects of not doing this filtering,
from my testing, it still seems to work in the same way.
2019-01-25 15:11:58 +00:00
Claudiu Lodromanean 1612d2a230
Merge pull request #22074 from Prospress/fix/22068
ensure product parent exists before getting its image
2019-01-04 09:37:03 -08:00
Ron Rennick b6c614c2af allow sale price to 23:59:59 on last sale date 2018-12-10 10:37:13 -06:00
Ron Rennick b8d635a29c phpcs sniffs in abstract-wc-product.php 2018-12-10 10:34:12 -06:00
Ron Rennick 548fc72718 ensure product parent exists before getting its image 2018-11-28 14:41:12 -04:00
Ron Rennick b0b2320559 fix phpcs sniffs in abstract-wc-product.php 2018-11-28 14:34:24 -04:00
Rodrigo Primo 6ed2ebb3ba Fix: WC_Product::get_image() should use $attr parameter
This commit fixes a issue that was introduced when WC_Product::get_image() was refactored in 64b589f032 that was making this method ignore what was passed in the $attr parameter.
2018-10-17 19:40:57 -03:00
claudiulodro 178f98ff65 Fix attribute saving 2018-09-19 11:35:46 -07:00
Rodrigo Primo 4d2530ef45 Fix: product attributes cache should work when non-ASCII characters are used
This commit fixes an issue in the code that sets product attributes that was breaking product attributes cache removal when non-ASCII characters are used in the attribute name. For more information see https://github.com/woocommerce/woocommerce/issues/21026#issuecomment-412111740
2018-08-15 13:24:33 -03:00
Rodrigo Primo fef0cd48ea phpcs fixes 2018-08-15 13:24:09 -03:00
Claudiu Lodromanean 87acfa731d
Merge pull request #20260 from leglesslizard/master
Set low stock notification threshold per product
2018-07-24 10:23:15 -07:00
Joey Gilham 58cdd7dad2
Merge branch 'master' into master 2018-07-03 15:41:15 +01:00
Mike Jolley 64b589f032 Get image from ID, not post thumbnail 2018-06-28 13:10:25 +01:00
Claudiu Lodromanean 2a3cedddcd
Merge pull request #20520 from woocommerce/feature/product-custom-tables-supporting-changes
Product custom tables supporting changes
2018-06-27 08:57:50 -07:00
Mike Jolley 0cee6a69b0 Update status based on stock, always 2018-06-19 13:35:17 +01:00
Joey cd8416122f removed low stock options for variations, and addressed changes 2018-06-19 12:40:27 +01:00
Gerhard Potgieter 90387e7d7e Revert "Deprecate manage_stock methods in favor of stock_status methods."
This reverts commit 2d9c058876.
2018-06-19 11:54:07 +02:00
Gerhard Potgieter 2d9c058876 Deprecate manage_stock methods in favor of stock_status methods.
Closes https://github.com/woocommerce/woocommerce-product-tables-feature-plugin/issues/100
2018-06-19 11:35:57 +02:00
Rodrigo Primo b6e73f528b Merge branch 'master' into feature/product-custom-tables-supporting-changes 2018-06-15 14:56:31 -03:00
Mike Jolley a8e2eaee2a Normalize parent tax class 2018-06-15 11:35:22 +01:00
Mike Jolley 812586742b Allow only valid default attributes 2018-06-13 14:33:13 +01:00
Joey 98e44092e7 updating suggested changes 2018-06-07 14:37:06 +01:00
Joey b08b55a651 added changes for low stock notifications per product 2018-05-27 05:40:58 +01:00
Claudiu Lodromanean 7a6b0d8cf5
Merge pull request #19934 from woocommerce/fix/19819
Add protocol to URLs for thumbnails in cart.
2018-05-09 10:09:17 -07:00
Peter Fabian 8a8f085dcf Added back extra parameter for backwards compatibility. 2018-05-08 10:16:53 +02:00
Peter Fabian c2493310d9 Switch stock status when manage stock gets changed.
As the stock quantity might be saved in the database from previous settings, stock_status needs to be in sync if qty is > 0.
2018-05-07 16:01:59 +02:00
Peter Fabian 8789642fb9 Add protocol to URLs for thumbnails in cart.
Removed wc_get_relative_url(), as it's not used anymore.
2018-05-02 14:34:50 +02:00
Claudio Sanches 0660a50e07 Removed obvious boolean results 2018-03-21 19:57:10 -03:00
Gerhard Potgieter 7f2362aab1 PHPCS passing abstract-wc-product.php 2018-03-05 14:46:34 +02:00
Boro Sitnikovski 927576edb2 Pass image to get_image_filter as well 2018-02-15 16:22:30 +01:00
Mike Jolley effbf87e22 API should generate or set file ID when setting downloads. Closes #18330 2018-01-03 11:02:38 +00:00
Mike Jolley 320392fc59 is_visible should ensure product is is not trashed
Closes #18023
2017-12-06 13:47:09 +00:00
claudiulodro 5513dc4546 Update with master 2017-11-22 11:02:14 -08:00
claudiulodro 99aefc91f3 Changes from feedback 2017-11-21 14:08:17 -08:00
Mike Jolley 8b02185596
Merge pull request #17817 from JeroenSormani/exclude-virtual-from-shipping-tax
Exclude virtual tax classes from calcluation for shipping taxes
2017-11-21 13:21:13 +00: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
JeroenSormani 14e5bcd51d Exclude virtual tax classes from calcluation for shipping taxes 2017-11-20 20:14:23 +01:00