1. Home
  2. WooCommerce Product Options
  3. Developer Documentation

Actions and Filters

Filters

wc_product_options_allowed_product_types

Filters the allowed product types.

Arguments

  • $product_types (array): The allowed product types.

Example

add_filter( 'wc_product_options_allowed_product_types', 'my_wc_product_options_allowed_product_types' );
function my_wc_product_options_allowed_product_types( $product_types ) {
	// your code to alter $product_types here...

	return $product_types;
}

wc_product_options_enable_price_calculation

Filters whether to allow product option price calculation on a product.

Arguments

  • $enable (bool): Whether to allow product option price calculation on a product.
  • $product (\WC_Product): The product which is being calculated.
  • $cart_item (array|null): The cart item if this is calculated in the cart.

Example

add_filter( 'wc_product_options_enable_price_calculation', 'my_wc_product_options_enable_price_calculation', 10, 3 );
function my_wc_product_options_enable_price_calculation( $enable, $product, $cart_item ) {
	// your code to alter $enable here...

	return $enable;
}

wc_product_options_field_classes

Example

add_filter( 'wc_product_options_field_classes', 'my_wc_product_options_field_classes' );
function my_wc_product_options_field_classes() {
	// your code here...
}

wc_product_options_field_css_class

Filters the CSS classes for the field.

Arguments

  • $class_string (string):
  • $field (\Barn2\Plugin\WC_Product_Options\Fields\Abstract_Field):

Example

add_filter( 'wc_product_options_field_css_class', 'my_wc_product_options_field_css_class', 10, 2 );
function my_wc_product_options_field_css_class( $class_string, $field ) {
	// your code to alter $class_string here...

	return $class_string;
}

wc_product_options_handle_add_to_cart_validation

Example

add_filter( 'wc_product_options_handle_add_to_cart_validation', 'my_wc_product_options_handle_add_to_cart_validation' );
function my_wc_product_options_handle_add_to_cart_validation() {
	// your code here...
}

wc_product_options_multiple_cart_item_data_seperator

Filter the formatted item data string.

Used in the cart, checkout, orders, and emails. Default ' | ' separator.

Arguments

  • $seperator (string):

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.