WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Admin_Post_Types::bulk_edit_save() public WC 1.0

Bulk edit.

Это метод класса: WC_Admin_Post_Types{}

Возвращает

Null. Ничего.

Использование

$WC_Admin_Post_Types = new WC_Admin_Post_Types();
$WC_Admin_Post_Types->bulk_edit_save( $post_id, $product );
$post_id(число) (обязательный)
Post ID being saved.
$product(WC_Product) (обязательный)
Product object.

Код WC_Admin_Post_Types::bulk_edit_save() WC 4.5.2

woocommerce/includes/admin/class-wc-admin-post-types.php
<?php
public function bulk_edit_save( $post_id, $product ) {
	// phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash

	$request_data = $this->request_data();

	$data_store = $product->get_data_store();

	if ( ! empty( $request_data['change_weight'] ) && isset( $request_data['_weight'] ) ) {
		$product->set_weight( wc_clean( wp_unslash( $request_data['_weight'] ) ) );
	}

	if ( ! empty( $request_data['change_dimensions'] ) ) {
		if ( isset( $request_data['_length'] ) ) {
			$product->set_length( wc_clean( wp_unslash( $request_data['_length'] ) ) );
		}
		if ( isset( $request_data['_width'] ) ) {
			$product->set_width( wc_clean( wp_unslash( $request_data['_width'] ) ) );
		}
		if ( isset( $request_data['_height'] ) ) {
			$product->set_height( wc_clean( wp_unslash( $request_data['_height'] ) ) );
		}
	}

	if ( ! empty( $request_data['_tax_status'] ) ) {
		$product->set_tax_status( wc_clean( $request_data['_tax_status'] ) );
	}

	if ( ! empty( $request_data['_tax_class'] ) ) {
		$tax_class = wc_clean( wp_unslash( $request_data['_tax_class'] ) );
		if ( 'standard' === $tax_class ) {
			$tax_class = '';
		}
		$product->set_tax_class( $tax_class );
	}

	if ( ! empty( $request_data['_shipping_class'] ) ) {
		if ( '_no_shipping_class' === $request_data['_shipping_class'] ) {
			$product->set_shipping_class_id( 0 );
		} else {
			$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $request_data['_shipping_class'] ) );
			$product->set_shipping_class_id( $shipping_class_id );
		}
	}

	if ( ! empty( $request_data['_visibility'] ) ) {
		$product->set_catalog_visibility( wc_clean( $request_data['_visibility'] ) );
	}

	if ( ! empty( $request_data['_featured'] ) ) {
		// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		$product->set_featured( wp_unslash( $request_data['_featured'] ) );
		// phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	}

	if ( ! empty( $request_data['_sold_individually'] ) ) {
		if ( 'yes' === $request_data['_sold_individually'] ) {
			$product->set_sold_individually( 'yes' );
		} else {
			$product->set_sold_individually( '' );
		}
	}

	// Handle price - remove dates and set to lowest.
	$change_price_product_types    = apply_filters( 'woocommerce_bulk_edit_save_price_product_types', array( 'simple', 'external' ) );
	$can_product_type_change_price = false;
	foreach ( $change_price_product_types as $product_type ) {
		if ( $product->is_type( $product_type ) ) {
			$can_product_type_change_price = true;
			break;
		}
	}

	if ( $can_product_type_change_price ) {
		$regular_price_changed = $this->set_new_price( $product, 'regular' );
		$sale_price_changed    = $this->set_new_price( $product, 'sale' );

		if ( $regular_price_changed || $sale_price_changed ) {
			$product->set_date_on_sale_to( '' );
			$product->set_date_on_sale_from( '' );

			if ( $product->get_regular_price() < $product->get_sale_price() ) {
				$product->set_sale_price( '' );
			}
		}
	}

	// Handle Stock Data.
	$was_managing_stock = $product->get_manage_stock() ? 'yes' : 'no';
	$backorders         = $product->get_backorders();
	$backorders         = ! empty( $request_data['_backorders'] ) ? wc_clean( $request_data['_backorders'] ) : $backorders;

	if ( ! empty( $request_data['_manage_stock'] ) ) {
		$manage_stock = 'yes' === wc_clean( $request_data['_manage_stock'] ) && 'grouped' !== $product->get_type() ? 'yes' : 'no';
	} else {
		$manage_stock = $was_managing_stock;
	}

	$stock_amount = 'yes' === $manage_stock && ! empty( $request_data['change_stock'] ) && isset( $request_data['_stock'] ) ? wc_stock_amount( $request_data['_stock'] ) : $product->get_stock_quantity();

	$product->set_manage_stock( $manage_stock );
	$product->set_backorders( $backorders );

	if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {
		$change_stock = absint( $request_data['change_stock'] );
		switch ( $change_stock ) {
			case 2:
				wc_update_product_stock( $product, $stock_amount, 'increase', true );
				break;
			case 3:
				wc_update_product_stock( $product, $stock_amount, 'decrease', true );
				break;
			default:
				wc_update_product_stock( $product, $stock_amount, 'set', true );
				break;
		}
	} else {
		// Reset values if WooCommerce Setting - Manage Stock status is disabled.
		$product->set_stock_quantity( '' );
		$product->set_manage_stock( 'no' );
	}

	$stock_status = empty( $request_data['_stock_status'] ) ? null : wc_clean( $request_data['_stock_status'] );
	$product      = $this->maybe_update_stock_status( $product, $stock_status );

	$product->save();

	do_action( 'woocommerce_product_bulk_edit_save', $product );

	// phpcs:enable WordPress.Security.ValidatedSanitizedInput.MissingUnslash
}