# AJAX add to cart for bundle products (YITH and WooCommerce bundles) (SUP-24186)

**Date**: 2026-04-03  
**Support Ticket**: SUP-24186

## What Changed

- `js/add-to-cart-ajax.min.js` — Detect bundle cart forms (`bundle_form`, `yith-wcpb-bundle-form`, `bundled_items*`, `yith_bundle_*`) and submit them with `form.serialize()` plus `product_id` and `action`, matching a normal POST so `$_POST` on the server includes all bundle fields. Skip the flat `serializeArray()` merge for that path. For simple products, fall back to `input[name="add-to-cart"]` and `data-product-id` when `.product_id` is missing.
- `changelog.txt` — User-facing FIX under the current unreleased version.

## Why

- **Problem**: With BodyCommerce “AJAX add to cart” enabled, bundle products (e.g. YITH WooCommerce Product Bundles) could not be added; disabling AJAX worked.
- **Cause**: The script built a flat object for `$.post()`. WooCommerce Product Bundles needs nested `bundled_items[...]` fields preserved; YITH uses `yith-wcpb-bundle-form` and `yith_bundle_*` inputs, not `bundle_form` / `bundled_items`, so the first fix did not match. The PHP handler expects `product_id`; many bundle templates only expose `add-to-cart` or `data-product-id`.

## Context

- Customer site: bundle product in Divi WooCommerce Add to Cart module; button class `ajax_add_to_cart`.

## Technical Details

- **Implementation**: `vanilla_woo === "bundle_serialized"` branch posts `application/x-www-form-urlencoded` body from `$cartForm.serialize()` with `product_id` and `action=bodycommerce_ajax_add_to_cart_woo_single` appended; same success path as other AJAX add-to-cart responses.
- ⚠️ **Do not** remove the YITH / `yith_bundle_` selectors without retesting YITH Product Bundles.

## Related

- Changelog: FIX — Bundle offers now add to the cart correctly when AJAX add to cart is turned on.

## Notes

- None.
