2026-02-28 10:28:13 +01:00
|
|
|
{#
|
|
|
|
|
# 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') }}
|
|
|
|
|
|
|
|
|
|
<form class="variations_form cart"
|
|
|
|
|
action="{{ product.get_permalink()|esc_url }}"
|
|
|
|
|
method="post"
|
|
|
|
|
enctype="multipart/form-data"
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
data-product_id="{{ product.get_id() }}"
|
|
|
|
|
data-product_variations="{{ available_variations|json_encode|esc_attr }}">
|
2026-02-28 10:28:13 +01:00
|
|
|
|
|
|
|
|
{{ do_action('woocommerce_before_variations_form') }}
|
|
|
|
|
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
{% 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. #}
|
2026-02-28 10:28:13 +01:00
|
|
|
<div class="variations mb-4">
|
|
|
|
|
{% for attribute_name, options in attributes %}
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
{% set sanitized_name = attribute_name|sanitize_title %}
|
2026-02-28 10:28:13 +01:00
|
|
|
<div class="mb-3">
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
<label class="form-label fw-semibold" for="{{ sanitized_name|esc_attr }}">
|
2026-02-28 10:28:13 +01:00
|
|
|
{{ wc_attribute_label(attribute_name)|esc_html }}
|
|
|
|
|
</label>
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
<select id="{{ sanitized_name|esc_attr }}"
|
2026-02-28 10:28:13 +01:00
|
|
|
class="form-select"
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
name="attribute_{{ sanitized_name|esc_attr }}"
|
|
|
|
|
data-attribute_name="attribute_{{ sanitized_name|esc_attr }}">
|
2026-02-28 10:28:13 +01:00
|
|
|
<option value="">{{ __('Choose an option') }}</option>
|
|
|
|
|
{% if options is iterable %}
|
|
|
|
|
{% for option in options %}
|
|
|
|
|
{% set selected_value = selected_attributes[attribute_name]|default('') %}
|
|
|
|
|
<option value="{{ option|esc_attr }}"{% if option == selected_value %} selected{% endif %}>
|
|
|
|
|
{{ option|esc_html }}
|
|
|
|
|
</option>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
{% endif %}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
{# Reset link — WC JS toggles visibility based on attribute selection #}
|
|
|
|
|
<a class="reset_variations btn btn-link btn-sm p-0 text-decoration-none" href="#" style="visibility: hidden;">
|
|
|
|
|
{{ __('Clear') }}
|
|
|
|
|
</a>
|
|
|
|
|
<div class="reset_variations_alert screen-reader-text" role="alert" aria-live="polite" aria-relevant="all"></div>
|
2026-02-28 10:28:13 +01:00
|
|
|
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
{{ do_action('woocommerce_after_variations_table') }}
|
2026-02-28 10:28:13 +01:00
|
|
|
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
{# 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. #}
|
2026-02-28 10:28:13 +01:00
|
|
|
<div class="single_variation_wrap">
|
|
|
|
|
{{ do_action('woocommerce_before_single_variation') }}
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
{{ do_action('woocommerce_single_variation') }}
|
2026-02-28 10:28:13 +01:00
|
|
|
{{ do_action('woocommerce_after_single_variation') }}
|
|
|
|
|
</div>
|
|
|
|
|
{% else %}
|
|
|
|
|
{# Out of stock / unavailable #}
|
|
|
|
|
<p class="stock out-of-stock alert alert-warning">
|
|
|
|
|
{{ __('This product is currently out of stock and unavailable.') }}
|
|
|
|
|
</p>
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
|
{{ do_action('woocommerce_after_variations_form') }}
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
{{ do_action('woocommerce_after_add_to_cart_form') }}
|
Fix 10 known bugs: catalog, single product, and account pages (v0.1.5)
Catalog: page title via woocommerce_page_title(), breadcrumbs, category
template rename (underscore), 3-column grid, single chevron on sort.
Single product: variable form data attributes + disabled CSS class fix
(WC JS only toggles CSS classes, not HTML disabled attribute), dark mode
select specificity (0,5,1) to beat WC's (0,4,3) background shorthand,
gallery main image in thumbnail strip with empty URL guard, related/
upsells setup_postdata for correct global $product, grouped product
loop logic rewrite.
Account: downloads via wc_get_customer_available_downloads().
New: product-gallery.js, sanitize_title filter, wc_setup_product_data()
and wp_reset_postdata() Twig functions, product-thumbnails.html.twig
suppressor. Removed obsolete PLAN.md and SETUP.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:33:31 +01:00
|
|
|
|