You've already forked wc-bootstrap
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>
117 lines
5.4 KiB
Twig
117 lines
5.4 KiB
Twig
{#
|
|
# Grouped Product Add to Cart (Bootstrap 5 Override)
|
|
#
|
|
# Add-to-cart form for grouped products: table of child products with quantities.
|
|
#
|
|
# Expected context:
|
|
# product - WC_Product_Grouped object (global, injected by TemplateOverride)
|
|
# grouped_products - Array of child WC_Product objects
|
|
#
|
|
# Note: quantites_required and show_add_to_cart_button are computed inside the
|
|
# loop (matching WooCommerce's PHP template behavior), not passed as context.
|
|
#
|
|
# WooCommerce PHP equivalent: single-product/add-to-cart/grouped.php
|
|
#
|
|
# @package WcBootstrap
|
|
# @since 0.1.0
|
|
#}
|
|
|
|
{{ do_action('woocommerce_before_add_to_cart_form') }}
|
|
|
|
<form class="cart grouped_form" action="{{ product.get_permalink()|esc_url }}" method="post" enctype="multipart/form-data">
|
|
<div class="table-responsive mb-4">
|
|
<table class="woocommerce-grouped-product-list group_table table table-borderless align-middle">
|
|
{% set quantites_required = false %}
|
|
{% set show_add_to_cart_button = false %}
|
|
|
|
{{ do_action('woocommerce_grouped_product_list_before') }}
|
|
|
|
{% for grouped_product in grouped_products %}
|
|
{% set child_id = grouped_product.get_id() %}
|
|
|
|
{# Set up global product data for each child (matches PHP's setup_postdata). #}
|
|
{{ wc_setup_product_data(grouped_product) }}
|
|
|
|
{% if grouped_product.is_purchasable() and not grouped_product.has_options() %}
|
|
{% set quantites_required = true %}
|
|
{% endif %}
|
|
{% if grouped_product.is_in_stock() %}
|
|
{% set show_add_to_cart_button = true %}
|
|
{% endif %}
|
|
|
|
<tr id="product-{{ child_id }}" class="woocommerce-grouped-product-list-item {{ grouped_product.get_stock_status() }}">
|
|
<td class="woocommerce-grouped-product-list-item__quantity" style="width: 140px;">
|
|
{% if not grouped_product.is_purchasable() or grouped_product.has_options() or not grouped_product.is_in_stock() %}
|
|
{# Non-purchasable, has options (variable), or out-of-stock: show view link #}
|
|
{% if grouped_product.is_visible() %}
|
|
<a href="{{ grouped_product.get_permalink()|esc_url }}" class="btn btn-sm btn-outline-secondary">
|
|
{{ __('View product') }}
|
|
</a>
|
|
{% endif %}
|
|
{% elseif grouped_product.is_sold_individually() %}
|
|
<div class="form-check">
|
|
<input type="checkbox"
|
|
name="quantity[{{ child_id }}]"
|
|
value="1"
|
|
class="form-check-input wc-grouped-product-add-to-cart-checkbox"
|
|
id="quantity-{{ child_id }}" />
|
|
</div>
|
|
{% else %}
|
|
{% include 'global/quantity-input.html.twig' with {
|
|
input_id: 'quantity_' ~ child_id,
|
|
input_name: 'quantity[' ~ child_id ~ ']',
|
|
input_value: '',
|
|
min_value: 0,
|
|
max_value: grouped_product.get_max_purchase_quantity(),
|
|
step: 1,
|
|
placeholder: '0',
|
|
inputmode: 'numeric',
|
|
classes: 'qty',
|
|
readonly: false,
|
|
type: 'number',
|
|
args: { product_name: grouped_product.get_name() }
|
|
} %}
|
|
{% endif %}
|
|
</td>
|
|
|
|
<td class="woocommerce-grouped-product-list-item__label">
|
|
<label for="product-{{ child_id }}">
|
|
{% if grouped_product.is_visible() %}
|
|
<a href="{{ grouped_product.get_permalink()|esc_url }}" class="text-decoration-none">
|
|
{{ grouped_product.get_name()|esc_html }}
|
|
</a>
|
|
{% else %}
|
|
{{ grouped_product.get_name()|esc_html }}
|
|
{% endif %}
|
|
</label>
|
|
</td>
|
|
|
|
<td class="woocommerce-grouped-product-list-item__price text-end">
|
|
<span class="price">
|
|
{{ grouped_product.get_price_html()|raw }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
|
|
{{ wp_reset_postdata() }}
|
|
|
|
{{ do_action('woocommerce_grouped_product_list_after') }}
|
|
</table>
|
|
</div>
|
|
|
|
<input type="hidden" name="add-to-cart" value="{{ product.get_id() }}" />
|
|
|
|
{% if quantites_required and show_add_to_cart_button %}
|
|
{{ do_action('woocommerce_before_add_to_cart_button') }}
|
|
|
|
<button type="submit" class="btn btn-primary btn-lg single_add_to_cart_button">
|
|
{{ product.single_add_to_cart_text() }}
|
|
</button>
|
|
|
|
{{ do_action('woocommerce_after_add_to_cart_button') }}
|
|
{% endif %}
|
|
</form>
|
|
|
|
{{ do_action('woocommerce_after_add_to_cart_form') }}
|