Recent

WooCommerce_Module class Pro only

WooCommerce_Module

WooCommerce integration module.

Namespace: WebberZone\Contextual_Related_Posts\Pro\WooCommerce
Since: 4.2.0
Source: includes/woocommerce/class-woocommerce-module.php line 22

Methods

__construct()

Constructor.

Since: 4.2.0
Line: 83

public function __construct(  );

filter_index_meta_keys()

Add WooCommerce product meta keys to the central CRP meta indexing pipeline.

Since: 4.2.0
Line: 116

public function filter_index_meta_keys( array $meta_keys, int $post_id ): array;
TypeNameDescription
string[]$meta_keysExisting meta keys to index.
int$post_idPost ID being indexed.

Returns: array — Deduplicated meta keys, potentially including _sku and _purchase_note.

Conditionally hide add to cart output during CRP’s related products rendering.

Since: 4.2.0
Line: 142

public function filter_add_to_cart_link( string $html, $product, array $args ): string;
TypeNameDescription
string$htmlAdd to cart HTML.
\WC_Product$productWC_Product object.
array$argsAdd to cart arguments.

Returns: string — Original HTML, or empty string when suppressed.

filter_sale_flash()

Conditionally hide sale flash output during CRP’s related products rendering.

Since: 4.2.0
Line: 162

public function filter_sale_flash( string $html, $post, $product ): string;
TypeNameDescription
string$htmlSale flash HTML.
\WP_Post$postPost object.
\WC_Product$productWC_Product object.

Returns: string — Original HTML, or empty string when suppressed.

filter_product_image_html()

Conditionally hide product image HTML during CRP’s related products rendering.

Since: 4.2.0
Line: 185

public function filter_product_image_html( string $image, $product, $size, array $attr, bool $placeholder, $image_src ): string;
TypeNameDescription
string$imageImage HTML.
\WC_Product$productWC_Product object.
string|int[]$sizeImage size name or [width, height] array.
array$attrImage attributes.
bool$placeholderWhether a placeholder image is being used.
string|false$image_srcImage src URL, or false when unavailable.

Returns: string — CRP thumbnail HTML, or empty string when thumbnails are suppressed.

filter_price_html()

Conditionally hide price output during CRP’s related products rendering.

Since: 4.2.0
Line: 221

public function filter_price_html( string $price_html, $product ): string;
TypeNameDescription
string$price_htmlPrice HTML.
\WC_Product$productWC_Product object.

Returns: string — Original price HTML, or empty string when suppressed.

filter_rating_html()

Conditionally hide rating output during CRP’s related products rendering.

Since: 4.2.0
Line: 241

public function filter_rating_html( string $html, $rating, $count ): string;
TypeNameDescription
string$htmlRating HTML.
float$ratingRating value.
int$countNumber of ratings.

Returns: string — Original rating HTML, or empty string when suppressed.

maybe_register_hooks()

Register all WooCommerce frontend hooks on the wp action.

Since: 4.3.0
Line: 315

public function maybe_register_hooks(  ): void;

Returns: void

maybe_register_single_product_hooks()

Register WooCommerce single product hooks.

Since: 4.2.0
Line: 325

public function maybe_register_single_product_hooks(  ): void;

Returns: void

Output related products using CRP.

Since: 4.2.0
Line: 348

public function output_related_products(  ): void;

Returns: void

maybe_register_cart_hooks()

Register WooCommerce cart hooks when on the cart page.

Since: 4.3.0
Line: 518

public function maybe_register_cart_hooks(  ): void;

Returns: void

maybe_enqueue_cart_styles()

Enqueue inline styles for the cart related products section on the cart page.

Registers a dummy stylesheet handle so the inline CSS is guaranteed to be output regardless of which WooCommerce stylesheet handles are registered. Scoped to .crp-cart-related-products so they don’t affect the main shop loop.

Since: 4.3.0
Line: 539

public function maybe_enqueue_cart_styles(  ): void;

Returns: void

Output related products on the cart page to nudge the customer toward free shipping.

Shows a mix of products at the full gap price (one item reaches free shipping) and products at half the gap price (two items reach free shipping), shuffled for display.

Since: 4.3.0
Line: 809

public function output_cart_related_products(  ): void;

Returns: void

Re-render the cart related products section in response to a cart update (AJAX).

Allows the section to refresh dynamically when products are added to or removed from the cart without a full page reload.

Since: 4.3.0
Line: 830

public function ajax_refresh_cart_related_products(  ): void;

Returns: void