
內容簡介
在 WooCommerce 中,單一產品頁面和變數產品頁面都沒有提供 AJAX 加入購物車的功能。
此外掛可以為單一產品頁面和變數產品頁面添加 AJAX 功能。
外掛標籤
開發者團隊
原文外掛簡介
WooCommerce core does not provide AJAX add-to-cart on the single product page or for variable products listed on archive pages (it redirects to the single view). This plugin adds an unobtrusive AJAX workflow for:
Simple products (single product page button becomes AJAX)
Variable products on archive & block-based Product Collection (opens an accessible modal to choose attributes, then adds via AJAX)
Classic themes and modern block/FSE themes (2025 and later) with Product Collection blocks
Highlights:
* Works with WooCommerce fragments (mini-cart updates automatically)
* Accessible modal (focus trap, ESC to close, restore focus)
* Nonce-secured AJAX endpoints; sanitized and validated input
* Settings page to enable/disable variable product archive functionality
* Block theme compatibility (intercepts “Select options” buttons) with slug/product_id fallback
* Performance-minded (loads minified bundles built via Webpack; falls back to source if missing)
* Translations auto-loaded from WordPress.org (no manual POT/PO generation required)
Privacy: This plugin does not send any data to external services. It only uses WooCommerce cart/session APIs.
Development
Build commands:
Install dependencies:
npm install
Production build (minified + source maps):
npm run build
Watch during development:
npm run watch
Lint JS:
npm run lint
Translations: WordPress.org language packs auto-load this plugin’s strings. The former POT/PO/MO tooling and i18n loader file were removed (WP 4.6+). Do not add a load_plugin_textdomain() call; simply keep the Text Domain header accurate.
WooCommerce is a registered trademark of Automattic Inc. This plugin is not affiliated with or endorsed by Automattic/WooCommerce.
