{# # Variable Product Add to Cart (Bootstrap 5 Override) # # Add-to-cart form for variable products with attribute selectors. # # Expected context: # product - WC_Product_Variable object # attributes - Array of attribute taxonomies # available_variations - JSON-encoded variations data # attribute_keys - Array of attribute keys # variations_json - Variations data as JSON string # variations_attr - Data attribute string for the form # selected_attributes - Currently selected attribute values # # WooCommerce PHP equivalent: single-product/add-to-cart/variable.php # # @package WcBootstrap # @since 0.1.0 #} {{ do_action('woocommerce_before_add_to_cart_form') }}
{{ do_action('woocommerce_before_variations_form') }} {% if available_variations is not same as(false) %} {# Variation attribute selectors. WC PHP uses sanitize_title() on attribute names for name/data-attribute_name so they match the lowercase keys in the variation data JSON. #}
{% for attribute_name, options in attributes %} {% set sanitized_name = attribute_name|sanitize_title %}
{% endfor %}
{# Reset link — WC JS toggles visibility based on attribute selection #} {{ do_action('woocommerce_after_variations_table') }} {# Single variation display + add-to-cart button. The woocommerce_single_variation hook outputs: - priority 10: empty .single_variation div (JS populates via underscore template) - priority 20: .variations_button div with quantity + add-to-cart button No manual wrapper divs — the hooks handle the full DOM structure. #}
{{ do_action('woocommerce_before_single_variation') }} {{ do_action('woocommerce_single_variation') }} {{ do_action('woocommerce_after_single_variation') }}
{% else %} {# Out of stock / unavailable #}

{{ __('This product is currently out of stock and unavailable.') }}

{% endif %} {{ do_action('woocommerce_after_variations_form') }}
{{ do_action('woocommerce_after_add_to_cart_form') }}