Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_AJAX::variation_bulk_adjust_price( array $variations, string $field, string $operator, string $value )
Bulk action – Set Price.
Description Description
Parameters Parameters
- $variations
-
(Required) List of variations.
- $field
-
(Required) price being adjusted _regular_price or _sale_price.
- $operator
-
(Required) + or -.
- $value
-
(Required) Price or Percent.
Source Source
File: includes/class-wc-ajax.php
private static function variation_bulk_adjust_price( $variations, $field, $operator, $value ) { foreach ( $variations as $variation_id ) { $variation = wc_get_product( $variation_id ); $field_value = $variation->{"get_$field"}( 'edit' ); if ( '%' === substr( $value, -1 ) ) { $percent = wc_format_decimal( substr( $value, 0, -1 ) ); $field_value += round( ( $field_value / 100 ) * $percent, wc_get_price_decimals() ) * "{$operator}1"; } else { $field_value += $value * "{$operator}1"; } $variation->{"set_$field"}( $field_value ); $variation->save(); } }