Product_Protector implements Registerable, Premium_Service

This class protects protect products inside product loops, the main shop page, search results, widgets, navigation menus, and in WooCommerce shortcodes.

This class is responsible for product level wholesale visibility protection. See Category_Protector for similar functionality at the category level.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Registerable
Premium_Service

Table of Contents

$protected_product_ids  : mixed
$unlocked_product_ids  : mixed
exclude_protected_products()  : mixed
Protect products in the loop.
include_unlocked_products()  : mixed
Add unlocked products to the loop when relevant.
is_product_purchasable()  : bool
Determine if the product is purchasable.
protect_nav_menus()  : array<string|int, mixed>
Protect WP navigation menus.
protect_single_product()  : mixed
Protect single product pages
protect_upsells()  : array<string|int, mixed>
Protect upsells from being displayed if they are protected on the product level
register()  : mixed
{@inheritdoc}
show_nav_menus()  : mixed
Show nav menu items with unlocked products.
unprotect_upsells()  : array<string|int, mixed>
Unprotect upsells which are unlocked on the product level
update_category_counts()  : array<string|int, mixed>
Update the category counts to reflect hidden ones.
protected_product_ids()  : array<string|int, mixed>
Set and retrieve hidden product ids.
unlocked_product_ids()  : array<string|int, mixed>
Set and retrieve unlocked product ids.

Properties

Methods

exclude_protected_products()

Protect products in the loop.

public exclude_protected_products(string $where, WP_Query $query) : mixed
Parameters
$where : string
$query : WP_Query
Tags
Return values
mixed

include_unlocked_products()

Add unlocked products to the loop when relevant.

public include_unlocked_products(string $where, WP_Query $query) : mixed
Parameters
$where : string
$query : WP_Query
Tags
Return values
mixed

is_product_purchasable()

Determine if the product is purchasable.

public is_product_purchasable(bool $purchasable, WC_Product $product) : bool
Parameters
$purchasable : bool
$product : WC_Product
Tags
Return values
bool

protect_nav_menus()

Protect WP navigation menus.

public protect_nav_menus(array<string|int, mixed> $menu_items, string $menu, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$menu_items : array<string|int, mixed>
$menu : string
$args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

protect_single_product()

Protect single product pages

public protect_single_product() : mixed
Tags
Return values
mixed

protect_upsells()

Protect upsells from being displayed if they are protected on the product level

public protect_upsells(array<string|int, mixed> $ids) : array<string|int, mixed>
Parameters
$ids : array<string|int, mixed>

Array of upsell IDs.

Tags
Return values
array<string|int, mixed>

Array of upsell IDs.

register()

{@inheritdoc}

public register() : mixed
Tags
Return values
mixed

show_nav_menus()

Show nav menu items with unlocked products.

public show_nav_menus(array<string|int, WP_Post$items_to_remove, string $menu, array<string|int, mixed> $args) : mixed
Parameters
$items_to_remove : array<string|int, WP_Post>
$menu : string
$args : array<string|int, mixed>
Tags
Return values
mixed

unprotect_upsells()

Unprotect upsells which are unlocked on the product level

public unprotect_upsells(array<string|int, mixed> $protected_ids) : array<string|int, mixed>
Parameters
$protected_ids : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

update_category_counts()

Update the category counts to reflect hidden ones.

public update_category_counts(array<string|int, mixed> $terms, array<string|int, mixed> $taxonomies, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$terms : array<string|int, mixed>
$taxonomies : array<string|int, mixed>
$args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

protected_product_ids()

Set and retrieve hidden product ids.

private protected_product_ids() : array<string|int, mixed>
Return values
array<string|int, mixed>

unlocked_product_ids()

Set and retrieve unlocked product ids.

private unlocked_product_ids() : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results