Automattic\WooCommerce\Internal\Orders

OrderAttributionController::stamp_html_elementpublicWC 1.0

Output <wc-order-attribution-inputs> element that contributes the order attribution values to the enclosing form.

Used for customer register forms and checkout forms.

Note: By default, this method may output multiple instances of the element when called multiple times (e.g., during checkout form pre-generation and actual rendering). The JavaScript layer will remove duplicate elements and ensure only one set of data is submitted.

Method of the class: OrderAttributionController{}

Returns

null. Nothing (null).

Usage

$OrderAttributionController = new OrderAttributionController();
$OrderAttributionController->stamp_html_element();

OrderAttributionController::stamp_html_element() code WC 10.5.0

public function stamp_html_element() {
	/**
	 * Filter to allow sites to opt back into single-output behavior.
	 *
	 * @since 10.5.0
	 *
	 * @param bool $allow_multiple_elements True to allow multiple elements (new behavior), false for single element (old behavior).
	 */
	$allow_multiple = apply_filters( 'wc_order_attribution_allow_multiple_elements', true );

	// If single-output mode is enabled, use the static flag to prevent multiple outputs.
	if ( ! $allow_multiple && self::$is_stamp_html_called ) {
		return;
	}

	printf( '<wc-order-attribution-inputs></wc-order-attribution-inputs>' );

	if ( ! $allow_multiple ) {
		self::$is_stamp_html_called = true;
	}
}