Automattic\WooCommerce\Blocks\BlockTypes
AddToCartWithOptionsVariationSelector::get_variations_table
Get variations table HTML.
Method of the class: AddToCartWithOptionsVariationSelector{}
Hooks from the method
Returns
String
. Table HTML
Usage
// private - for code of main (parent) class only $result = $this->get_variations_table( $product, $variation_attributes ): string;
- $product(WC_Product) (required)
- Product instance.
- $variation_attributes(array) (required)
- Variation attributes.
AddToCartWithOptionsVariationSelector::get_variations_table() AddToCartWithOptionsVariationSelector::get variations table code WC 9.8.5
private function get_variations_table( $product, $variation_attributes ): string { ob_start(); /** * Action hook to add content before the variations table. * * @since 9.7.0 */ do_action( 'woocommerce_before_variations_table' ); $before_table = ob_get_clean(); $table = '<table class="variations" cellspacing="0" role="presentation"><tbody>'; foreach ( $variation_attributes as $attribute_name => $options ) { $table .= $this->get_variation_row( $product, $attribute_name, $options ); } $table .= '</tbody></table>'; ob_start(); /** * Action hook to add content after the variations table. * * @since 9.7.0 */ do_action( 'woocommerce_after_variations_table' ); $after_table = ob_get_clean(); return $before_table . $table . $after_table; }