gspc_process_form_on_add_to_cart

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Skip processing if a “skip-form” query parameter is present.
    2. Skip processing the form if the product is a specific variation.
  5. Since

Description

Filter if the form should be processed when adding to the cart. Defaults to true. Useful to skip an attached form for specific variations, etc.

Usage

Filter if attached forms should be processed when adding a product to cart.

add_filter( 'gspc_process_form_on_add_to_cart', '__return_true' );

Parameters

  • process_form bool

    True to process and validate attached form, false to skip processing and defer to the default behavior.

  • product \WC_Product

    The current product.

  • product_form \GFForm

    The product form.

  • feed \GSPCFeed

    The product feed.

  • valid bool

    The current validation status.

  • quantity int

    The quantity of the product being added to the cart.

  • variation_id int|null

    The variation ID being added to the cart.

  • variation array|null

    The variation data.

Examples

Skip processing if a “skip-form” query parameter is present.

add_filter( 'gspc_process_form_on_add_to_cart', function ( $process_form ) {
	if ( rgget( 'skip-form' ) ) {
		return false;
	}

	return $process_form;
}, 10 );

Skip processing the form if the product is a specific variation.

add_filter( 'gspc_process_form_on_add_to_cart', function ( $process_form, $product, $product_form, $feed, $valid, $quantity, $variation_id, $variation ) {
	if ( $variation_id == 123 )
		return false;
	}

	return $process_form;
}, 10, 8 );

Since

This filter is available since Gravity Shop Product Configurator 1.0-beta-2.26.