WC_Product::validate_props()
Ensure properties are set correctly before save.
Метод класса: WC_Product{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$WC_Product = new WC_Product(); $WC_Product->validate_props();
Список изменений
С версии 3.0.0 | Введена. |
Код WC_Product::validate_props() WC Product::validate props WC 9.2.3
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( '' ); return; } $stock_is_above_notification_threshold = ( (int) $this->get_stock_quantity() > absint( get_option( 'woocommerce_notify_no_stock_amount', 0 ) ) ); $backorders_are_allowed = ( 'no' !== $this->get_backorders() ); if ( $stock_is_above_notification_threshold ) { $new_stock_status = 'instock'; } elseif ( $backorders_are_allowed ) { $new_stock_status = 'onbackorder'; } else { $new_stock_status = 'outofstock'; } $this->set_stock_status( $new_stock_status ); }