Product

  • Full name: \BigCommerce\Post_Types\Product\Product

Constants

ConstantVisibilityTypeValue
NAMEpublic’bigcommerce_product’
BIGCOMMERCE_IDpublic’bigcommerce_id’
BRAND_TRANSIENTpublic’bigcommerce_brand_transient’
LISTING_IDpublic’bigcommerce_listing_id’
SKUpublic’bigcommerce_sku’
SKU_NORMALIZEDpublic’bigcommerce_sku_normalized’
SOURCE_DATA_META_KEYpublic’bigcommerce_source_data’
LISTING_DATA_META_KEYpublic’bigcommerce_listing_data’
MODIFIER_DATA_META_KEYpublic’bigcommerce_modifier_data’
OPTIONS_DATA_META_KEYpublic’bigcommerce_options_data’
OPTIONS_DATA_TRANSIENTpublic’bigcommerce_options_transient’
CUSTOM_FIELDS_META_KEYpublic’bigcommerce_custom_fields’
REQUIRES_REFRESH_META_KEYpublic’bigcommerce_force_refresh’
IMPORTER_VERSION_META_KEYpublic’bigcommerce_importer_version’
DATA_HASH_META_KEYpublic’bigcommerce_data_hash’
GALLERY_META_KEYpublic’bigcommerce_gallery’
VARIANT_IMAGES_META_KEYpublic’bigcommerce_variant_images’
RATING_META_KEYpublic’bigcommerce_rating’
RATING_SUM_META_KEYpublic’bigcommerce_review_rating_sum’
REVIEW_COUNT_META_KEYpublic’bigcommerce_review_count’
REVIEWS_APPROVED_META_KEYpublic’bigcommerce_approved_review_count’
REVIEW_CACHEpublic’bigcommerce_reviews’
SALES_META_KEYpublic’bigcommerce_sales’
PRICE_META_KEYpublic’bigcommerce_calculated_price’
PRICE_RANGE_META_KEYpublic’bigcommerce_price_range’
INVENTORY_META_KEYpublic’bigcommerce_inventory_level’

Methods

__construct

public __construct(mixed $post_id): mixed

Parameters:

ParameterTypeDescription
$post_idmixed

public get_redirect_product_link(): mixed

__get

public __get(mixed $property): mixed

Parameters:

ParameterTypeDescription
$propertymixed

is_headless

public is_headless(): mixed

get_property

public get_property(mixed $property): mixed

Parameters:

ParameterTypeDescription
$propertymixed

post_id

public post_id(): mixed

bc_id

public bc_id(): mixed

sku

public sku(): mixed

get_reviews_sum

public get_reviews_sum(): mixed

get_reviews_count

public get_reviews_count(): mixed

brand

public brand(): mixed

condition

public condition(): mixed

show_condition

public show_condition(): mixed

on_sale

public on_sale(): mixed

price_range

public price_range(): mixed

calculated_price_range

public calculated_price_range(): mixed

retail_price

Get the retail price (MSRP) of the product

public retail_price(): string

Return Value:

The formatted currency string for the product’s retail price


get_product_options

public get_product_options(): mixed

options

public options(): mixed

get_source_data

Get the product source data cached for this product

public get_source_data(): object

get_listing_data

Get the channel listing data cached for this product

public get_listing_data(): object

has_options

Check if a product has options.

public has_options(): bool

modifiers

public modifiers(): mixed

update_source_data

public update_source_data(mixed $data): mixed

Parameters:

ParameterTypeDescription
$datamixed

update_listing_data

public update_listing_data(mixed $data): mixed

Parameters:

ParameterTypeDescription
$datamixed

update_modifier_data

public update_modifier_data(mixed $data): mixed

Parameters:

ParameterTypeDescription
$datamixed

update_options_data

public update_options_data(mixed $data): mixed

Parameters:

ParameterTypeDescription
$datamixed

update_custom_field_data

public update_custom_field_data(mixed $data): mixed

Parameters:

ParameterTypeDescription
$datamixed

get_custom_fields

Get custom fields for this Product

public get_custom_fields(): array[]

Return Value:

An array of associative arrays, with the properties:

  • name: the name to display for the field
  • value: the value to display for the field

public get_gallery_ids(): int[]

Return Value:

WP post IDs of gallery images


public get_headless_featured_image(string $size = '80'): string|null

Parameters:

ParameterTypeDescription
$sizestring

get_thumb_from_cdn

public static get_thumb_from_cdn(mixed $post_ID, mixed $format = 'html', mixed $size = '80'): mixed
  • This method is static.

Parameters:

ParameterTypeDescription
$post_IDmixed
$formatmixed
$sizemixed

youtube_videos

Get the list of YouTube videos associated with the product

public youtube_videos(): array

purchase_url

public purchase_url(): mixed

purchase_button

public purchase_button(): mixed

purchase_message

public purchase_message(): mixed

get_variant_sku

Get product variant SKU by variant ID. Returns empty string if variant ID is not provided or wrong

public get_variant_sku(int $variant_id): string

Parameters:

ParameterTypeDescription
$variant_idint

get_selected_variant_id

Get selected variant id

public get_selected_variant_id(): int

get_inventory_level

public get_inventory_level(mixed $variant_id): mixed

Parameters:

ParameterTypeDescription
$variant_idmixed

out_of_stock

Checks if a product is out of stock. If a variant ID is given and the product uses variant-level inventory tracking, then it will be checked against the specific variant.

public out_of_stock(int $variant_id): bool

Parameters:

ParameterTypeDescription
$variant_idint

Return Value:

If the product is out of stock


availability

Get the availability for the product

public availability(): string

is_purchasable

Checks if a product can be purchased, considering both the purchasability setting and inventory levels

public is_purchasable(int $variant_id): bool

Parameters:

ParameterTypeDescription
$variant_idint

Return Value:

If the product is out of stock


low_inventory

public low_inventory(): bool

Return Value:

Whether the product is below the “low inventory” threshold


Get a list of products related to this one

public related_products(array $args = []): int[]

Parameters:

ParameterTypeDescription
$argsarrayAdditional args to pass to WP_Query

Return Value:

The IDs of related products


get_reviews

Get the reviews associated with this product

public get_reviews(int $count = 12): array

Parameters:

ParameterTypeDescription
$countintThe number of reviews to return. Will not return more
than the number in the review cache.

Return Value:

The most recent reviews cached for the product


get_review_count

Get the total number of reviews for the product

public get_review_count(): int

get_channel_id

Get the channel ID associated with this post

public get_channel_id(): int

Return Value:

The BigCommerce channel ID


get_channel

Get the Channel term associated with this post

public get_channel(): \WP_Term

Return Value:

The WordPress Channel term


get_listing_id

Get the Listing ID associated with this post

public get_listing_id(): int

Return Value:

The BigCommerce Listing ID


by_product_id

Gets a BigCommerce Product ID and returns matching Product object

public static by_product_id(int $product_id, \WP_Term|null $channel = null, array $query_args = []): \BigCommerce\Post_Types\Product\Product|array
  • This method is static.

Parameters:

ParameterTypeDescription
$product_idint
$channel\WP_Term|null
$query_argsarray

by_product_sku

Gets a BigCommerce Product SKU and returns matching Product object

public static by_product_sku(string $product_sku, \WP_Term|null $channel = null, array $query_args = []): \BigCommerce\Post_Types\Product\Product|array
  • This method is static.

Parameters:

ParameterTypeDescription
$product_skustring
$channel\WP_Term|null
$query_argsarray

Inherited methods

format_currency

Formats a numeric value as a currency string.

protected format_currency(float $value, string $empty_value = ''): string

Parameters:

ParameterTypeDescription
$valuefloatThe currency value to format.
$empty_valuestringThe value to return if $value is empty. Pass null to format anyway.

Return Value:

The formatted currency string or the empty value.



Automatically generated on 2025-01-21