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;
| Type | Name | Description |
|---|---|---|
string[] | $meta_keys | Existing meta keys to index. |
int | $post_id | Post ID being indexed. |
Returns: array — Deduplicated meta keys, potentially including _sku and _purchase_note.
filter_add_to_cart_link()
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;
| Type | Name | Description |
|---|---|---|
string | $html | Add to cart HTML. |
\WC_Product | $product | WC_Product object. |
array | $args | Add 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;
| Type | Name | Description |
|---|---|---|
string | $html | Sale flash HTML. |
\WP_Post | $post | Post object. |
\WC_Product | $product | WC_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;
| Type | Name | Description |
|---|---|---|
string | $image | Image HTML. |
\WC_Product | $product | WC_Product object. |
string|int[] | $size | Image size name or [width, height] array. |
array | $attr | Image attributes. |
bool | $placeholder | Whether a placeholder image is being used. |
string|false | $image_src | Image 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;
| Type | Name | Description |
|---|---|---|
string | $price_html | Price HTML. |
\WC_Product | $product | WC_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;
| Type | Name | Description |
|---|---|---|
string | $html | Rating HTML. |
float | $rating | Rating value. |
int | $count | Number 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()
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_cart_related_products()
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
ajax_refresh_cart_related_products()
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