WC_Product::validate_props()
Ensure properties are set correctly before save.
Description Description
Source Source
File: includes/abstracts/abstract-wc-product.php
public function validate_props() { // Before updating, ensure stock props are all aligned. Qty, backorders and low stock amount are not needed if not stock managed. if ( ! $this->get_manage_stock() ) { $this->set_stock_quantity( '' ); $this->set_backorders( 'no' ); $this->set_low_stock_amount( '' ); // If we are stock managing and we don't have stock, force out of stock status. } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount', 0 ) && 'no' === $this->get_backorders() ) { $this->set_stock_status( 'outofstock' ); // If we are stock managing, backorders are allowed, and we don't have stock, force on backorder status. } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount', 0 ) && 'no' !== $this->get_backorders() ) { $this->set_stock_status( 'onbackorder' ); // If the stock level is changing and we do now have enough, force in stock status. } elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount', 0 ) ) { $this->set_stock_status( 'instock' ); } }
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |