Product_Form_Preview
A specialized version of the product form that disables purchase functionality.
It hides product options and renders a disabled purchase button.
- Full name:
\BigCommerce\Templates\Product_Form_Preview
- Parent class:
\BigCommerce\Templates\Product_Form
Properties
template
The template path for rendering the product form preview.
protected string $template
Methods
parse_options
Parses the options for the product form preview.
protected parse_options(array $options): array
Ensures that options are never displayed.
Parameters:
Parameter | Type | Description |
---|---|---|
$options | array | The original options array. |
Return Value:
The modified options array with options hidden.
get_data
Retrieves data for rendering the product form preview.
public get_data(): array
Temporarily adds a filter to overwrite the purchase button HTML.
Return Value:
The data array for rendering the product form preview.
overwrite_purchase_button
Overwrites the purchase button with a disabled button in the product form preview.
public overwrite_purchase_button(string $html, int $post_id, string $label): string
Parameters:
Parameter | Type | Description |
---|---|---|
$html | string | The original button HTML. |
$post_id | int | The product post ID. |
$label | string | The label for the button. |
Return Value:
The modified button HTML with a disabled state.
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.
factory
Creates an instance of the controller
public static factory(array $options = [], string $template = ''): static
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$options | array | |
$template | string |
__construct
public __construct(array $options = [], string $template = ''): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$options | array | |
$template | string |
parse_options
protected parse_options(array $options): array
Parameters:
Parameter | Type | Description |
---|---|---|
$options | array |
render
Render the template and return it as a string
public render(): string
Return Value:
The rendered template
get_data
Build the data that will be available to the template
public get_data(): array
wrap
Wrap the template output in an optional tag. This provides us a mechanism to ensure that some elements and classes are consistently available for JavaScript targeting, despite possible template overrides.
protected wrap(string $html): string
Parameters:
Parameter | Type | Description |
---|---|---|
$html | string |
get_wrapper_tag
protected get_wrapper_tag(): mixed
get_wrapper_classes
protected get_wrapper_classes(): mixed
get_wrapper_attributes
protected get_wrapper_attributes(): mixed
build_attribute_string
Build a string of HTML attributes that can safely be injected into a template out of a list of key/value pairs
protected build_attribute_string(array $attributes): string
Parameters:
Parameter | Type | Description |
---|---|---|
$attributes | array |
get_options
protected get_options(\BigCommerce\Post_Types\Product\Product $product): string
Parameters:
Parameter | Type | Description |
---|---|---|
$product | \BigCommerce\Post_Types\Product\Product |
Return Value:
The rendered option and modifier fields for the product
Automatically generated on 2025-01-21