You've already forked wc-bootstrap
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>
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
# Add-to-cart form for grouped products: table of child products with quantities.
|
||||
#
|
||||
# Expected context:
|
||||
# product - WC_Product_Grouped object
|
||||
# grouped_products - Array of child WC_Product objects
|
||||
# grouped_product_columns - Array of column definitions
|
||||
# quantites_required - Whether quantities are required
|
||||
# show_add_to_cart_button - Whether to show the submit button
|
||||
# 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
|
||||
#
|
||||
@@ -21,19 +21,48 @@
|
||||
<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() %}
|
||||
<tr id="product-{{ child_id }}" class="{{ grouped_product.get_stock_status() }}">
|
||||
|
||||
{# 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 grouped_product.is_purchasable() and grouped_product.is_in_stock() %}
|
||||
{% 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: 0,
|
||||
input_value: '',
|
||||
min_value: 0,
|
||||
max_value: grouped_product.get_max_purchase_quantity()|default(0),
|
||||
max_value: grouped_product.get_max_purchase_quantity(),
|
||||
step: 1,
|
||||
placeholder: '0',
|
||||
inputmode: 'numeric',
|
||||
@@ -46,7 +75,7 @@
|
||||
</td>
|
||||
|
||||
<td class="woocommerce-grouped-product-list-item__label">
|
||||
<label for="quantity_{{ child_id }}">
|
||||
<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 }}
|
||||
@@ -65,14 +94,17 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{{ wp_reset_postdata() }}
|
||||
|
||||
{{ do_action('woocommerce_grouped_product_list_after') }}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% if show_add_to_cart_button is not defined or show_add_to_cart_button %}
|
||||
<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') }}
|
||||
|
||||
<input type="hidden" name="add-to-cart" value="{{ product.get_id() }}" />
|
||||
<button type="submit" class="btn btn-primary btn-lg single_add_to_cart_button">
|
||||
{{ product.single_add_to_cart_text() }}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user