Black Friday: 79% off every plugin Shop the sale →

Filters and hooks

All hooks use the ankpqv_ prefix. The three public filters below are the supported way to change what the plugin prints.

ankpqv_show_button#

Controls whether the Quick view button is printed for a product in a listing.

/**
 * @param bool       $show    Whether to show the button. Default true.
 * @param WC_Product $product The product in the loop.
 * @return bool
 */
add_filter( 'ankpqv_show_button', function ( $show, $product ) {
	// Hide quick view for external/affiliate products.
	if ( $product->is_type( 'external' ) ) {
		return false;
	}
	return $show;
}, 10, 2 );

Hide the button on a specific category:

add_filter( 'ankpqv_show_button', function ( $show, $product ) {
	if ( has_term( 'gift-cards', 'product_cat', $product->get_id() ) ) {
		return false;
	}
	return $show;
}, 10, 2 );

ankpqv_show_element#

Overrides the “Show in the modal” checkboxes for a single element, per request. Element keys are gallery, rating, price, description, add_to_cart, meta and details_link.

/**
 * @param bool   $show    Whether the element is shown (from the settings).
 * @param string $element Element key.
 * @return bool
 */
add_filter( 'ankpqv_show_element', function ( $show, $element ) {
	// Never show SKU, categories and tags to logged-out visitors.
	if ( 'meta' === $element && ! is_user_logged_in() ) {
		return false;
	}
	return $show;
}, 10, 2 );

The filter runs while the modal HTML is rendered, so $GLOBALS['product'] holds the product being displayed if you need product-specific decisions.

ankpqv_quick_view_html#

Filters the complete modal HTML before it is returned to the browser.

/**
 * @param string     $html    Modal HTML.
 * @param WC_Product $product The product.
 * @return string
 */
add_filter( 'ankpqv_quick_view_html', function ( $html, $product ) {
	$badge = '<p class="my-shipping-note">Ships within 24 hours.</p>';
	return str_replace( '<p class="ankpqv-product__actions">', $badge . '<p class="ankpqv-product__actions">', $html );
}, 10, 2 );

Because the modal is rendered with the WooCommerce product globals set up as on the product page, WooCommerce hooks that run inside woocommerce_template_single_add_to_cart(), woocommerce_template_single_rating() and woocommerce_template_single_meta() also run inside the modal.

JavaScript event ankpqv_quick_view_loaded#

Fired on document.body after the product HTML has been inserted into the modal and the variation form (if any) has been initialised. Use it to initialise your own scripts inside the modal.

jQuery( document.body ).on( 'ankpqv_quick_view_loaded', function ( event, productId, $content ) {
	// $content is the jQuery-wrapped .ankpqv-modal__content element.
	$content.find( '.my-swatches' ).mySwatches();
} );

The standard WooCommerce added_to_cart event is triggered after a successful add to cart from the modal, with the usual fragments, cart_hash and $button arguments, so cart widgets and the Mini Cart block refresh without extra code.

AJAX endpoint#

Product details are served from the front-end WooCommerce AJAX endpoint ?wc-ajax=ankpqv_quick_view with a POST field product_id. The response is { success: true, data: { html: "…" } } or a 404 JSON error. The request is read-only, returns only public product data, and deliberately carries no nonce so that full-page caches never serve an expired one.

Licensing filters and constants#

These exist for development and white-label builds. Stores running the zip from technoleet.dev never need them.

Hook or constantPurpose
ankpqv_storeengine_store_url filter / ANKPQV_STOREENGINE_STORE_URL constantThe store used for license checks and updates.
ankpqv_storeengine_product_id filter / ANKPQV_STOREENGINE_PRODUCT_ID constantThe store’s product ID. 0 disables licensing.
ankpqv_storeengine_allow_local filterWhether keys may be activated on local and .test sites. Default true.
ankpqv_store_dashboard_url filterThe URL of the Manage License button.
Was this article helpful?