Product
- Full name:
\BigCommerce\Post_Types\Product\Product
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
NAME | public | ’bigcommerce_product’ | |
BIGCOMMERCE_ID | public | ’bigcommerce_id’ | |
BRAND_TRANSIENT | public | ’bigcommerce_brand_transient’ | |
LISTING_ID | public | ’bigcommerce_listing_id’ | |
SKU | public | ’bigcommerce_sku’ | |
SKU_NORMALIZED | public | ’bigcommerce_sku_normalized’ | |
SOURCE_DATA_META_KEY | public | ’bigcommerce_source_data’ | |
LISTING_DATA_META_KEY | public | ’bigcommerce_listing_data’ | |
MODIFIER_DATA_META_KEY | public | ’bigcommerce_modifier_data’ | |
OPTIONS_DATA_META_KEY | public | ’bigcommerce_options_data’ | |
OPTIONS_DATA_TRANSIENT | public | ’bigcommerce_options_transient’ | |
CUSTOM_FIELDS_META_KEY | public | ’bigcommerce_custom_fields’ | |
REQUIRES_REFRESH_META_KEY | public | ’bigcommerce_force_refresh’ | |
IMPORTER_VERSION_META_KEY | public | ’bigcommerce_importer_version’ | |
DATA_HASH_META_KEY | public | ’bigcommerce_data_hash’ | |
GALLERY_META_KEY | public | ’bigcommerce_gallery’ | |
VARIANT_IMAGES_META_KEY | public | ’bigcommerce_variant_images’ | |
RATING_META_KEY | public | ’bigcommerce_rating’ | |
RATING_SUM_META_KEY | public | ’bigcommerce_review_rating_sum’ | |
REVIEW_COUNT_META_KEY | public | ’bigcommerce_review_count’ | |
REVIEWS_APPROVED_META_KEY | public | ’bigcommerce_approved_review_count’ | |
REVIEW_CACHE | public | ’bigcommerce_reviews’ | |
SALES_META_KEY | public | ’bigcommerce_sales’ | |
PRICE_META_KEY | public | ’bigcommerce_calculated_price’ | |
PRICE_RANGE_META_KEY | public | ’bigcommerce_price_range’ | |
INVENTORY_META_KEY | public | ’bigcommerce_inventory_level’ |
Methods
__construct
public __construct(mixed $post_id): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$post_id | mixed |
get_redirect_product_link
public get_redirect_product_link(): mixed
__get
public __get(mixed $property): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$property | mixed |
is_headless
public is_headless(): mixed
get_property
public get_property(mixed $property): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$property | mixed |
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:
Parameter | Type | Description |
---|---|---|
$data | mixed |
update_listing_data
public update_listing_data(mixed $data): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$data | mixed |
update_modifier_data
public update_modifier_data(mixed $data): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$data | mixed |
update_options_data
public update_options_data(mixed $data): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$data | mixed |
update_custom_field_data
public update_custom_field_data(mixed $data): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$data | mixed |
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
get_gallery_ids
public get_gallery_ids(): int[]
Return Value:
WP post IDs of gallery images
get_headless_featured_image
public get_headless_featured_image(string $size = '80'): string|null
Parameters:
Parameter | Type | Description |
---|---|---|
$size | string |
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:
Parameter | Type | Description |
---|---|---|
$post_ID | mixed | |
$format | mixed | |
$size | mixed |
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:
Parameter | Type | Description |
---|---|---|
$variant_id | int |
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:
Parameter | Type | Description |
---|---|---|
$variant_id | mixed |
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:
Parameter | Type | Description |
---|---|---|
$variant_id | int |
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:
Parameter | Type | Description |
---|---|---|
$variant_id | int |
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
related_products
Get a list of products related to this one
public related_products(array $args = []): int[]
Parameters:
Parameter | Type | Description |
---|---|---|
$args | array | Additional 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:
Parameter | Type | Description |
---|---|---|
$count | int | The 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:
Parameter | Type | Description |
---|---|---|
$product_id | int | |
$channel | \WP_Term|null | |
$query_args | array |
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:
Parameter | Type | Description |
---|---|---|
$product_sku | string | |
$channel | \WP_Term|null | |
$query_args | array |
Inherited methods
format_currency
Formats a numeric value as a currency string.
protected format_currency(float $value, string $empty_value = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$value | float | The currency value to format. |
$empty_value | string | The 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