Confirm bids on single auction pages

Ask bidders to confirm before submitting a bid on a single auction page. The example uses the browser’s confirmation dialog and lets the auction form continue when the bidder confirms.

Note:

This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.

Before you start

↑ Back to top

Use a test store with Auctions for WooCommerce 4.2.1 active and a live fixture auction with the standard single-auction bid form. You need a site-specific plugin or equivalent custom PHP setup.

Add the confirmation

↑ Back to top

Add the following PHP in your site-specific plugin. The example loads on single auction pages and attaches a submit listener to the auction form.

add_action(
	'wp_enqueue_scripts',
	static function () {
		if ( ! is_product() ) {
			return;
		}

		$product = wc_get_product( get_queried_object_id() );
		if ( ! $product || ! $product->is_type( 'auction' ) ) {
			return;
		}

		$confirmation = <<<'JS'
document.addEventListener( 'submit', function ( event ) {
	if ( ! event.target.matches( 'form.auction_form' ) ) {
		return;
	}

	if ( ! window.confirm( 'Place this bid?' ) ) {
		event.preventDefault();
		event.stopImmediatePropagation();
	}
}, true );
JS;

		wp_add_inline_script( 'auctions-for-woocommerce-frontend', $confirmation );
	},
	20
);

Verify both choices

↑ Back to top

On your test auction, submit a bid and cancel at the prompt. Confirm that the bid history did not change. Submit again and confirm the prompt, then check the normal success or validation message.

If the prompt does not appear, check that your custom code is active and your theme renders the extension’s standard bid form. To undo the change, remove the custom code and reload the auction.

Questions and support

↑ Back to top

Something missing from this documentation? Still have questions and need assistance?

  • If you have a question about an extension or theme you’d like to purchase, visit our contact page and use the AI Assistant or contact options.
  • If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.

Related Products

WooCommerce Subscriptions is a WooCommerce extension that lets customers subscribe to your products or...

Offer add-ons like gift wrapping, special messages or other special options for your products.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.