You've already forked wc-composable-product
Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd5965ae4c | |||
| 9bc7a62f20 | |||
| ed66c96d3d | |||
| ea64dbfb33 | |||
| 6507f4d8bb | |||
| 29a68b0be4 | |||
| fb8ddf903e | |||
| 33d2836de0 | |||
| c036a37602 | |||
| efedd1bf29 | |||
| 12388af5a0 | |||
| c39c13ffed | |||
| 7931dbeef9 | |||
| ee81de86c2 | |||
| 669888817b | |||
| 5564b888fc | |||
| 91aca25169 | |||
| 4195fb2651 | |||
| ba28ae174f | |||
| 755108a7d3 | |||
| 85983d5473 | |||
| 252b187600 | |||
| 8185a77697 | |||
| 6c2e317230 | |||
| 58f5329bc4 | |||
| 0767016370 | |||
| fa7ec0e422 | |||
| f4d2543d4e | |||
| 9e4513f911 | |||
| 4dc7b767a8 | |||
| f763e35d19 | |||
| 8b271c90c0 | |||
| 0dd4408b23 | |||
| 7a4a0a0135 | |||
| c6a48d6404 | |||
| ac1cb9b135 | |||
| f5bc0d0335 | |||
| 88a907c4dd | |||
| 03a7624564 | |||
| 1c3f44f3c2 | |||
| 287f8b778b | |||
| 63d8f9ed52 | |||
| 601570d724 | |||
| e9b2d1c79b | |||
| d27dd4b7bd | |||
| 1b7c7a0257 | |||
| 4f65c8e5e0 | |||
| 054617f320 | |||
| 8fc0614334 | |||
| 867abc8f63 | |||
| 818fd51502 | |||
| 392559dedc | |||
| 17d5312df3 | |||
| 037be97ece | |||
| 28d2223306 | |||
| 413b5d8acd | |||
| 8aaf30de99 | |||
| 18d340d029 | |||
| f1382490ec | |||
| f1b255a7f8 | |||
| 7520a37b05 | |||
| 7bde9e2f0c | |||
| e491dadc67 | |||
| 91f44b0080 | |||
| 7b1b778f5b | |||
| 67bc61cf91 | |||
| e9df6e4278 | |||
| a581ef42e6 | |||
| bcbf12702e |
205
.gitea/workflows/release.yml
Normal file
205
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
name: Create Release Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.3'
|
||||||
|
extensions: mbstring, xml, zip, intl, gettext
|
||||||
|
tools: composer:v2
|
||||||
|
|
||||||
|
- name: Get version from tag
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF_NAME#v}
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "Building version: $VERSION"
|
||||||
|
|
||||||
|
- name: Validate composer.json
|
||||||
|
run: composer validate --strict
|
||||||
|
|
||||||
|
- name: Install Composer dependencies (production)
|
||||||
|
run: |
|
||||||
|
composer config platform.php 8.3.0
|
||||||
|
composer install --no-dev --optimize-autoloader --no-interaction
|
||||||
|
|
||||||
|
- name: Install gettext
|
||||||
|
run: apt-get update && apt-get install -y gettext
|
||||||
|
|
||||||
|
- name: Compile translations
|
||||||
|
run: |
|
||||||
|
for po in languages/*.po; do
|
||||||
|
if [ -f "$po" ]; then
|
||||||
|
mo="${po%.po}.mo"
|
||||||
|
echo "Compiling $po to $mo"
|
||||||
|
msgfmt -o "$mo" "$po"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Verify plugin version matches tag
|
||||||
|
run: |
|
||||||
|
PLUGIN_VERSION=$(grep -oP "Version:\s*\K[0-9]+\.[0-9]+\.[0-9]+" wc-composable-product.php | head -1)
|
||||||
|
TAG_VERSION=${{ steps.version.outputs.version }}
|
||||||
|
if [ "$PLUGIN_VERSION" != "$TAG_VERSION" ]; then
|
||||||
|
echo "Error: Plugin version ($PLUGIN_VERSION) does not match tag version ($TAG_VERSION)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Version verified: $PLUGIN_VERSION"
|
||||||
|
|
||||||
|
- name: Create release directory
|
||||||
|
run: mkdir -p releases
|
||||||
|
|
||||||
|
- name: Build release package
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
PLUGIN_NAME="wc-composable-product"
|
||||||
|
RELEASE_FILE="releases/${PLUGIN_NAME}-${VERSION}.zip"
|
||||||
|
|
||||||
|
# Move to parent directory for proper zip structure
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Create zip with proper WordPress plugin structure
|
||||||
|
zip -r "${PLUGIN_NAME}/${RELEASE_FILE}" "${PLUGIN_NAME}" \
|
||||||
|
-x "${PLUGIN_NAME}/.git/*" \
|
||||||
|
-x "${PLUGIN_NAME}/.gitea/*" \
|
||||||
|
-x "${PLUGIN_NAME}/.github/*" \
|
||||||
|
-x "${PLUGIN_NAME}/.vscode/*" \
|
||||||
|
-x "${PLUGIN_NAME}/.claude/*" \
|
||||||
|
-x "${PLUGIN_NAME}/CLAUDE.md" \
|
||||||
|
-x "${PLUGIN_NAME}/wp-core" \
|
||||||
|
-x "${PLUGIN_NAME}/wp-core/*" \
|
||||||
|
-x "${PLUGIN_NAME}/wp-plugins" \
|
||||||
|
-x "${PLUGIN_NAME}/wp-plugins/*" \
|
||||||
|
-x "${PLUGIN_NAME}/releases/*" \
|
||||||
|
-x "${PLUGIN_NAME}/cache/*" \
|
||||||
|
-x "${PLUGIN_NAME}/composer.lock" \
|
||||||
|
-x "${PLUGIN_NAME}/*.log" \
|
||||||
|
-x "${PLUGIN_NAME}/.gitignore" \
|
||||||
|
-x "${PLUGIN_NAME}/.editorconfig" \
|
||||||
|
-x "${PLUGIN_NAME}/phpcs.xml*" \
|
||||||
|
-x "${PLUGIN_NAME}/phpunit.xml*" \
|
||||||
|
-x "${PLUGIN_NAME}/tests/*" \
|
||||||
|
-x "${PLUGIN_NAME}/*.po~" \
|
||||||
|
-x "${PLUGIN_NAME}/*.bak" \
|
||||||
|
-x "*.DS_Store"
|
||||||
|
|
||||||
|
cd "${PLUGIN_NAME}"
|
||||||
|
echo "Created: ${RELEASE_FILE}"
|
||||||
|
|
||||||
|
- name: Generate checksums
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
|
||||||
|
cd releases
|
||||||
|
sha256sum "wc-composable-product-${VERSION}.zip" > "wc-composable-product-${VERSION}.zip.sha256"
|
||||||
|
|
||||||
|
echo "SHA256:"
|
||||||
|
cat "wc-composable-product-${VERSION}.zip.sha256"
|
||||||
|
|
||||||
|
- name: Verify package structure
|
||||||
|
run: |
|
||||||
|
set +o pipefail
|
||||||
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
echo "Package contents:"
|
||||||
|
unzip -l "releases/wc-composable-product-${VERSION}.zip" | head -50 || true
|
||||||
|
|
||||||
|
# Verify main file is at correct location
|
||||||
|
if unzip -l "releases/wc-composable-product-${VERSION}.zip" | grep -q "wc-composable-product/wc-composable-product.php"; then
|
||||||
|
echo "✓ Main plugin file at correct location"
|
||||||
|
else
|
||||||
|
echo "✗ Error: Main plugin file not found at wc-composable-product/wc-composable-product.php"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify vendor directory is included
|
||||||
|
if unzip -l "releases/wc-composable-product-${VERSION}.zip" | grep -q "wc-composable-product/vendor/"; then
|
||||||
|
echo "✓ Vendor directory included"
|
||||||
|
else
|
||||||
|
echo "✗ Error: Vendor directory not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Extract changelog for release notes
|
||||||
|
id: changelog
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
# Extract changelog section for this version
|
||||||
|
NOTES=$(sed -n "/^## \[${VERSION}\]/,/^## \[/p" CHANGELOG.md | sed '$ d' | tail -n +2)
|
||||||
|
if [ -z "$NOTES" ]; then
|
||||||
|
NOTES="Release version ${VERSION}"
|
||||||
|
fi
|
||||||
|
# Save to file for multi-line output
|
||||||
|
echo "$NOTES" > release_notes.txt
|
||||||
|
echo "Release notes extracted"
|
||||||
|
|
||||||
|
- name: Create Gitea Release
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.SRC_GITEA_TOKEN }}
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
TAG_NAME=${{ github.ref_name }}
|
||||||
|
PRERELEASE="false"
|
||||||
|
if [[ "$TAG_NAME" == *-* ]]; then
|
||||||
|
PRERELEASE="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read release notes
|
||||||
|
BODY=$(cat release_notes.txt)
|
||||||
|
|
||||||
|
# Check if release already exists for this tag and delete it
|
||||||
|
EXISTING_RELEASE=$(curl -s \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME}")
|
||||||
|
|
||||||
|
EXISTING_ID=$(echo "$EXISTING_RELEASE" | jq -r '.id // empty')
|
||||||
|
|
||||||
|
if [ -n "$EXISTING_ID" ] && [ "$EXISTING_ID" != "null" ]; then
|
||||||
|
echo "Deleting existing release ID: $EXISTING_ID"
|
||||||
|
curl -s -X DELETE \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${EXISTING_ID}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create release via Gitea API
|
||||||
|
RELEASE_RESPONSE=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${VERSION}\", \"body\": $(echo "$BODY" | jq -Rs .), \"draft\": false, \"prerelease\": ${PRERELEASE}}" \
|
||||||
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases")
|
||||||
|
|
||||||
|
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | jq -r '.id')
|
||||||
|
|
||||||
|
if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "Failed to create release:"
|
||||||
|
echo "$RELEASE_RESPONSE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Created release ID: $RELEASE_ID"
|
||||||
|
|
||||||
|
# Upload attachments
|
||||||
|
for file in "releases/wc-composable-product-${VERSION}.zip" "releases/wc-composable-product-${VERSION}.zip.sha256"; do
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
FILENAME=$(basename "$file")
|
||||||
|
echo "Uploading $FILENAME..."
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary "@$file" \
|
||||||
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
||||||
|
echo "Uploaded $FILENAME"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Release created successfully: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/${TAG_NAME}"
|
||||||
13
.gitignore
vendored
Normal file → Executable file
13
.gitignore
vendored
Normal file → Executable file
@@ -1,13 +1,8 @@
|
|||||||
# Linked sources
|
|
||||||
wp-core
|
|
||||||
wp-plugins
|
|
||||||
|
|
||||||
# Editor swap files
|
# Editor swap files
|
||||||
*.*swp
|
*.*swp
|
||||||
|
|
||||||
# Composer
|
# Composer
|
||||||
vendor/
|
vendor/
|
||||||
composer.lock
|
|
||||||
|
|
||||||
# Cache
|
# Cache
|
||||||
cache/
|
cache/
|
||||||
@@ -15,12 +10,14 @@ cache/
|
|||||||
# Development files
|
# Development files
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
logs/
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
# OS files
|
# OS files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Binary files
|
||||||
|
languages/*.mo
|
||||||
|
|
||||||
# Release files
|
|
||||||
*.zip
|
|
||||||
releases/
|
|
||||||
|
|||||||
455
CHANGELOG.md
455
CHANGELOG.md
@@ -5,6 +5,461 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [1.3.0] - 2026-03-01
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Include Non-Public Products**: New option to include draft and private products in composable product selections
|
||||||
|
- Global setting under WooCommerce > Settings > Composable Products
|
||||||
|
- Per-product override in the Composable Options tab (Use global default / Yes / No)
|
||||||
|
- Useful when products should only be sold as part of a composition, not individually
|
||||||
|
- Translations for the new setting in all 6 locales (de_DE, de_CH, fr_CH, it_CH + informal variants)
|
||||||
|
|
||||||
|
## [1.2.1] - 2026-03-01
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Consolidated documentation: merged INSTALL.md into README.md, merged IMPLEMENTATION.md into CLAUDE.md
|
||||||
|
- Condensed CLAUDE.md from ~1960 lines to ~160 lines, keeping only essential architecture and lessons learned
|
||||||
|
- README.md now includes full installation guide, usage tutorial, and troubleshooting section
|
||||||
|
- Cleaned up .gitignore
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- INSTALL.md (content merged into README.md)
|
||||||
|
- IMPLEMENTATION.md (content merged into CLAUDE.md)
|
||||||
|
|
||||||
|
## [1.2.0] - 2026-03-01
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: Product selection always empty regardless of configuration (categories, tags, or SKUs)
|
||||||
|
- Root cause: Product query used a `meta_query` checking `_product_type` in `wp_postmeta`, but WooCommerce stores product types in the `product_type` **taxonomy** — the `!=` comparison with a non-existent meta key caused an INNER JOIN returning zero results
|
||||||
|
- Fix: Replaced broken `meta_query` with correct `tax_query` using `product_type` taxonomy to exclude composable products
|
||||||
|
- **CRITICAL**: Cart price always 0.00 despite correct frontend price calculation
|
||||||
|
- Root cause: `composable_price_calculated` flag was persisted to the cart session, preventing price recalculation on subsequent page loads — but `set_price()` only modifies the in-memory product object and is lost between requests
|
||||||
|
- Fix: Removed per-item session flag; the existing static `$already_calculated` flag already prevents duplicate calculation within a single request
|
||||||
|
- **Admin tab rendering**: Both General and Composable Options panels visible on initial page load
|
||||||
|
- Root cause: JavaScript manually showed `#composable_product_data` via `.show()` without hiding the General panel
|
||||||
|
- Fix: Trigger WooCommerce's native tab click instead, so the tab system handles panel visibility correctly
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Gitea CI/CD release workflow** (`.gitea/workflows/release.yml`)
|
||||||
|
- Triggered on `v*` tags
|
||||||
|
- Installs PHP 8.3 with production Composer dependencies
|
||||||
|
- Compiles `.po` → `.mo` translations
|
||||||
|
- Verifies plugin version matches tag
|
||||||
|
- Builds release ZIP with proper WordPress directory structure
|
||||||
|
- Generates SHA-256 checksums
|
||||||
|
- Verifies package contains main plugin file and vendor directory
|
||||||
|
- Extracts changelog for release notes
|
||||||
|
- Creates Gitea release with attachments via API
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Debug logging from v1.1.14 (no longer needed after root cause identified)
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Modified files: includes/Product_Type.php, includes/Cart_Handler.php, assets/js/admin.js
|
||||||
|
- New file: .gitea/workflows/release.yml
|
||||||
|
- Product query now correctly uses `tax_query` with `product_type` taxonomy (`NOT IN` operator)
|
||||||
|
- Cart price recalculated on every request via `woocommerce_before_calculate_totals` hook
|
||||||
|
- Admin JS uses `$('ul.product_data_tabs li.composable_options a').trigger('click')` for native WooCommerce tab handling
|
||||||
|
|
||||||
|
## [1.1.14] - 2025-12-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **DEBUG**: Comprehensive debug logging to troubleshoot product retrieval issues
|
||||||
|
- Error log output shows selection criteria, query arguments, and results
|
||||||
|
- Logs each product/variation being added to help identify filtering issues
|
||||||
|
- Enable by setting WP_DEBUG to true in wp-config.php
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Modified file: includes/Product_Type.php (added error_log statements throughout get_available_products())
|
||||||
|
- Logs criteria array (categories, tags, SKUs)
|
||||||
|
- Logs WP_Query arguments before execution
|
||||||
|
- Logs number of posts found by query
|
||||||
|
- Logs each variable product's variation count
|
||||||
|
- Logs each variation/simple product being added with name
|
||||||
|
- Logs total products available at end
|
||||||
|
- All logging wrapped in WP_DEBUG checks (no performance impact in production)
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- This is a debug release to help diagnose why products aren't showing
|
||||||
|
- No functional changes from v1.1.13
|
||||||
|
- User should enable WP_DEBUG and check debug.log or error.log
|
||||||
|
- Log output will show exactly where products are being filtered out
|
||||||
|
- All translation files remain at 100% completion (57/57 strings)
|
||||||
|
|
||||||
|
## [1.1.13] - 2025-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: "No products available for selection" message showing even when products are configured
|
||||||
|
- Removed overly strict `is_in_stock()` requirement that was filtering out all products
|
||||||
|
- Products now show regardless of stock status (out-of-stock items are displayed but disabled)
|
||||||
|
- Added `'relation' => 'AND'` to meta_query for proper handling of multiple meta conditions
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Product retrieval now shows all purchasable products, not just in-stock ones
|
||||||
|
- Stock status still displayed on frontend with appropriate styling
|
||||||
|
- Out-of-stock items shown but disabled via checkbox and visual indicators
|
||||||
|
- Frontend stock management from v1.1.0 still fully functional
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Modified file: includes/Product_Type.php (lines 117-124, 177, 181)
|
||||||
|
- Changed from `$variation->is_in_stock() && $variation->is_purchasable()` to just `$variation->is_purchasable()`
|
||||||
|
- Changed from `$product->is_in_stock() && $product->is_purchasable()` to just `$product->is_purchasable()`
|
||||||
|
- Added `'relation' => 'AND'` to meta_query array for WordPress query compatibility
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- This fixes the issue where NO products were showing in the selector
|
||||||
|
- Stock validation still occurs at add-to-cart time (Stock_Manager class)
|
||||||
|
- Frontend still displays stock badges (in stock, low stock, out of stock)
|
||||||
|
- Out-of-stock items remain non-selectable via disabled checkboxes
|
||||||
|
- All translation files remain at 100% completion (57/57 strings)
|
||||||
|
|
||||||
|
## [1.1.12] - 2025-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: Variable product variations still not appearing in product selector after v1.1.11 release
|
||||||
|
- Changed variation retrieval method from `get_available_variations()` to `get_children()` for more reliable variation ID retrieval
|
||||||
|
- `get_available_variations()` returns complex data arrays which may not work in all contexts
|
||||||
|
- `get_children()` returns simple array of variation IDs directly, ensuring consistent results
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Modified file: includes/Product_Type.php (lines 171-184)
|
||||||
|
- Changed from `$product->get_available_variations()` to `$product->get_children()`
|
||||||
|
- More direct and reliable method for retrieving variation IDs
|
||||||
|
- Each variation ID passed to `wc_get_product()` for full product object
|
||||||
|
- Maintains all stock and purchasability checks from v1.1.11
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- This is a patch release fixing the variable product support introduced in v1.1.11
|
||||||
|
- User reported "nope, still no product selectable" after v1.1.11
|
||||||
|
- Root cause: `get_available_variations()` returns variation data arrays instead of clean IDs
|
||||||
|
- `get_children()` is the standard WooCommerce method for retrieving variation IDs
|
||||||
|
- All translation files remain at 100% completion (57/57 strings - no changes needed)
|
||||||
|
|
||||||
|
## [1.1.11] - 2025-12-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **FEATURE**: Variable product support - composable products can now include variable products and their variations
|
||||||
|
- Variable products automatically expand to show all available variations as selectable items
|
||||||
|
- Each variation displays with full attribute information (e.g., "Product - Color: Red, Size: Large")
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Products not showing in selector when all available products were variable products
|
||||||
|
- Variable products were being filtered out because parent products aren't directly purchasable
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Modified `get_available_products()` to detect and handle variable products
|
||||||
|
- Variable products now expand into their individual variations
|
||||||
|
- Each variation checked individually for stock status and purchasability
|
||||||
|
- Simple products continue to work exactly as before
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Modified file: includes/Product_Type.php (lines 160-188)
|
||||||
|
- Added logic to detect `is_type('variable')` products
|
||||||
|
- Uses `get_available_variations()` to retrieve all variations
|
||||||
|
- Each variation validated with `is_in_stock()` and `is_purchasable()`
|
||||||
|
- Maintains backward compatibility with simple products
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- This is a feature enhancement release, not a bug fix
|
||||||
|
- Resolves the issue where categories containing only variable products showed no selections
|
||||||
|
- Variations display with their parent product name plus selected attributes
|
||||||
|
- Stock management works correctly for both simple products and variations
|
||||||
|
- All translation files remain at 100% completion (57/57 strings - no new strings added)
|
||||||
|
|
||||||
|
## [1.1.10] - 2025-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: Admin panel - Both General and Composable tabs visible simultaneously on initial page load
|
||||||
|
- **CRITICAL**: Frontend - No products showing in product selector, only cart button and pricing visible
|
||||||
|
- Empty product grid now shows helpful message instead of blank space
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Added explicit `display: none` to `#composable_product_data` panel for proper initial hiding
|
||||||
|
- Panel now only shows when `body.product-type-composable` class is present
|
||||||
|
- Added empty state message in product selector template when no products are configured
|
||||||
|
- Cleared Twig cache to ensure template changes take effect
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Empty state message: "No products available for selection. Please configure the product criteria in the admin panel."
|
||||||
|
- Translations for empty state message in all 6 supported locales (de_DE, de_DE_informal, de_CH, de_CH_informal, fr_CH, it_CH)
|
||||||
|
- Recompiled .mo translation files
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Modified files: assets/css/admin.css (lines 7-16), templates/product-selector.twig (lines 12-15)
|
||||||
|
- Root cause (admin): Panel lacked explicit CSS hiding rule, relied only on `hidden` class
|
||||||
|
- Root cause (frontend): No feedback when products array is empty
|
||||||
|
- Solution: CSS specificity + empty state conditional in Twig template
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- This release fixes two critical bugs discovered immediately after v1.1.9
|
||||||
|
- Admin interface now correctly hides composable panel until product type is selected
|
||||||
|
- Frontend provides clear user feedback when product selection is unavailable
|
||||||
|
- All translation files now 100% complete (57/57 strings)
|
||||||
|
|
||||||
|
## [1.1.9] - 2025-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: Admin rendering completely broken - tabs disappeared and fields appeared out of context after v1.1.8 release
|
||||||
|
- CSS selectors were too broad, hiding tab navigation along with field groups
|
||||||
|
- Removed `!important` flags that caused overly aggressive hiding
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Made CSS selectors more specific: `.options_group.show_if_composable` for field groups only
|
||||||
|
- Added separate rule for tab links: `.product_data_tabs li.composable_options`
|
||||||
|
- Tab navigation now works correctly without hiding itself
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Modified files: assets/css/admin.css (lines 22-40)
|
||||||
|
- Root cause: `.show_if_composable` class used by WooCommerce for both tab links AND field groups
|
||||||
|
- Solution: Separate selectors for each use case to prevent unintended hiding
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- This release fixes critical regression introduced in v1.1.8
|
||||||
|
- Admin interface now renders correctly with visible tabs and properly positioned fields
|
||||||
|
- No `!important` flags needed with specific selectors
|
||||||
|
|
||||||
|
## [1.1.8] - 2025-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: Admin rendering bug where both General and Composable Options tabs showed simultaneously on initial page load
|
||||||
|
- **CRITICAL**: Frontend product selector not appearing on product pages - WooCommerce's default add-to-cart button now hidden for composable products
|
||||||
|
- **CRITICAL**: Price formatting not localized - prices now display with proper currency symbols, decimal separators, and thousand separators for all locales
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `wc_price()` Twig function for proper price formatting in templates
|
||||||
|
- `formatPrice()` JavaScript method with full WooCommerce locale support
|
||||||
|
- Price format localization data passed to frontend JavaScript (decimal/thousand separators, currency position, number of decimals)
|
||||||
|
- `hide_default_add_to_cart()` method to prevent WooCommerce's default purchase UI for composable products
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Enhanced CSS specificity with `!important` flags for proper tab visibility control
|
||||||
|
- Template now uses `{{ fixed_price_html|raw }}` instead of raw currency concatenation
|
||||||
|
- Product selector passes pre-formatted price HTML from `wc_price()` function
|
||||||
|
- Frontend JavaScript updates prices dynamically using WooCommerce format settings
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Modified files: assets/css/admin.css (+24 lines), includes/Cart_Handler.php (+14 lines), includes/Plugin.php (+7 lines), includes/Product_Selector.php (+2 lines), templates/product-selector.twig, assets/js/frontend.js (+28 lines)
|
||||||
|
- All PHP files pass syntax validation
|
||||||
|
- Supports Swiss format (CHF 50.-), European format (50,00 €), US format ($50.00), and all other WooCommerce locales
|
||||||
|
- Thousand separator support: comma (1,000), dot (1.000), apostrophe (1'000), space (1 000)
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- This release fixes all three critical UI bugs reported in CLAUDE.md
|
||||||
|
- Admin tabs now display correctly on initial page load without JavaScript flicker
|
||||||
|
- Frontend product selector is now the only purchase interface (no WooCommerce default button)
|
||||||
|
- All prices maintain proper locale formatting during dynamic updates
|
||||||
|
|
||||||
|
## [1.1.7] - 2025-12-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Compiled .mo translation files for all 6 supported locales (de_DE, de_DE_informal, de_CH, de_CH_informal, fr_CH, it_CH)
|
||||||
|
- WordPress can now load translations in admin and frontend areas
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: Missing translations in WordPress admin when using non-English locales
|
||||||
|
- Settings page ("Composable Products", "Default Selection Limit", etc.) now properly translated
|
||||||
|
- Product settings ("Composable Options", "Selection Criteria", etc.) now properly translated
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Compiled .mo files from .po sources using msgfmt
|
||||||
|
- All 6 locales now have complete translation coverage (56/56 strings translated and compiled)
|
||||||
|
- .mo files required for WordPress i18n system to display translations
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- Previous versions included .po translation files but WordPress requires compiled .mo files
|
||||||
|
- This release makes all existing translations actually visible to users
|
||||||
|
|
||||||
|
## [1.1.6] - 2025-12-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Complete translations for all admin area strings across all 6 supported locales
|
||||||
|
- "Fixed Price" field label and description translations
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated translation template (.pot) to version 1.1.6
|
||||||
|
- Simplified "How to calculate the price" description text
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- All .po files now include translations for v1.1.4 admin strings
|
||||||
|
- 100% translation coverage maintained across all locales (56/56 strings)
|
||||||
|
- German formal/informal variants properly differentiated (Sie vs. du)
|
||||||
|
|
||||||
|
## [1.1.5] - 2025-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: Fixed Twig template error "Unknown 'esc_attr' filter" when rendering product selector
|
||||||
|
- Template compatibility issue when other plugins (e.g., WooCommerce Tier and Package Prices) use Twig
|
||||||
|
- WordPress escaping functions now properly registered as both Twig functions AND filters
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Added `TwigFilter` registrations for `esc_html`, `esc_attr`, and `esc_url` in `Plugin::init_twig()`
|
||||||
|
- Template can now use both syntax styles: `{{ value|esc_attr }}` (filter) and `{{ esc_attr(value) }}` (function)
|
||||||
|
- Prevents conflicts when multiple plugins bundle their own Twig installations
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- Previous versions only registered escaping functions as Twig functions, not filters
|
||||||
|
- Template used filter syntax (`|esc_attr`) which failed when parsed by external Twig instances
|
||||||
|
- Fix ensures compatibility regardless of which Twig instance processes the template
|
||||||
|
|
||||||
|
## [1.1.4] - 2025-12-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Fixed price field in Composable Options tab for easier price configuration
|
||||||
|
- JavaScript toggle to show/hide fixed price field based on selected pricing mode
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Simplified pricing mode description text in admin interface
|
||||||
|
- Fixed price field now appears dynamically when "Fixed" pricing mode is selected
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Added `_regular_price` field with `composable_fixed_price_field` CSS class in `Product_Data.php`
|
||||||
|
- Implemented `toggleFixedPriceField()` JavaScript function in `assets/js/admin.js`
|
||||||
|
- Progressive disclosure pattern improves admin UX by showing relevant fields only
|
||||||
|
|
||||||
|
## [1.1.3] - 2024-12-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- WooCommerce HPOS (High-Performance Order Storage) compatibility declaration
|
||||||
|
- Prevents duplicate price calculations to avoid conflicts with other pricing plugins
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- WooCommerce compatibility warnings with Analytics and other WooCommerce extensions
|
||||||
|
- Price calculation conflicts with third-party pricing plugins
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Added `before_woocommerce_init` hook to declare HPOS compatibility
|
||||||
|
- Implemented static flag in `Cart_Handler::calculate_cart_item_price()` to prevent multiple executions
|
||||||
|
- Added `composable_price_calculated` flag to cart items to prevent re-calculation by other plugins
|
||||||
|
- Ensures composable products work with WooCommerce's modern order storage system
|
||||||
|
|
||||||
|
## [1.1.2] - 2024-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **CRITICAL**: Fixed persistent "Class WC_Settings_Page not found" error that continued in v1.1.1
|
||||||
|
- Root cause: Settings.php was being included too early (during plugin init) before WC_Settings_Page was loaded
|
||||||
|
- Solution: Delayed Settings.php inclusion until `woocommerce_get_settings_pages` filter when class is guaranteed to exist
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Removed `require_once Settings.php` from `Plugin::includes()` (line 93)
|
||||||
|
- Added `require_once Settings.php` to `Plugin::add_settings_page()` (line 196)
|
||||||
|
- Settings file now loads on-demand when WooCommerce requests settings pages
|
||||||
|
- Previous hook change (woocommerce_init) was insufficient - class loading order was the real issue
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- v1.1.1 attempted to fix this with hook change but the error persisted
|
||||||
|
- This version addresses the actual root cause: premature class extension
|
||||||
|
|
||||||
|
## [1.1.1] - 2024-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Settings page initialization timing issue causing "Class WC_Settings_Page not found" error
|
||||||
|
- Changed hook from `woocommerce_loaded` to `woocommerce_init` to ensure WC_Settings_Page class is available
|
||||||
|
- Plugin now initializes after all WooCommerce core classes are loaded
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Hook changed from `woocommerce_loaded` to `woocommerce_init` in wc-composable-product.php:65
|
||||||
|
- `woocommerce_init` fires after WooCommerce has finished loading all its core classes including settings
|
||||||
|
|
||||||
|
## [1.1.0] - 2024-12-31
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Stock Management Integration**: Complete inventory tracking system for composable products
|
||||||
|
- Stock validation during product selection and add-to-cart
|
||||||
|
- Automatic stock deduction when orders are completed/processed
|
||||||
|
- Automatic stock restoration on order cancellation/refund
|
||||||
|
- Stock status indicators in product selector (In stock, Low stock, Out of stock)
|
||||||
|
- Visual feedback for out-of-stock items (disabled checkboxes, reduced opacity)
|
||||||
|
- Low stock warnings when 5 or fewer items remain
|
||||||
|
- Prevention of out-of-stock item selection
|
||||||
|
- Order notes documenting stock changes
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- New `Stock_Manager` class handling all stock operations
|
||||||
|
- Integration with WooCommerce order status hooks
|
||||||
|
- Stock information passed to frontend via Twig template
|
||||||
|
- Enhanced CSS styling for stock status badges
|
||||||
|
- Stock data stored in order item meta for accurate tracking
|
||||||
|
- Backorder support detection and handling
|
||||||
|
|
||||||
|
### Translation
|
||||||
|
|
||||||
|
- Added 8 new translatable strings for stock messages
|
||||||
|
- Updated Italian (Switzerland) translation with stock-related terms
|
||||||
|
- Updated translation template (.pot file)
|
||||||
|
|
||||||
|
## [1.0.1] - 2024-12-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fatal error "Class WC_Settings_Page not found" during plugin activation
|
||||||
|
- Changed initialization hook from `plugins_loaded` to `woocommerce_loaded` to ensure WooCommerce classes are available before plugin initialization
|
||||||
|
- Settings page now correctly integrates as a tab in WooCommerce > Settings
|
||||||
|
|
||||||
|
### Technical
|
||||||
|
|
||||||
|
- Plugin now waits for `woocommerce_loaded` action before initializing
|
||||||
|
- Prevents race condition where WooCommerce classes weren't loaded yet
|
||||||
|
- Settings tab appears correctly in WooCommerce settings interface
|
||||||
|
|
||||||
## [1.0.0] - 2024-12-31
|
## [1.0.0] - 2024-12-31
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
327
CLAUDE.md
327
CLAUDE.md
@@ -1,299 +1,186 @@
|
|||||||
# WooCommerce plugin for user composable products - AI Context Document
|
# WooCommerce Composable Products - AI Context Document
|
||||||
|
|
||||||
**Author:** Marco Graetsch
|
**Author:** Marco Graetsch
|
||||||
|
|
||||||
## Project Overview
|
## Project Overview
|
||||||
|
|
||||||
This plugin implements a special product type, for which users can select a limited number of product from a configurable set of simple or variable products. The limit of selectable products should be a global and per-product setting, for which global is the fallback. The set of selectable products can be defined per category, tag or SKU. The price is either a fixed price or the sum of the prices of the selected products. Think of a package of stickers as composable product, where each package can contain $limit number of stickers.
|
This plugin implements a custom WooCommerce product type where customers select a limited number of products from a configurable set of simple or variable products. The limit is configurable globally and per-product. The selectable products are defined by category, tag, or SKU. Pricing is either fixed or the sum of selected products. Think of a sticker pack where each package contains N stickers chosen by the customer.
|
||||||
|
|
||||||
### Key Fact: 100% AI-Generated
|
This project is 100% AI-generated ("vibe-coded") using Claude.AI.
|
||||||
|
|
||||||
This project is proudly **"vibe-coded"** using Claude.AI - the entire codebase was created through AI assistance.
|
|
||||||
|
|
||||||
## Technical Stack
|
## Technical Stack
|
||||||
|
|
||||||
- **Language:** PHP 8.3+
|
- **Language:** PHP 8.3+
|
||||||
- **Framework:** Latest WordPress Plugin API
|
- **Framework:** WordPress Plugin API
|
||||||
- **E-commerce:** WooCommerce 10.0+
|
- **E-commerce:** WooCommerce 10.0+
|
||||||
- **Template Engine:** Twig 3.0 (via Composer)
|
- **Template Engine:** Twig 3.0 (via Composer)
|
||||||
- **Frontend:** Vanilla JavaScript + jQuery
|
- **Frontend:** Vanilla JavaScript + jQuery
|
||||||
- **Styling:** Custom CSS
|
- **Styling:** Custom CSS
|
||||||
- **Dependency Management:** Composer
|
- **Dependencies:** Composer
|
||||||
- **Internationalization:** WordPress i18n (.pot/.po/.mo files)
|
- **i18n:** WordPress i18n (.pot/.po/.mo), text domain: `wc-composable-product`
|
||||||
|
- **CI/CD:** Gitea Actions (`.gitea/workflows/release.yml`)
|
||||||
## Implementation Details
|
|
||||||
|
|
||||||
### Security Best Practices
|
|
||||||
|
|
||||||
- All user inputs are sanitized (integers for quantities/prices)
|
|
||||||
- Nonce verification on form submissions
|
|
||||||
- Output escaping in templates (`esc_attr`, `esc_html`, `esc_js`)
|
|
||||||
- Direct file access prevention via `ABSPATH` check
|
|
||||||
|
|
||||||
### Translation Ready
|
|
||||||
|
|
||||||
All user-facing strings use:
|
|
||||||
|
|
||||||
```php
|
|
||||||
__('Text to translate', 'wc-composable-product')
|
|
||||||
_e('Text to translate', 'wc-composable-product')
|
|
||||||
```
|
|
||||||
|
|
||||||
Text domain: `wc-composable-product`
|
|
||||||
|
|
||||||
**Translation Template:**
|
|
||||||
|
|
||||||
- Base `.pot` file created: `languages/wc-composable-product.pot`
|
|
||||||
- Ready for translation to any locale
|
|
||||||
- All translatable strings properly marked with text domain
|
|
||||||
|
|
||||||
**Planned Translations:**
|
|
||||||
|
|
||||||
- `en_US` - English (United States) [base language]
|
|
||||||
- `de_DE` - German (Germany, formal)
|
|
||||||
- `de_DE_informal` - German (Germany, informal "du")
|
|
||||||
- `de_CH` - German (Switzerland, formal "Sie")
|
|
||||||
- `de_CH_informal` - German (Switzerland, informal "du")
|
|
||||||
- `fr_CH` - French (Switzerland)
|
|
||||||
- `it_CH` - Italian (Switzerland)
|
|
||||||
|
|
||||||
Note: Swiss locales should use CHF currency formatting in examples (e.g., "CHF 50.-")
|
|
||||||
|
|
||||||
### Create releases
|
|
||||||
|
|
||||||
- The `vendor/` directory MUST be included in releases (Twig dependency required for runtime)
|
|
||||||
- Running zip from wrong directory creates empty or malformed archives
|
|
||||||
- Exclusion patterns must match the relative path structure used in zip command
|
|
||||||
- Always verify the package with `unzip -l` and test extraction before committing
|
|
||||||
- The `wp-core/` and `wp-plugins/` directories MUST NOT be included in releases
|
|
||||||
- Releases are stored in `releases/` including checksums
|
|
||||||
|
|
||||||
**Important Git Notes:**
|
|
||||||
|
|
||||||
- Always commit from `dev` branch first
|
|
||||||
- Tags should use format `vX.X.X` (e.g., `v1.1.22`)
|
|
||||||
- Use annotated tags (`-a`) not lightweight tags
|
|
||||||
- Commit messages should follow the established format with Claude Code attribution
|
|
||||||
- `.claude/settings.local.json` changes are typically local-only (stash before rebasing)
|
|
||||||
|
|
||||||
#### What Gets Released
|
|
||||||
|
|
||||||
- All plugin source files
|
|
||||||
- Compiled vendor dependencies
|
|
||||||
- Translation files (.mo compiled from .po)
|
|
||||||
- Assets (CSS, JS)
|
|
||||||
- Documentation (README, CHANGELOG, etc.)
|
|
||||||
|
|
||||||
#### What's Excluded
|
|
||||||
|
|
||||||
- Git metadata (`.git/`)
|
|
||||||
- Development files (`.vscode/`, `.claude/`, `CLAUDE.md`)
|
|
||||||
- Logs and cache files
|
|
||||||
- Previous releases
|
|
||||||
- `composer.lock` (but `vendor/` is included)
|
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
wc-composable-product/
|
wc-composable-product/
|
||||||
|
├── .gitea/workflows/
|
||||||
|
│ └── release.yml # CI/CD release workflow
|
||||||
├── assets/
|
├── assets/
|
||||||
│ ├── css/
|
│ ├── css/
|
||||||
│ │ ├── admin.css # Admin panel styling
|
│ │ ├── admin.css # Admin panel styling
|
||||||
│ │ └── frontend.css # Customer-facing styles
|
│ │ └── frontend.css # Customer-facing styles (with stock indicators)
|
||||||
│ └── js/
|
│ └── js/
|
||||||
│ ├── admin.js # Product edit interface logic
|
│ ├── admin.js # Product edit interface logic
|
||||||
│ └── frontend.js # AJAX cart & selection UI
|
│ └── frontend.js # AJAX cart & selection UI
|
||||||
├── cache/ # Twig template cache (writable)
|
├── cache/ # Twig template cache (writable, gitignored)
|
||||||
├── includes/
|
├── includes/
|
||||||
│ ├── Admin/
|
│ ├── Admin/
|
||||||
│ │ ├── Product_Data.php # Product data tab & meta boxes
|
│ │ ├── Product_Data.php # Product data tab & meta boxes
|
||||||
│ │ └── Settings.php # WooCommerce settings integration
|
│ │ └── Settings.php # WooCommerce settings integration
|
||||||
│ ├── Cart_Handler.php # Add-to-cart & cart display logic
|
│ ├── Cart_Handler.php # Add-to-cart & cart display logic (with stock validation)
|
||||||
│ ├── Plugin.php # Main plugin class (Singleton)
|
│ ├── Plugin.php # Main plugin class (Singleton)
|
||||||
│ ├── Product_Selector.php # Frontend product selector renderer
|
│ ├── Product_Selector.php # Frontend product selector renderer (with stock info)
|
||||||
│ └── Product_Type.php # Custom WC_Product extension
|
│ ├── Product_Type.php # Custom WC_Product extension
|
||||||
├── languages/
|
│ └── Stock_Manager.php # Stock management & inventory tracking
|
||||||
│ └── wc-composable-product.pot # Translation template
|
├── languages/ # Translation files (.pot, .po, .mo)
|
||||||
|
├── releases/ # Release packages (gitignored)
|
||||||
├── templates/
|
├── templates/
|
||||||
│ └── product-selector.twig # Frontend selection interface
|
│ └── product-selector.twig # Frontend selection interface
|
||||||
├── vendor/ # Composer dependencies (gitignored)
|
├── vendor/ # Composer dependencies (gitignored, included in releases)
|
||||||
├── composer.json # Dependency configuration
|
├── composer.json
|
||||||
├── wc-composable-product.php # Main plugin file
|
└── wc-composable-product.php # Main plugin file
|
||||||
└── [Documentation files] # README, INSTALL, IMPLEMENTATION, etc.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Architecture Overview
|
## Architecture
|
||||||
|
|
||||||
### Core Classes
|
### Core Classes
|
||||||
|
|
||||||
1. **Plugin.php** - Main singleton class
|
1. **Plugin.php** — Main singleton class
|
||||||
- Initializes Twig template engine
|
- Initializes Twig with WordPress functions registered as both Twig functions AND filters
|
||||||
- Registers hooks and filters
|
- Registers hooks, manages asset enqueuing, provides template rendering API
|
||||||
- Manages asset enqueuing
|
- Settings.php is lazy-loaded via `woocommerce_get_settings_pages` filter (not in `includes()`) to avoid "Class WC_Settings_Page not found" errors
|
||||||
- Provides template rendering API
|
|
||||||
|
|
||||||
2. **Product_Type.php** - Custom WooCommerce product type
|
2. **Product_Type.php** — Custom WooCommerce product type (`composable`)
|
||||||
- Extends `WC_Product`
|
- Extends `WC_Product`
|
||||||
- Handles selection criteria (category/tag/SKU)
|
- Queries available products via `get_available_products()` using `WP_Query`
|
||||||
- Manages pricing modes (fixed/sum)
|
- **Critical**: Uses `tax_query` with `product_type` taxonomy to exclude composable products (NOT `meta_query` — WooCommerce stores product types as taxonomy terms)
|
||||||
- Queries available products dynamically
|
- Handles variable products by expanding them into individual variations via `get_children()`
|
||||||
|
- Products are filtered by `is_purchasable()` only (not `is_in_stock()` — stock is shown visually and validated at add-to-cart)
|
||||||
|
|
||||||
3. **Cart_Handler.php** - Cart integration
|
3. **Cart_Handler.php** — Cart integration
|
||||||
- Validates product selections
|
- Validates selections, stores selected products in cart meta, calculates pricing
|
||||||
- Stores selected products in cart meta
|
- Uses `woocommerce_is_purchasable` filter to hide default add-to-cart button for composable products
|
||||||
- Calculates dynamic pricing
|
- Price recalculation uses a static `$already_calculated` flag per request (no persistent session flags — `set_price()` is in-memory only)
|
||||||
- Displays selections in cart/checkout
|
|
||||||
|
|
||||||
4. **Product_Selector.php** - Frontend renderer
|
4. **Product_Selector.php** — Frontend renderer
|
||||||
- Renders Twig template with product data
|
- Renders Twig template with product data, stock info, and pre-formatted price HTML via `wc_price()`
|
||||||
- Applies display settings (images/prices/total)
|
|
||||||
|
|
||||||
5. **Admin/Product_Data.php** - Product edit interface
|
5. **Admin/Product_Data.php** — Product edit interface
|
||||||
- Adds "Composable Options" tab
|
- Adds "Composable Options" tab with category/tag/SKU selection fields
|
||||||
- Category/tag/SKU selection fields
|
- Saved meta: `_composable_selection_limit`, `_composable_pricing_mode`, `_composable_criteria_type`, `_composable_categories`, `_composable_tags`, `_composable_skus`
|
||||||
- Saves product metadata
|
|
||||||
|
|
||||||
6. **Admin/Settings.php** - Global settings
|
6. **Admin/Settings.php** — Global settings (extends `WC_Settings_Page`)
|
||||||
- WooCommerce settings tab integration
|
- Default selection limit, pricing mode, display preferences
|
||||||
- Default limits and pricing mode
|
|
||||||
- Display preferences
|
7. **Stock_Manager.php** — Inventory management
|
||||||
|
- Stock validation, automatic deduction on order completion, restoration on cancellation
|
||||||
|
- Prevents WooCommerce double-deduction via `woocommerce_can_reduce_order_stock`
|
||||||
|
|
||||||
### Data Flow
|
### Data Flow
|
||||||
|
|
||||||
**Product Creation:**
|
**Product Creation:** Admin selects "Composable product" type → configures criteria/limits/pricing → metadata saved as `_composable_*` fields
|
||||||
|
|
||||||
1. Admin selects "Composable product" type
|
**Frontend Display:** `Cart_Handler::render_product_selector()` → `Product_Type::get_available_products()` queries products via taxonomy/SKU → `Product_Selector::render()` passes data to Twig template → JavaScript handles selection UI
|
||||||
2. Configures criteria, limits, pricing in product data tab
|
|
||||||
3. Metadata saved: `_composable_*` fields
|
|
||||||
|
|
||||||
**Frontend Display:**
|
**Add to Cart:** Customer selects products → JS validates limit → AJAX request with `composable_products[]` → server-side validation (selection + stock) → selections stored in cart item data → price calculated per pricing mode
|
||||||
|
|
||||||
1. `Cart_Handler::render_product_selector()` called on product page
|
**Order Processing:** Order completed → `Stock_Manager` deducts inventory → order notes added for audit → on cancellation/refund: stock restored
|
||||||
2. `Product_Type::get_available_products()` queries matching products
|
|
||||||
3. `Product_Selector::render()` passes data to Twig template
|
|
||||||
4. JavaScript handles selection UI and AJAX
|
|
||||||
|
|
||||||
**Add to Cart:**
|
### Key Hooks
|
||||||
|
|
||||||
1. Customer selects products (JS validates limit)
|
- `woocommerce_add_to_cart_validation` — validate selections
|
||||||
2. AJAX request with `composable_products[]` array
|
- `woocommerce_add_cart_item_data` — store selections
|
||||||
3. `Cart_Handler::validate_add_to_cart()` server-side validation
|
- `woocommerce_before_calculate_totals` — update prices
|
||||||
4. `Cart_Handler::add_cart_item_data()` stores selections
|
- `woocommerce_get_item_data` — display in cart
|
||||||
5. `Cart_Handler::calculate_cart_item_price()` applies pricing
|
- `woocommerce_order_status_completed/processing` — deduct stock
|
||||||
|
- `woocommerce_order_status_cancelled/refunded` — restore stock
|
||||||
|
|
||||||
## Development Workflow
|
### Security
|
||||||
|
|
||||||
### Initial Setup
|
- Input: `absint()` for IDs/limits, `sanitize_text_field()` for modes, `sanitize_textarea_field()` for SKUs
|
||||||
|
- Output: `esc_html()`, `esc_attr()`, `esc_url()` (registered as both Twig functions and filters)
|
||||||
|
- Nonce verification via WooCommerce
|
||||||
|
|
||||||
```bash
|
### Developer API
|
||||||
composer install
|
|
||||||
|
```php
|
||||||
|
$product = wc_get_product($product_id);
|
||||||
|
if ($product->get_type() === 'composable') {
|
||||||
|
$products = $product->get_available_products();
|
||||||
|
$limit = $product->get_selection_limit();
|
||||||
|
$price = $product->calculate_composed_price($selected_ids);
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Making Changes
|
## Translations
|
||||||
|
|
||||||
1. **PHP Classes:** Edit files in `includes/` or `includes/Admin/`
|
All strings use text domain `wc-composable-product`. Available locales:
|
||||||
2. **Templates:** Modify `templates/*.twig` (cache clears on auto-reload)
|
|
||||||
3. **Styles:** Update `assets/css/*.css`
|
|
||||||
4. **JavaScript:** Edit `assets/js/*.js`
|
|
||||||
5. **Translations:** Update `.pot` file, create `.po` translations
|
|
||||||
|
|
||||||
### Testing Checklist
|
- `en_US` (base), `de_DE`, `de_DE_informal`, `de_CH`, `de_CH_informal`, `fr_CH`, `it_CH`
|
||||||
|
|
||||||
- [ ] Create composable product in admin
|
Compile .po to .mo: `for po in languages/*.po; do msgfmt -o "${po%.po}.mo" "$po"; done`
|
||||||
- [ ] Test each selection criteria type (category/tag/SKU)
|
|
||||||
- [ ] Verify selection limit enforcement
|
|
||||||
- [ ] Test both pricing modes (fixed/sum)
|
|
||||||
- [ ] Check AJAX add-to-cart functionality
|
|
||||||
- [ ] Verify cart display shows selected products
|
|
||||||
- [ ] Test checkout process
|
|
||||||
- [ ] Check responsive design on mobile
|
|
||||||
- [ ] Validate all strings are translatable
|
|
||||||
|
|
||||||
### Creating Releases
|
WordPress requires compiled .mo files — .po files alone are insufficient.
|
||||||
|
|
||||||
|
## Release Workflow
|
||||||
|
|
||||||
|
### Automated (Gitea CI/CD)
|
||||||
|
|
||||||
|
Push an annotated tag (`v*`) to trigger the workflow. It installs PHP 8.3, production Composer deps, compiles translations, verifies version matches tag, creates ZIP with checksums, and publishes a Gitea release.
|
||||||
|
|
||||||
|
### Manual
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# From project root
|
# From project root
|
||||||
zip -r wc-composable-product-vX.X.X.zip . \
|
zip -r releases/wc-composable-product-vX.X.X.zip . \
|
||||||
-x "*.git*" "*.vscode*" "*.claude*" "CLAUDE.md" \
|
-x "*.git*" "*.vscode*" "*.claude*" "CLAUDE.md" \
|
||||||
"wp-core" "wp-plugins" "*.log" "composer.lock" \
|
"wp-core/*" "wp-plugins/*" "*.log" "composer.lock" \
|
||||||
"cache/*" "releases/*" "*.zip"
|
"cache/*" "releases/*" "*.zip" "logs/*"
|
||||||
|
|
||||||
# Verify contents
|
|
||||||
unzip -l wc-composable-product-vX.X.X.zip
|
|
||||||
|
|
||||||
# IMPORTANT: Ensure vendor/ is included!
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Session History
|
The `vendor/` directory MUST be included in releases (Twig dependency required at runtime).
|
||||||
|
|
||||||
### v1.0.0 - Initial Implementation (2024-12-31)
|
### Git Workflow
|
||||||
|
|
||||||
**What was built:**
|
- Develop on `dev` branch, merge to `main` for releases
|
||||||
|
- Tags: annotated, format `vX.X.X` (e.g., `v1.2.0`)
|
||||||
|
- Commit messages include `Co-Authored-By: Claude` attribution
|
||||||
|
|
||||||
- Complete plugin implementation from scratch
|
## Critical Lessons Learned
|
||||||
- All 6 core PHP classes with PSR-4 autoloading
|
|
||||||
- Twig template system integration
|
|
||||||
- Responsive frontend with AJAX functionality
|
|
||||||
- Admin interface with WooCommerce integration
|
|
||||||
- Full i18n support with .pot template
|
|
||||||
- Comprehensive documentation (README, INSTALL, IMPLEMENTATION)
|
|
||||||
|
|
||||||
**Key decisions made:**
|
1. **WooCommerce stores product types as taxonomy terms** (`product_type` taxonomy), NOT as postmeta. Using `meta_query` on `_product_type` silently returns zero results because the meta key doesn't exist.
|
||||||
|
|
||||||
- Used Singleton pattern for main Plugin class
|
2. **`WC_Product::set_price()` is in-memory only** — changes are lost between HTTP requests. Never persist a "price already calculated" flag to cart session; use a static per-request flag instead.
|
||||||
- Twig for templating (per requirements)
|
|
||||||
- Vanilla JS + jQuery for frontend (WooCommerce standard)
|
|
||||||
- Grid layout for product selector (responsive)
|
|
||||||
- AJAX add-to-cart for better UX
|
|
||||||
- Meta-based configuration storage
|
|
||||||
|
|
||||||
**Files created:** 21 files, 2,628 lines of code
|
3. **Settings.php must be lazy-loaded** — `require_once` in `Plugin::includes()` causes "Class WC_Settings_Page not found" because WooCommerce hasn't loaded that class yet. Load it inside the `woocommerce_get_settings_pages` filter callback instead.
|
||||||
|
|
||||||
**Git workflow:**
|
4. **Register WordPress functions as both Twig functions AND filters** — other plugins may bundle their own Twig instance that parses our templates. Both `{{ esc_attr(value) }}` and `{{ value|esc_attr }}` syntax must work.
|
||||||
|
|
||||||
- Initial commit to `main` branch
|
5. **HPOS compatibility declaration is required** — without it, WooCommerce shows incompatibility warnings.
|
||||||
- Created `dev` branch from `main`
|
|
||||||
- Both branches in sync at v1.0.0
|
|
||||||
|
|
||||||
**What works:**
|
6. **WordPress i18n requires compiled .mo files** — .po files are source only; WordPress cannot use them directly.
|
||||||
|
|
||||||
- Product type registration ✓
|
7. **Don't filter by `is_in_stock()` during product retrieval** — it's too strict (excludes backorder-enabled products, products without stock management). Show all purchasable products; let the frontend display stock status and validate at add-to-cart time.
|
||||||
- Admin product data tab ✓
|
|
||||||
- Category/tag/SKU selection ✓
|
|
||||||
- Frontend product selector ✓
|
|
||||||
- AJAX add-to-cart ✓
|
|
||||||
- Cart integration ✓
|
|
||||||
- Pricing calculation (both modes) ✓
|
|
||||||
|
|
||||||
**Known limitations:**
|
## For AI Assistants
|
||||||
|
|
||||||
- Currently only simple products in selection (not variable)
|
When starting a new session:
|
||||||
- No grouped product support
|
|
||||||
- No automatic stock deduction for selected items
|
|
||||||
- Template cache requires manual clearing after updates
|
|
||||||
|
|
||||||
**Future enhancements to consider:**
|
1. Read this CLAUDE.md first
|
||||||
|
2. Check git log for recent changes
|
||||||
- Variable product support
|
3. Verify you're on the `dev` branch before making changes
|
||||||
- Quantity selection per item
|
4. Run `composer install` if vendor/ is missing
|
||||||
- Visual bundle preview
|
5. Test changes before committing
|
||||||
- Product recommendations
|
6. Follow commit message format with Claude Code attribution
|
||||||
- Stock management integration
|
7. Always use `tax_query` (not `meta_query`) for product type filtering
|
||||||
- Selection presets/templates
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**For AI Assistants:**
|
|
||||||
|
|
||||||
When starting a new session on this project:
|
|
||||||
|
|
||||||
1. Read this CLAUDE.md file first
|
|
||||||
2. Review IMPLEMENTATION.md for technical details
|
|
||||||
3. Check git log for recent changes
|
|
||||||
4. Verify you're on the `dev` branch before making changes
|
|
||||||
5. Run `composer install` if vendor/ is missing
|
|
||||||
6. Test changes before committing
|
|
||||||
7. Follow commit message format with Claude Code attribution
|
|
||||||
8. Update this session history section with learnings
|
|
||||||
|
|
||||||
Always refer to this document when starting work on this project. Good luck!
|
|
||||||
|
|||||||
@@ -1,406 +0,0 @@
|
|||||||
# WooCommerce Composable Products - Implementation Summary
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
This document provides a technical overview of the WooCommerce Composable Products plugin implementation.
|
|
||||||
|
|
||||||
**Version:** 1.0.0
|
|
||||||
**Created:** 2024-12-31
|
|
||||||
**AI-Generated:** 100% created with Claude.AI assistance
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
### Plugin Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
wc-composable-product/
|
|
||||||
├── assets/ # Frontend assets
|
|
||||||
│ ├── css/
|
|
||||||
│ │ ├── admin.css # Admin styles
|
|
||||||
│ │ └── frontend.css # Frontend styles
|
|
||||||
│ └── js/
|
|
||||||
│ ├── admin.js # Admin JavaScript
|
|
||||||
│ └── frontend.js # Frontend JavaScript
|
|
||||||
├── cache/ # Twig template cache
|
|
||||||
├── includes/ # PHP classes
|
|
||||||
│ ├── Admin/
|
|
||||||
│ │ ├── Product_Data.php # Product data tab
|
|
||||||
│ │ └── Settings.php # Settings page
|
|
||||||
│ ├── Cart_Handler.php # Cart integration
|
|
||||||
│ ├── Plugin.php # Main plugin class
|
|
||||||
│ ├── Product_Selector.php # Frontend selector
|
|
||||||
│ └── Product_Type.php # Custom product type
|
|
||||||
├── languages/ # Translation files
|
|
||||||
│ └── wc-composable-product.pot
|
|
||||||
├── templates/ # Twig templates
|
|
||||||
│ └── product-selector.twig
|
|
||||||
└── wc-composable-product.php # Main plugin file
|
|
||||||
```
|
|
||||||
|
|
||||||
## Core Components
|
|
||||||
|
|
||||||
### 1. Main Plugin Class (`Plugin.php`)
|
|
||||||
|
|
||||||
**Responsibilities:**
|
|
||||||
- Singleton pattern implementation
|
|
||||||
- Twig template engine initialization
|
|
||||||
- Hook registration
|
|
||||||
- Component initialization
|
|
||||||
- Asset enqueuing
|
|
||||||
|
|
||||||
**Key Methods:**
|
|
||||||
- `instance()`: Get singleton instance
|
|
||||||
- `init_twig()`: Initialize Twig with WordPress functions
|
|
||||||
- `render_template()`: Render Twig templates
|
|
||||||
- `add_product_type()`: Register composable product type
|
|
||||||
|
|
||||||
### 2. Product Type (`Product_Type.php`)
|
|
||||||
|
|
||||||
**Extends:** `WC_Product`
|
|
||||||
|
|
||||||
**Key Features:**
|
|
||||||
- Custom product type: `composable`
|
|
||||||
- Selection limit management (per-product or global)
|
|
||||||
- Pricing mode (fixed or sum)
|
|
||||||
- Product selection criteria (category/tag/SKU)
|
|
||||||
- Dynamic product availability
|
|
||||||
- Price calculation
|
|
||||||
|
|
||||||
**Key Methods:**
|
|
||||||
- `get_selection_limit()`: Get max selectable items
|
|
||||||
- `get_pricing_mode()`: Get pricing calculation mode
|
|
||||||
- `get_available_products()`: Query available products
|
|
||||||
- `calculate_composed_price()`: Calculate final price
|
|
||||||
|
|
||||||
### 3. Admin Settings (`Admin/Settings.php`)
|
|
||||||
|
|
||||||
**Extends:** `WC_Settings_Page`
|
|
||||||
|
|
||||||
**Global Settings:**
|
|
||||||
- Default selection limit
|
|
||||||
- Default pricing mode
|
|
||||||
- Display options (images, prices, total)
|
|
||||||
|
|
||||||
**Integration:** Adds tab to WooCommerce Settings
|
|
||||||
|
|
||||||
### 4. Product Data Tab (`Admin/Product_Data.php`)
|
|
||||||
|
|
||||||
**Responsibilities:**
|
|
||||||
- Add "Composable Options" tab to product edit page
|
|
||||||
- Render selection criteria fields
|
|
||||||
- Save product meta data
|
|
||||||
- Dynamic field visibility based on criteria type
|
|
||||||
|
|
||||||
**Saved Meta:**
|
|
||||||
- `_composable_selection_limit`: Item limit
|
|
||||||
- `_composable_pricing_mode`: Pricing calculation
|
|
||||||
- `_composable_criteria_type`: Selection method
|
|
||||||
- `_composable_categories`: Selected categories
|
|
||||||
- `_composable_tags`: Selected tags
|
|
||||||
- `_composable_skus`: SKU list
|
|
||||||
|
|
||||||
### 5. Product Selector (`Product_Selector.php`)
|
|
||||||
|
|
||||||
**Responsibilities:**
|
|
||||||
- Render frontend product selection interface
|
|
||||||
- Prepare data for Twig template
|
|
||||||
- Apply display settings
|
|
||||||
|
|
||||||
**Template Variables:**
|
|
||||||
- `products`: Available products array
|
|
||||||
- `selection_limit`: Max selections
|
|
||||||
- `pricing_mode`: Pricing calculation
|
|
||||||
- `show_images/prices/total`: Display flags
|
|
||||||
|
|
||||||
### 6. Cart Handler (`Cart_Handler.php`)
|
|
||||||
|
|
||||||
**Responsibilities:**
|
|
||||||
- Validate product selection
|
|
||||||
- Add selected products to cart data
|
|
||||||
- Calculate dynamic pricing
|
|
||||||
- Display selected products in cart
|
|
||||||
|
|
||||||
**Hooks:**
|
|
||||||
- `woocommerce_add_to_cart_validation`: Validate selections
|
|
||||||
- `woocommerce_add_cart_item_data`: Store selections
|
|
||||||
- `woocommerce_before_calculate_totals`: Update prices
|
|
||||||
- `woocommerce_get_item_data`: Display in cart
|
|
||||||
|
|
||||||
## Frontend Implementation
|
|
||||||
|
|
||||||
### Product Selector Template (`product-selector.twig`)
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
- Responsive grid layout
|
|
||||||
- Checkbox-based selection
|
|
||||||
- Product images and prices
|
|
||||||
- Real-time total calculation
|
|
||||||
- AJAX add-to-cart
|
|
||||||
|
|
||||||
**Data Attributes:**
|
|
||||||
- `data-product-id`: Composable product ID
|
|
||||||
- `data-selection-limit`: Max selections
|
|
||||||
- `data-pricing-mode`: Pricing mode
|
|
||||||
- `data-price`: Individual product prices
|
|
||||||
|
|
||||||
### JavaScript (`frontend.js`)
|
|
||||||
|
|
||||||
**Functionality:**
|
|
||||||
- Selection limit enforcement
|
|
||||||
- Visual feedback on selection
|
|
||||||
- Real-time price updates (sum mode)
|
|
||||||
- AJAX cart operations
|
|
||||||
- Error/success messages
|
|
||||||
|
|
||||||
**Key Functions:**
|
|
||||||
- `handleCheckboxChange()`: Selection logic
|
|
||||||
- `updateTotalPrice()`: Calculate total
|
|
||||||
- `addToCart()`: AJAX add-to-cart
|
|
||||||
- `showMessage()`: User feedback
|
|
||||||
|
|
||||||
### CSS Styling
|
|
||||||
|
|
||||||
**Approach:**
|
|
||||||
- Grid-based layout (responsive)
|
|
||||||
- Card-style product items
|
|
||||||
- Visual selection states
|
|
||||||
- Mobile-first design
|
|
||||||
- Breakpoints: 768px, 480px
|
|
||||||
|
|
||||||
## Data Flow
|
|
||||||
|
|
||||||
### Creating a Composable Product
|
|
||||||
|
|
||||||
1. Admin selects "Composable product" type
|
|
||||||
2. Configure selection limit and pricing mode
|
|
||||||
3. Choose selection criteria (category/tag/SKU)
|
|
||||||
4. Save product metadata
|
|
||||||
5. WooCommerce registers product with custom type
|
|
||||||
|
|
||||||
### Frontend Display
|
|
||||||
|
|
||||||
1. Customer visits product page
|
|
||||||
2. `Cart_Handler` renders `Product_Selector`
|
|
||||||
3. `Product_Type::get_available_products()` queries products
|
|
||||||
4. Twig template renders grid with products
|
|
||||||
5. JavaScript handles interactions
|
|
||||||
|
|
||||||
### Adding to Cart
|
|
||||||
|
|
||||||
1. Customer selects products (JavaScript validation)
|
|
||||||
2. Click "Add to Cart" button
|
|
||||||
3. AJAX request with selected product IDs
|
|
||||||
4. `Cart_Handler::validate_add_to_cart()` validates
|
|
||||||
5. `Cart_Handler::add_cart_item_data()` stores selections
|
|
||||||
6. `Cart_Handler::calculate_cart_item_price()` updates price
|
|
||||||
7. Product added to cart with custom data
|
|
||||||
|
|
||||||
### Cart Display
|
|
||||||
|
|
||||||
1. WooCommerce loads cart
|
|
||||||
2. `Cart_Handler::get_cart_item_from_session()` restores data
|
|
||||||
3. `Cart_Handler::display_cart_item_data()` shows selections
|
|
||||||
4. Price calculated dynamically on each cart load
|
|
||||||
|
|
||||||
## Security Implementation
|
|
||||||
|
|
||||||
### Input Sanitization
|
|
||||||
|
|
||||||
- **Integers:** `absint()` for IDs and limits
|
|
||||||
- **Text:** `sanitize_text_field()` for modes and types
|
|
||||||
- **Textarea:** `sanitize_textarea_field()` for SKUs
|
|
||||||
- **Arrays:** `array_map()` with sanitization functions
|
|
||||||
|
|
||||||
### Output Escaping
|
|
||||||
|
|
||||||
- **HTML:** `esc_html()`, `esc_html_e()`
|
|
||||||
- **Attributes:** `esc_attr()`
|
|
||||||
- **URLs:** `esc_url()`
|
|
||||||
- **JavaScript:** Localized scripts with escaped data
|
|
||||||
|
|
||||||
### Validation
|
|
||||||
|
|
||||||
- Selection limit enforcement
|
|
||||||
- Product availability verification
|
|
||||||
- Cart data validation
|
|
||||||
- Nonce verification (via WooCommerce)
|
|
||||||
|
|
||||||
## Internationalization
|
|
||||||
|
|
||||||
### Text Domain
|
|
||||||
|
|
||||||
`wc-composable-product`
|
|
||||||
|
|
||||||
### Translation Functions
|
|
||||||
|
|
||||||
- `__()`: Return translated string
|
|
||||||
- `_e()`: Echo translated string
|
|
||||||
- `sprintf()` with `__()`: Variable substitution
|
|
||||||
|
|
||||||
### POT File
|
|
||||||
|
|
||||||
Generated template: `languages/wc-composable-product.pot`
|
|
||||||
|
|
||||||
**Supported Locales (per CLAUDE.md):**
|
|
||||||
- en_US (English)
|
|
||||||
- de_DE, de_DE_informal (German - Germany)
|
|
||||||
- de_CH, de_CH_informal (German - Switzerland)
|
|
||||||
- fr_CH (French - Switzerland)
|
|
||||||
- it_CH (Italian - Switzerland)
|
|
||||||
|
|
||||||
## Performance Considerations
|
|
||||||
|
|
||||||
### Caching
|
|
||||||
|
|
||||||
- Twig templates cached in `cache/` directory
|
|
||||||
- Auto-reload enabled in debug mode
|
|
||||||
- Optimized Composer autoloader
|
|
||||||
|
|
||||||
### Database Queries
|
|
||||||
|
|
||||||
- Efficient `WP_Query` for product selection
|
|
||||||
- Meta queries for SKU filtering
|
|
||||||
- Taxonomy queries for category/tag filtering
|
|
||||||
|
|
||||||
### Asset Loading
|
|
||||||
|
|
||||||
- Scripts only on relevant pages
|
|
||||||
- Minification ready (use build tools)
|
|
||||||
- Conditional enqueuing
|
|
||||||
|
|
||||||
## Extensibility
|
|
||||||
|
|
||||||
### Hooks & Filters
|
|
||||||
|
|
||||||
**Available Filters:**
|
|
||||||
- `wc_composable_settings`: Modify settings array
|
|
||||||
- `woocommerce_product_class`: Custom product class
|
|
||||||
- `product_type_selector`: Product type registration
|
|
||||||
|
|
||||||
**Customization Points:**
|
|
||||||
- Twig templates (override in theme)
|
|
||||||
- CSS styling (enqueue custom styles)
|
|
||||||
- JavaScript behavior (extend object)
|
|
||||||
|
|
||||||
### Developer API
|
|
||||||
|
|
||||||
```php
|
|
||||||
// Get composable product
|
|
||||||
$product = wc_get_product($product_id);
|
|
||||||
|
|
||||||
// Check if composable
|
|
||||||
if ($product->get_type() === 'composable') {
|
|
||||||
// Get available products
|
|
||||||
$products = $product->get_available_products();
|
|
||||||
|
|
||||||
// Get selection limit
|
|
||||||
$limit = $product->get_selection_limit();
|
|
||||||
|
|
||||||
// Calculate price
|
|
||||||
$price = $product->calculate_composed_price($selected_ids);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Testing Checklist
|
|
||||||
|
|
||||||
### Admin Testing
|
|
||||||
- [ ] Product type appears in dropdown
|
|
||||||
- [ ] Composable Options tab displays
|
|
||||||
- [ ] Selection criteria toggle works
|
|
||||||
- [ ] Meta data saves correctly
|
|
||||||
- [ ] Settings page accessible
|
|
||||||
- [ ] Global defaults apply
|
|
||||||
|
|
||||||
### Frontend Testing
|
|
||||||
- [ ] Product selector renders
|
|
||||||
- [ ] Selection limit enforced
|
|
||||||
- [ ] Price calculation accurate (both modes)
|
|
||||||
- [ ] AJAX add-to-cart works
|
|
||||||
- [ ] Cart displays selections
|
|
||||||
- [ ] Checkout processes correctly
|
|
||||||
|
|
||||||
### Edge Cases
|
|
||||||
- [ ] Empty criteria (no products)
|
|
||||||
- [ ] Out of stock products excluded
|
|
||||||
- [ ] Invalid product selections rejected
|
|
||||||
- [ ] Multiple cart items unique
|
|
||||||
- [ ] Session persistence
|
|
||||||
|
|
||||||
## Known Limitations
|
|
||||||
|
|
||||||
1. **Variable Products:** Currently supports simple products in selection
|
|
||||||
2. **Grouped Products:** Cannot be used as selectable items
|
|
||||||
3. **Stock Management:** No automatic stock reduction for selected items
|
|
||||||
4. **Caching:** Template cache needs manual clearing after updates
|
|
||||||
|
|
||||||
## Future Enhancements
|
|
||||||
|
|
||||||
Potential features for future versions:
|
|
||||||
|
|
||||||
- Variable product support in selection
|
|
||||||
- Quantity selection per item (not just presence)
|
|
||||||
- Visual bundle previews
|
|
||||||
- Advanced pricing rules
|
|
||||||
- Stock management integration
|
|
||||||
- Product recommendations
|
|
||||||
- Selection templates/presets
|
|
||||||
- Multi-currency support enhancements
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
### Runtime
|
|
||||||
- PHP 8.3+
|
|
||||||
- WordPress 6.0+
|
|
||||||
- WooCommerce 8.0+
|
|
||||||
- Twig 3.0 (via Composer)
|
|
||||||
|
|
||||||
### Development
|
|
||||||
- Composer for dependency management
|
|
||||||
- WP-CLI for i18n operations (optional)
|
|
||||||
|
|
||||||
## Deployment
|
|
||||||
|
|
||||||
### Production Checklist
|
|
||||||
|
|
||||||
1. Run `composer install --no-dev --optimize-autoloader`
|
|
||||||
2. Ensure `vendor/` directory is included
|
|
||||||
3. Ensure `cache/` directory is writable
|
|
||||||
4. Test on staging environment
|
|
||||||
5. Clear all caches after activation
|
|
||||||
6. Verify WooCommerce compatibility
|
|
||||||
|
|
||||||
### Release Package
|
|
||||||
|
|
||||||
Must include:
|
|
||||||
- All PHP files
|
|
||||||
- `vendor/` directory
|
|
||||||
- Assets (CSS, JS)
|
|
||||||
- Templates
|
|
||||||
- Language files
|
|
||||||
- Documentation
|
|
||||||
|
|
||||||
Must exclude:
|
|
||||||
- `.git/` directory
|
|
||||||
- `composer.lock`
|
|
||||||
- Development files
|
|
||||||
- `wp-core/`, `wp-plugins/` symlinks
|
|
||||||
|
|
||||||
## Support & Maintenance
|
|
||||||
|
|
||||||
### Code Standards
|
|
||||||
- WordPress Coding Standards
|
|
||||||
- WooCommerce best practices
|
|
||||||
- PSR-4 autoloading
|
|
||||||
- Inline documentation
|
|
||||||
|
|
||||||
### Version Control
|
|
||||||
- Semantic versioning (MAJOR.MINOR.PATCH)
|
|
||||||
- Changelog maintained
|
|
||||||
- Annotated git tags
|
|
||||||
- Development on `dev` branch
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Last Updated:** 2024-12-31
|
|
||||||
**Maintainer:** Marco Graetsch
|
|
||||||
**AI Assistant:** Claude.AI (Anthropic)
|
|
||||||
150
INSTALL.md
150
INSTALL.md
@@ -1,150 +0,0 @@
|
|||||||
# Installation Guide
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
Before installing the WooCommerce Composable Products plugin, ensure your system meets these requirements:
|
|
||||||
|
|
||||||
- **PHP**: 8.3 or higher
|
|
||||||
- **WordPress**: 6.0 or higher
|
|
||||||
- **WooCommerce**: 8.0 or higher
|
|
||||||
- **Composer**: For dependency management
|
|
||||||
|
|
||||||
## Installation Steps
|
|
||||||
|
|
||||||
### 1. Upload Plugin Files
|
|
||||||
|
|
||||||
Upload the plugin directory to your WordPress installation:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
/wp-content/plugins/wc-composable-product/
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Install Dependencies
|
|
||||||
|
|
||||||
Navigate to the plugin directory and install dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd /wp-content/plugins/wc-composable-product/
|
|
||||||
composer install --no-dev --optimize-autoloader
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Activate Plugin
|
|
||||||
|
|
||||||
1. Log in to your WordPress admin panel
|
|
||||||
2. Navigate to **Plugins > Installed Plugins**
|
|
||||||
3. Find "WooCommerce Composable Products"
|
|
||||||
4. Click **Activate**
|
|
||||||
|
|
||||||
### 4. Configure Settings
|
|
||||||
|
|
||||||
After activation, configure the plugin:
|
|
||||||
|
|
||||||
1. Navigate to **WooCommerce > Settings**
|
|
||||||
2. Click on the **Composable Products** tab
|
|
||||||
3. Configure default settings:
|
|
||||||
- **Default Selection Limit**: Number of items customers can select (default: 5)
|
|
||||||
- **Default Pricing Mode**: Choose between "Sum of selected products" or "Fixed price"
|
|
||||||
- **Display Options**: Toggle product images, prices, and totals
|
|
||||||
|
|
||||||
## Creating Your First Composable Product
|
|
||||||
|
|
||||||
### Step 1: Create a New Product
|
|
||||||
|
|
||||||
1. Go to **Products > Add New**
|
|
||||||
2. Enter a product name (e.g., "Custom Sticker Pack")
|
|
||||||
|
|
||||||
### Step 2: Set Product Type
|
|
||||||
|
|
||||||
1. In the **Product Data** panel, select **Composable product** from the dropdown
|
|
||||||
|
|
||||||
### Step 3: Configure General Settings
|
|
||||||
|
|
||||||
In the **General** tab:
|
|
||||||
- Set a **Regular price** (used if pricing mode is "Fixed")
|
|
||||||
- Configure **Selection Limit** (leave empty to use global default)
|
|
||||||
- Choose **Pricing Mode** (leave empty to use global default)
|
|
||||||
|
|
||||||
### Step 4: Configure Composable Options
|
|
||||||
|
|
||||||
Click on the **Composable Options** tab:
|
|
||||||
|
|
||||||
1. **Selection Criteria**: Choose how to select available products
|
|
||||||
- **By Category**: Select product categories
|
|
||||||
- **By Tag**: Select product tags
|
|
||||||
- **By SKU**: Enter comma-separated SKUs
|
|
||||||
|
|
||||||
2. Based on your selection:
|
|
||||||
- **Categories**: Select one or more categories from the dropdown
|
|
||||||
- **Tags**: Select one or more tags from the dropdown
|
|
||||||
- **SKUs**: Enter SKUs like: `STICKER-01, STICKER-02, STICKER-03`
|
|
||||||
|
|
||||||
### Step 5: Publish
|
|
||||||
|
|
||||||
Click **Publish** to make your composable product live.
|
|
||||||
|
|
||||||
## Frontend Usage
|
|
||||||
|
|
||||||
When customers visit your composable product:
|
|
||||||
|
|
||||||
1. They see a grid of available products based on your criteria
|
|
||||||
2. They can select up to the configured limit
|
|
||||||
3. The total price updates in real-time (if using sum pricing mode)
|
|
||||||
4. Click "Add to Cart" to add the composition to their cart
|
|
||||||
5. Selected products are displayed in the cart
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Plugin Won't Activate
|
|
||||||
|
|
||||||
- Ensure WooCommerce is installed and activated first
|
|
||||||
- Check PHP version (must be 8.3+)
|
|
||||||
- Verify Composer dependencies are installed
|
|
||||||
|
|
||||||
### Products Not Showing in Selector
|
|
||||||
|
|
||||||
- Check that products are published and in stock
|
|
||||||
- Verify the selection criteria (category/tag/SKU) is correct
|
|
||||||
- Ensure products match the criteria you configured
|
|
||||||
|
|
||||||
### Twig Template Errors
|
|
||||||
|
|
||||||
- Ensure the `vendor/` directory exists and contains Twig
|
|
||||||
- Run `composer install` again
|
|
||||||
- Check that the `cache/` directory is writable
|
|
||||||
|
|
||||||
### JavaScript Not Working
|
|
||||||
|
|
||||||
- Clear browser cache
|
|
||||||
- Check browser console for errors
|
|
||||||
- Ensure jQuery is loaded (WooCommerce includes it)
|
|
||||||
|
|
||||||
## Updating
|
|
||||||
|
|
||||||
When updating the plugin:
|
|
||||||
|
|
||||||
1. Deactivate the plugin
|
|
||||||
2. Replace plugin files
|
|
||||||
3. Run `composer install --no-dev --optimize-autoloader`
|
|
||||||
4. Reactivate the plugin
|
|
||||||
5. Clear all caches (WordPress, browser, CDN)
|
|
||||||
|
|
||||||
## Uninstallation
|
|
||||||
|
|
||||||
To completely remove the plugin:
|
|
||||||
|
|
||||||
1. Deactivate the plugin
|
|
||||||
2. Delete the plugin from the Plugins page
|
|
||||||
3. Optionally clean up database entries (WooCommerce will handle this automatically)
|
|
||||||
|
|
||||||
## Support
|
|
||||||
|
|
||||||
For issues and feature requests:
|
|
||||||
- GitHub: https://github.com/magdev/wc-composable-product/issues
|
|
||||||
- Documentation: See README.md
|
|
||||||
|
|
||||||
## Next Steps
|
|
||||||
|
|
||||||
- Customize the template by editing `templates/product-selector.twig`
|
|
||||||
- Modify styles in `assets/css/frontend.css`
|
|
||||||
- Translate the plugin using the provided `.pot` file
|
|
||||||
- Create categories/tags for easier product organization
|
|
||||||
133
README.md
133
README.md
@@ -1,51 +1,112 @@
|
|||||||
# WooCommerce Composable Products
|
# WooCommerce Composable Products
|
||||||
|
|
||||||
Create composable products where customers can select a limited number of items from a configurable set of products.
|
Create composable products where customers can select a limited number of items from a configurable set of products. Think of it as a "build your own gift box" or "create your sticker pack" feature.
|
||||||
|
|
||||||
## Description
|
## Key Features
|
||||||
|
|
||||||
This plugin adds a new product type to WooCommerce that allows customers to build their own product bundles by selecting from a predefined set of simple or variable products. Think of it as a "build your own gift box" or "create your sticker pack" feature.
|
|
||||||
|
|
||||||
### Key Features
|
|
||||||
|
|
||||||
- **Custom Product Type**: New "Composable Product" type in WooCommerce
|
- **Custom Product Type**: New "Composable Product" type in WooCommerce
|
||||||
- **Flexible Selection**: Define available products by category, tag, or SKU
|
- **Flexible Selection**: Define available products by category, tag, or SKU
|
||||||
|
- **Variable Product Support**: Automatically expands variable products into selectable variations
|
||||||
|
- **Stock Management**: Real-time stock validation, visual indicators, and automatic inventory tracking
|
||||||
- **Configurable Limits**: Set global or per-product selection limits
|
- **Configurable Limits**: Set global or per-product selection limits
|
||||||
- **Pricing Options**: Fixed price or sum of selected products
|
- **Pricing Options**: Fixed price or sum of selected products with full locale-aware formatting
|
||||||
- **Multi-language Support**: Fully translatable with i18n support
|
- **Multi-language Support**: Fully translated in 6 locales (de_DE, de_CH, fr_CH, it_CH + informal variants)
|
||||||
- **Modern UI**: Clean interface built with Twig templates and vanilla JavaScript
|
- **Modern UI**: Clean interface built with Twig templates and vanilla JavaScript
|
||||||
|
- **CI/CD**: Automated release workflow for Gitea
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- PHP 8.3 or higher
|
- PHP 8.3 or higher
|
||||||
- WordPress 6.0 or higher
|
- WordPress 6.0 or higher
|
||||||
- WooCommerce 8.0 or higher
|
- WooCommerce 8.0 or higher
|
||||||
|
- Composer (for dependency management)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Upload the plugin files to `/wp-content/plugins/wc-composable-product/`
|
### From Release Package
|
||||||
2. Run `composer install --no-dev` in the plugin directory
|
|
||||||
3. Activate the plugin through the 'Plugins' menu in WordPress
|
1. Download the latest release ZIP from the releases page
|
||||||
4. Configure global settings under WooCommerce > Settings > Composable Products
|
2. In WordPress admin, go to **Plugins > Add New > Upload Plugin**
|
||||||
|
3. Upload the ZIP file and click **Install Now**
|
||||||
|
4. Activate the plugin through the **Plugins** menu
|
||||||
|
5. Configure global settings under **WooCommerce > Settings > Composable Products**
|
||||||
|
|
||||||
|
### From Source
|
||||||
|
|
||||||
|
1. Upload the plugin directory to `/wp-content/plugins/wc-composable-product/`
|
||||||
|
2. Install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /wp-content/plugins/wc-composable-product/
|
||||||
|
composer install --no-dev --optimize-autoloader
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Activate the plugin through the **Plugins** menu in WordPress
|
||||||
|
4. Configure global settings under **WooCommerce > Settings > Composable Products**
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Creating a Composable Product
|
|
||||||
|
|
||||||
1. Go to Products > Add New
|
|
||||||
2. Select "Composable Product" as the product type
|
|
||||||
3. Configure product details:
|
|
||||||
- Set the selection limit (or use global default)
|
|
||||||
- Choose pricing mode (fixed or sum)
|
|
||||||
- Define available products by category, tag, or SKU
|
|
||||||
4. Publish the product
|
|
||||||
|
|
||||||
### Global Settings
|
### Global Settings
|
||||||
|
|
||||||
Navigate to WooCommerce > Settings > Composable Products to configure:
|
Navigate to **WooCommerce > Settings > Composable Products** to configure:
|
||||||
- Default selection limit
|
|
||||||
- Default pricing mode
|
- **Default Selection Limit**: Number of items customers can select (default: 5)
|
||||||
- Display options
|
- **Default Pricing Mode**: Choose between "Sum of selected products" or "Fixed price"
|
||||||
|
- **Display Options**: Toggle product images, prices, and totals
|
||||||
|
|
||||||
|
### Creating a Composable Product
|
||||||
|
|
||||||
|
1. Go to **Products > Add New**
|
||||||
|
2. Select **Composable product** from the Product Data dropdown
|
||||||
|
3. In the **General** tab:
|
||||||
|
- Set a **Regular price** (used when pricing mode is "Fixed")
|
||||||
|
- Configure **Selection Limit** (leave empty to use global default)
|
||||||
|
- Choose **Pricing Mode** (leave empty to use global default)
|
||||||
|
4. Click the **Composable Options** tab:
|
||||||
|
- **Selection Criteria**: Choose how to define available products
|
||||||
|
- **By Category**: Select one or more product categories
|
||||||
|
- **By Tag**: Select one or more product tags
|
||||||
|
- **By SKU**: Enter comma-separated SKUs (e.g., `STICKER-01, STICKER-02`)
|
||||||
|
5. Click **Publish**
|
||||||
|
|
||||||
|
### Frontend Behavior
|
||||||
|
|
||||||
|
When customers visit a composable product page:
|
||||||
|
|
||||||
|
1. A grid of available products is displayed based on configured criteria
|
||||||
|
2. Customers select up to the configured limit via checkboxes
|
||||||
|
3. Total price updates in real-time (in sum pricing mode)
|
||||||
|
4. Stock indicators show availability (green/orange/red badges)
|
||||||
|
5. Click "Add to Cart" to add the composition to cart
|
||||||
|
6. Selected products are listed in the cart and checkout
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Plugin Won't Activate
|
||||||
|
|
||||||
|
- Ensure WooCommerce is installed and activated first
|
||||||
|
- Check PHP version (must be 8.3+)
|
||||||
|
- Verify Composer dependencies are installed (`vendor/` directory exists)
|
||||||
|
|
||||||
|
### Products Not Showing in Selector
|
||||||
|
|
||||||
|
- Check that products are published
|
||||||
|
- Verify the selection criteria (category/tag/SKU) matches existing products
|
||||||
|
- Ensure the criteria type and values are saved in the Composable Options tab
|
||||||
|
|
||||||
|
### Twig Template Errors
|
||||||
|
|
||||||
|
- Ensure the `vendor/` directory exists and contains Twig
|
||||||
|
- Run `composer install` again
|
||||||
|
- Check that the `cache/` directory is writable
|
||||||
|
|
||||||
|
### Updating
|
||||||
|
|
||||||
|
1. Deactivate the plugin
|
||||||
|
2. Replace plugin files (or upload new release ZIP)
|
||||||
|
3. If installed from source: run `composer install --no-dev --optimize-autoloader`
|
||||||
|
4. Reactivate the plugin
|
||||||
|
5. Clear all caches (WordPress, browser, CDN)
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
@@ -60,10 +121,28 @@ composer install
|
|||||||
### Translation
|
### Translation
|
||||||
|
|
||||||
Generate POT file:
|
Generate POT file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wp i18n make-pot . languages/wc-composable-product.pot
|
wp i18n make-pot . languages/wc-composable-product.pot
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Compile translations:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
for po in languages/*.po; do msgfmt -o "${po%.po}.mo" "$po"; done
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating Releases
|
||||||
|
|
||||||
|
Releases are automated via Gitea CI/CD. Push an annotated tag to trigger:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag -a v1.2.0 -m "Release v1.2.0"
|
||||||
|
git push origin v1.2.0
|
||||||
|
```
|
||||||
|
|
||||||
|
The workflow builds the release ZIP, compiles translations, generates checksums, and creates a Gitea release with attachments.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
GPL v3 or later - see LICENSE file for details
|
GPL v3 or later - see LICENSE file for details
|
||||||
@@ -74,4 +153,4 @@ Marco Graetsch
|
|||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
For issues and feature requests, please use the GitHub issue tracker.
|
For issues and feature requests, please use the issue tracker.
|
||||||
|
|||||||
23
assets/css/admin.css
Normal file → Executable file
23
assets/css/admin.css
Normal file → Executable file
@@ -4,10 +4,17 @@
|
|||||||
* @package WC_Composable_Product
|
* @package WC_Composable_Product
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Hide composable panel by default */
|
||||||
#composable_product_data {
|
#composable_product_data {
|
||||||
|
display: none;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Show composable panel when composable type is selected */
|
||||||
|
body.product-type-composable #composable_product_data {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.composable_criteria_group {
|
.composable_criteria_group {
|
||||||
border-top: 1px solid #eee;
|
border-top: 1px solid #eee;
|
||||||
padding-top: 12px;
|
padding-top: 12px;
|
||||||
@@ -19,11 +26,23 @@
|
|||||||
min-height: 150px;
|
min-height: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.show_if_composable {
|
/* Hide composable-specific elements by default (but not tabs) */
|
||||||
|
.options_group.show_if_composable {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.product-type-composable .show_if_composable {
|
/* Show composable elements when composable product type is selected */
|
||||||
|
body.product-type-composable .options_group.show_if_composable {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide the Composable Options tab link by default */
|
||||||
|
.product_data_tabs li.composable_options {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show the Composable Options tab when composable type selected */
|
||||||
|
body.product-type-composable .product_data_tabs li.composable_options {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
41
assets/css/frontend.css
Normal file → Executable file
41
assets/css/frontend.css
Normal file → Executable file
@@ -54,6 +54,20 @@
|
|||||||
background: #f0f8ff;
|
background: #f0f8ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.composable-product-item.out-of-stock {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.composable-product-item.out-of-stock:hover {
|
||||||
|
border-color: #e0e0e0;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.composable-product-item.out-of-stock .product-item-label {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
.product-item-label {
|
.product-item-label {
|
||||||
display: block;
|
display: block;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
@@ -94,6 +108,33 @@
|
|||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.product-item-stock {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stock-status {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stock-status.in-stock {
|
||||||
|
color: #2e7d32;
|
||||||
|
background: #e8f5e9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stock-status.low-stock {
|
||||||
|
color: #f57c00;
|
||||||
|
background: #fff3e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stock-status.out-of-stock {
|
||||||
|
color: #c62828;
|
||||||
|
background: #ffebee;
|
||||||
|
}
|
||||||
|
|
||||||
.product-item-checkmark {
|
.product-item-checkmark {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0.5rem;
|
top: 0.5rem;
|
||||||
|
|||||||
25
assets/js/admin.js
Normal file → Executable file
25
assets/js/admin.js
Normal file → Executable file
@@ -17,12 +17,14 @@
|
|||||||
if (productType === 'composable') {
|
if (productType === 'composable') {
|
||||||
$('.show_if_composable').show();
|
$('.show_if_composable').show();
|
||||||
$('.hide_if_composable').hide();
|
$('.hide_if_composable').hide();
|
||||||
$('#composable_product_data').show();
|
// Show the composable tab, then click it so WooCommerce's
|
||||||
$('.product_data_tabs .composable_options a').show();
|
// native tab system hides all other panels properly
|
||||||
|
$('.product_data_tabs li.composable_options').show();
|
||||||
|
$('ul.product_data_tabs li.composable_options a').trigger('click');
|
||||||
} else {
|
} else {
|
||||||
$('.show_if_composable').hide();
|
$('.show_if_composable').hide();
|
||||||
|
$('.product_data_tabs li.composable_options').hide();
|
||||||
$('#composable_product_data').hide();
|
$('#composable_product_data').hide();
|
||||||
$('.product_data_tabs .composable_options a').hide();
|
|
||||||
}
|
}
|
||||||
}).trigger('change');
|
}).trigger('change');
|
||||||
|
|
||||||
@@ -36,6 +38,23 @@
|
|||||||
$('#composable_criteria_' + criteriaType).show();
|
$('#composable_criteria_' + criteriaType).show();
|
||||||
}).trigger('change');
|
}).trigger('change');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle fixed price field based on pricing mode
|
||||||
|
*/
|
||||||
|
function toggleFixedPriceField() {
|
||||||
|
const pricingMode = $('#_composable_pricing_mode').val();
|
||||||
|
const $fixedPriceField = $('.composable_fixed_price_field');
|
||||||
|
|
||||||
|
if (pricingMode === 'fixed') {
|
||||||
|
$fixedPriceField.show();
|
||||||
|
} else {
|
||||||
|
$fixedPriceField.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#_composable_pricing_mode').on('change', toggleFixedPriceField);
|
||||||
|
toggleFixedPriceField();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize enhanced select for categories and tags
|
* Initialize enhanced select for categories and tags
|
||||||
*/
|
*/
|
||||||
|
|||||||
34
assets/js/frontend.js
Normal file → Executable file
34
assets/js/frontend.js
Normal file → Executable file
@@ -63,6 +63,36 @@
|
|||||||
this.clearMessages($container);
|
this.clearMessages($container);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format price using WooCommerce settings
|
||||||
|
*
|
||||||
|
* @param {number} price Price amount
|
||||||
|
* @return {string} Formatted price HTML
|
||||||
|
*/
|
||||||
|
formatPrice: function(price) {
|
||||||
|
if (typeof wcComposableProduct === 'undefined' || !wcComposableProduct.price_format) {
|
||||||
|
return price.toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
const format = wcComposableProduct.price_format;
|
||||||
|
const decimals = parseInt(format.decimals, 10);
|
||||||
|
const decimalSep = format.decimal_separator;
|
||||||
|
const thousandSep = format.thousand_separator;
|
||||||
|
|
||||||
|
// Format number
|
||||||
|
let priceStr = price.toFixed(decimals);
|
||||||
|
const parts = priceStr.split('.');
|
||||||
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousandSep);
|
||||||
|
priceStr = parts.join(decimalSep);
|
||||||
|
|
||||||
|
// Apply price format (e.g., "%1$s%2$s" for symbol+price or "%2$s%1$s" for price+symbol)
|
||||||
|
let formatted = format.price_format
|
||||||
|
.replace('%1$s', '<span class="woocommerce-Price-currencySymbol">' + format.currency_symbol + '</span>')
|
||||||
|
.replace('%2$s', priceStr);
|
||||||
|
|
||||||
|
return '<span class="woocommerce-Price-amount amount">' + formatted + '</span>';
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update total price
|
* Update total price
|
||||||
*
|
*
|
||||||
@@ -79,8 +109,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const currencySymbol = $container.find('.total-price').data('currency');
|
const formattedPrice = this.formatPrice(total);
|
||||||
$container.find('.calculated-total').text(currencySymbol + total.toFixed(2));
|
$container.find('.calculated-total').html(formattedPrice);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Marco Graetsch",
|
"name": "Marco Graetsch",
|
||||||
"email": "marco@example.com"
|
"email": "magdev3.0@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
|
|||||||
335
composer.lock
generated
Normal file
335
composer.lock
generated
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "1342d597ec95bd7abf806825a199cae0",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "symfony/deprecation-contracts",
|
||||||
|
"version": "v3.6.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/deprecation-contracts.git",
|
||||||
|
"reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62",
|
||||||
|
"reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/contracts",
|
||||||
|
"name": "symfony/contracts"
|
||||||
|
},
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "3.6-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"function.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A generic function and convention to trigger deprecation notices",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-09-25T14:21:43+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-ctype",
|
||||||
|
"version": "v1.33.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||||
|
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
|
||||||
|
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-ctype": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-ctype": "For best performance"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/polyfill",
|
||||||
|
"name": "symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Ctype\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Gert de Pagter",
|
||||||
|
"email": "BackEndTea@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for ctype functions",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"ctype",
|
||||||
|
"polyfill",
|
||||||
|
"portable"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/nicolas-grekas",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-09-09T11:45:10+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-mbstring",
|
||||||
|
"version": "v1.33.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||||
|
"reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493",
|
||||||
|
"reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-iconv": "*",
|
||||||
|
"php": ">=7.2"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-mbstring": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-mbstring": "For best performance"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/polyfill",
|
||||||
|
"name": "symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for the Mbstring extension",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"mbstring",
|
||||||
|
"polyfill",
|
||||||
|
"portable",
|
||||||
|
"shim"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/nicolas-grekas",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-12-23T08:48:59+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "twig/twig",
|
||||||
|
"version": "v3.22.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
|
"reference": "946ddeafa3c9f4ce279d1f34051af041db0e16f2"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/946ddeafa3c9f4ce279d1f34051af041db0e16f2",
|
||||||
|
"reference": "946ddeafa3c9f4ce279d1f34051af041db0e16f2",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.1.0",
|
||||||
|
"symfony/deprecation-contracts": "^2.5|^3",
|
||||||
|
"symfony/polyfill-ctype": "^1.8",
|
||||||
|
"symfony/polyfill-mbstring": "^1.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpstan/phpstan": "^2.0",
|
||||||
|
"psr/container": "^1.0|^2.0",
|
||||||
|
"symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/Resources/core.php",
|
||||||
|
"src/Resources/debug.php",
|
||||||
|
"src/Resources/escaper.php",
|
||||||
|
"src/Resources/string_loader.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Twig\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com",
|
||||||
|
"homepage": "http://fabien.potencier.org",
|
||||||
|
"role": "Lead Developer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Twig Team",
|
||||||
|
"role": "Contributors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Armin Ronacher",
|
||||||
|
"email": "armin.ronacher@active-4.com",
|
||||||
|
"role": "Project Founder"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
||||||
|
"homepage": "https://twig.symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"templating"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
|
"source": "https://github.com/twigphp/Twig/tree/v3.22.2"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-12-14T11:28:47+00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": {},
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": {
|
||||||
|
"php": ">=8.3"
|
||||||
|
},
|
||||||
|
"platform-dev": {},
|
||||||
|
"plugin-api-version": "2.6.0"
|
||||||
|
}
|
||||||
@@ -63,7 +63,7 @@ class Product_Data {
|
|||||||
woocommerce_wp_select([
|
woocommerce_wp_select([
|
||||||
'id' => '_composable_pricing_mode',
|
'id' => '_composable_pricing_mode',
|
||||||
'label' => __('Pricing Mode', 'wc-composable-product'),
|
'label' => __('Pricing Mode', 'wc-composable-product'),
|
||||||
'description' => __('How to calculate the price. Leave empty to use global default.', 'wc-composable-product'),
|
'description' => __('How to calculate the price.', 'wc-composable-product'),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'options' => [
|
'options' => [
|
||||||
'' => __('Use global default', 'wc-composable-product'),
|
'' => __('Use global default', 'wc-composable-product'),
|
||||||
@@ -72,6 +72,16 @@ class Product_Data {
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
woocommerce_wp_text_input([
|
||||||
|
'id' => '_regular_price',
|
||||||
|
'label' => __('Fixed Price', 'wc-composable-product') . ' (' . get_woocommerce_currency_symbol() . ')',
|
||||||
|
'description' => __('Enter the fixed price for this composable product.', 'wc-composable-product'),
|
||||||
|
'desc_tip' => true,
|
||||||
|
'type' => 'text',
|
||||||
|
'data_type' => 'price',
|
||||||
|
'wrapper_class' => 'composable_fixed_price_field',
|
||||||
|
]);
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,6 +95,19 @@ class Product_Data {
|
|||||||
<div id="composable_product_data" class="panel woocommerce_options_panel hidden">
|
<div id="composable_product_data" class="panel woocommerce_options_panel hidden">
|
||||||
<div class="options_group">
|
<div class="options_group">
|
||||||
<?php
|
<?php
|
||||||
|
woocommerce_wp_select([
|
||||||
|
'id' => '_composable_include_unpublished',
|
||||||
|
'label' => __('Include Non-Public Products', 'wc-composable-product'),
|
||||||
|
'description' => __('Allow draft and private products in the selection. Useful when products should only be sold as part of a composition.', 'wc-composable-product'),
|
||||||
|
'desc_tip' => true,
|
||||||
|
'options' => [
|
||||||
|
'' => __('Use global default', 'wc-composable-product'),
|
||||||
|
'yes' => __('Yes', 'wc-composable-product'),
|
||||||
|
'no' => __('No', 'wc-composable-product'),
|
||||||
|
],
|
||||||
|
'value' => get_post_meta($post->ID, '_composable_include_unpublished', true) ?: '',
|
||||||
|
]);
|
||||||
|
|
||||||
woocommerce_wp_select([
|
woocommerce_wp_select([
|
||||||
'id' => '_composable_criteria_type',
|
'id' => '_composable_criteria_type',
|
||||||
'label' => __('Selection Criteria', 'wc-composable-product'),
|
'label' => __('Selection Criteria', 'wc-composable-product'),
|
||||||
@@ -171,6 +194,10 @@ class Product_Data {
|
|||||||
$pricing_mode = isset($_POST['_composable_pricing_mode']) ? sanitize_text_field($_POST['_composable_pricing_mode']) : '';
|
$pricing_mode = isset($_POST['_composable_pricing_mode']) ? sanitize_text_field($_POST['_composable_pricing_mode']) : '';
|
||||||
update_post_meta($post_id, '_composable_pricing_mode', $pricing_mode);
|
update_post_meta($post_id, '_composable_pricing_mode', $pricing_mode);
|
||||||
|
|
||||||
|
// Save include unpublished
|
||||||
|
$include_unpublished = isset($_POST['_composable_include_unpublished']) ? sanitize_text_field($_POST['_composable_include_unpublished']) : '';
|
||||||
|
update_post_meta($post_id, '_composable_include_unpublished', $include_unpublished);
|
||||||
|
|
||||||
// Save criteria type
|
// Save criteria type
|
||||||
$criteria_type = isset($_POST['_composable_criteria_type']) ? sanitize_text_field($_POST['_composable_criteria_type']) : 'category';
|
$criteria_type = isset($_POST['_composable_criteria_type']) ? sanitize_text_field($_POST['_composable_criteria_type']) : 'category';
|
||||||
update_post_meta($post_id, '_composable_criteria_type', $criteria_type);
|
update_post_meta($post_id, '_composable_criteria_type', $criteria_type);
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ class Settings extends \WC_Settings_Page {
|
|||||||
],
|
],
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'title' => __('Include Non-Public Products', 'wc-composable-product'),
|
||||||
|
'desc' => __('Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually.', 'wc-composable-product'),
|
||||||
|
'id' => 'wc_composable_include_unpublished',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'default' => 'no',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'title' => __('Show Product Images', 'wc-composable-product'),
|
'title' => __('Show Product Images', 'wc-composable-product'),
|
||||||
'desc' => __('Display product images in the selection interface.', 'wc-composable-product'),
|
'desc' => __('Display product images in the selection interface.', 'wc-composable-product'),
|
||||||
|
|||||||
@@ -15,16 +15,41 @@ defined('ABSPATH') || exit;
|
|||||||
* Handles adding composable products to cart and calculating prices
|
* Handles adding composable products to cart and calculating prices
|
||||||
*/
|
*/
|
||||||
class Cart_Handler {
|
class Cart_Handler {
|
||||||
|
/**
|
||||||
|
* Stock manager instance
|
||||||
|
*
|
||||||
|
* @var Stock_Manager
|
||||||
|
*/
|
||||||
|
private $stock_manager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
$this->stock_manager = new Stock_Manager();
|
||||||
|
|
||||||
add_filter('woocommerce_add_to_cart_validation', [$this, 'validate_add_to_cart'], 10, 3);
|
add_filter('woocommerce_add_to_cart_validation', [$this, 'validate_add_to_cart'], 10, 3);
|
||||||
add_filter('woocommerce_add_cart_item_data', [$this, 'add_cart_item_data'], 10, 2);
|
add_filter('woocommerce_add_cart_item_data', [$this, 'add_cart_item_data'], 10, 2);
|
||||||
add_filter('woocommerce_get_cart_item_from_session', [$this, 'get_cart_item_from_session'], 10, 2);
|
add_filter('woocommerce_get_cart_item_from_session', [$this, 'get_cart_item_from_session'], 10, 2);
|
||||||
add_filter('woocommerce_get_item_data', [$this, 'display_cart_item_data'], 10, 2);
|
add_filter('woocommerce_get_item_data', [$this, 'display_cart_item_data'], 10, 2);
|
||||||
add_action('woocommerce_before_calculate_totals', [$this, 'calculate_cart_item_price']);
|
add_action('woocommerce_before_calculate_totals', [$this, 'calculate_cart_item_price']);
|
||||||
add_action('woocommerce_single_product_summary', [$this, 'render_product_selector'], 25);
|
add_action('woocommerce_single_product_summary', [$this, 'render_product_selector'], 25);
|
||||||
|
add_action('woocommerce_checkout_create_order_line_item', [$this->stock_manager, 'store_selected_products_in_order'], 10, 3);
|
||||||
|
add_filter('woocommerce_is_purchasable', [$this, 'hide_default_add_to_cart'], 10, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide default WooCommerce add to cart button for composable products
|
||||||
|
*
|
||||||
|
* @param bool $is_purchasable Is purchasable status
|
||||||
|
* @param \WC_Product $product Product object
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hide_default_add_to_cart($is_purchasable, $product) {
|
||||||
|
if ($product && $product->get_type() === 'composable') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $is_purchasable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,6 +112,13 @@ class Cart_Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate stock availability
|
||||||
|
$stock_validation = $this->stock_manager->validate_stock_availability($selected_products, $quantity);
|
||||||
|
if ($stock_validation !== true) {
|
||||||
|
wc_add_notice($stock_validation, 'error');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $passed;
|
return $passed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +200,12 @@ class Cart_Handler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use static flag to prevent multiple executions within the same request
|
||||||
|
static $already_calculated = false;
|
||||||
|
if ($already_calculated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($cart->get_cart() as $cart_item_key => $cart_item) {
|
foreach ($cart->get_cart() as $cart_item_key => $cart_item) {
|
||||||
if (isset($cart_item['data']) && $cart_item['data']->get_type() === 'composable') {
|
if (isset($cart_item['data']) && $cart_item['data']->get_type() === 'composable') {
|
||||||
if (isset($cart_item['composable_products'])) {
|
if (isset($cart_item['composable_products'])) {
|
||||||
@@ -177,5 +215,7 @@ class Cart_Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$already_calculated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,15 +84,23 @@ class Plugin {
|
|||||||
$this->twig->addFunction(new \Twig\TwigFunction('esc_html', 'esc_html'));
|
$this->twig->addFunction(new \Twig\TwigFunction('esc_html', 'esc_html'));
|
||||||
$this->twig->addFunction(new \Twig\TwigFunction('esc_attr', 'esc_attr'));
|
$this->twig->addFunction(new \Twig\TwigFunction('esc_attr', 'esc_attr'));
|
||||||
$this->twig->addFunction(new \Twig\TwigFunction('esc_url', 'esc_url'));
|
$this->twig->addFunction(new \Twig\TwigFunction('esc_url', 'esc_url'));
|
||||||
|
$this->twig->addFunction(new \Twig\TwigFunction('wc_price', 'wc_price'));
|
||||||
|
|
||||||
|
// Add WordPress escaping functions as Twig filters
|
||||||
|
$this->twig->addFilter(new \Twig\TwigFilter('esc_html', 'esc_html'));
|
||||||
|
$this->twig->addFilter(new \Twig\TwigFilter('esc_attr', 'esc_attr'));
|
||||||
|
$this->twig->addFilter(new \Twig\TwigFilter('esc_url', 'esc_url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include required files
|
* Include required files
|
||||||
*/
|
*/
|
||||||
private function includes() {
|
private function includes() {
|
||||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/Settings.php';
|
// Note: Settings.php is NOT included here because it extends WC_Settings_Page
|
||||||
|
// which isn't loaded until later. It's included in add_settings_page() instead.
|
||||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/Product_Data.php';
|
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/Product_Data.php';
|
||||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Product_Type.php';
|
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Product_Type.php';
|
||||||
|
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Stock_Manager.php';
|
||||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Cart_Handler.php';
|
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Cart_Handler.php';
|
||||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Product_Selector.php';
|
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Product_Selector.php';
|
||||||
|
|
||||||
@@ -154,6 +162,13 @@ class Plugin {
|
|||||||
'max_items' => __('Maximum items selected', 'wc-composable-product'),
|
'max_items' => __('Maximum items selected', 'wc-composable-product'),
|
||||||
'min_items' => __('Please select at least one item', 'wc-composable-product'),
|
'min_items' => __('Please select at least one item', 'wc-composable-product'),
|
||||||
],
|
],
|
||||||
|
'price_format' => [
|
||||||
|
'currency_symbol' => get_woocommerce_currency_symbol(),
|
||||||
|
'decimal_separator' => wc_get_price_decimal_separator(),
|
||||||
|
'thousand_separator' => wc_get_price_thousand_separator(),
|
||||||
|
'decimals' => wc_get_price_decimals(),
|
||||||
|
'price_format' => get_woocommerce_price_format(),
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,6 +205,8 @@ class Plugin {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function add_settings_page($settings) {
|
public function add_settings_page($settings) {
|
||||||
|
// Include Settings.php here, when WC_Settings_Page is guaranteed to be loaded
|
||||||
|
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/Settings.php';
|
||||||
$settings[] = new Admin\Settings();
|
$settings[] = new Admin\Settings();
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,14 @@ class Product_Selector {
|
|||||||
$show_prices = get_option('wc_composable_show_prices', 'yes') === 'yes';
|
$show_prices = get_option('wc_composable_show_prices', 'yes') === 'yes';
|
||||||
$show_total = get_option('wc_composable_show_total', 'yes') === 'yes';
|
$show_total = get_option('wc_composable_show_total', 'yes') === 'yes';
|
||||||
|
|
||||||
|
// Get stock manager for stock information
|
||||||
|
$stock_manager = new Stock_Manager();
|
||||||
|
|
||||||
// Prepare product data for template
|
// Prepare product data for template
|
||||||
$products_data = [];
|
$products_data = [];
|
||||||
foreach ($available_products as $available_product) {
|
foreach ($available_products as $available_product) {
|
||||||
|
$stock_info = $stock_manager->get_product_stock_info($available_product->get_id());
|
||||||
|
|
||||||
$products_data[] = [
|
$products_data[] = [
|
||||||
'id' => $available_product->get_id(),
|
'id' => $available_product->get_id(),
|
||||||
'name' => $available_product->get_name(),
|
'name' => $available_product->get_name(),
|
||||||
@@ -43,6 +48,11 @@ class Product_Selector {
|
|||||||
'price_html' => $available_product->get_price_html(),
|
'price_html' => $available_product->get_price_html(),
|
||||||
'image_url' => wp_get_attachment_image_url($available_product->get_image_id(), 'thumbnail'),
|
'image_url' => wp_get_attachment_image_url($available_product->get_image_id(), 'thumbnail'),
|
||||||
'permalink' => $available_product->get_permalink(),
|
'permalink' => $available_product->get_permalink(),
|
||||||
|
'stock_status' => $stock_info['stock_status'],
|
||||||
|
'in_stock' => $stock_info['in_stock'],
|
||||||
|
'stock_quantity' => $stock_info['stock_quantity'],
|
||||||
|
'managing_stock' => $stock_info['managing_stock'],
|
||||||
|
'backorders_allowed' => $stock_info['backorders_allowed'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +65,8 @@ class Product_Selector {
|
|||||||
'show_prices' => $show_prices,
|
'show_prices' => $show_prices,
|
||||||
'show_total' => $show_total,
|
'show_total' => $show_total,
|
||||||
'fixed_price' => $product->get_price(),
|
'fixed_price' => $product->get_price(),
|
||||||
|
'fixed_price_html' => wc_price($product->get_price()),
|
||||||
|
'zero_price_html' => wc_price(0),
|
||||||
'currency_symbol' => get_woocommerce_currency_symbol(),
|
'currency_symbol' => get_woocommerce_currency_symbol(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,22 @@ class Product_Type extends \WC_Product {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if non-public products should be included
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function should_include_unpublished() {
|
||||||
|
$per_product = $this->get_meta('_composable_include_unpublished', true);
|
||||||
|
if ($per_product === 'yes') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($per_product === 'no') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return get_option('wc_composable_include_unpublished', 'no') === 'yes';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get available products based on criteria
|
* Get available products based on criteria
|
||||||
*
|
*
|
||||||
@@ -104,21 +120,24 @@ class Product_Type extends \WC_Product {
|
|||||||
*/
|
*/
|
||||||
public function get_available_products() {
|
public function get_available_products() {
|
||||||
$criteria = $this->get_selection_criteria();
|
$criteria = $this->get_selection_criteria();
|
||||||
|
$include_unpublished = $this->should_include_unpublished();
|
||||||
$args = [
|
$args = [
|
||||||
'post_type' => 'product',
|
'post_type' => 'product',
|
||||||
'posts_per_page' => -1,
|
'posts_per_page' => -1,
|
||||||
'post_status' => 'publish',
|
'post_status' => $include_unpublished ? ['publish', 'draft', 'private'] : 'publish',
|
||||||
'orderby' => 'title',
|
'orderby' => 'title',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
'tax_query' => [],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Exclude composable products from selection
|
// Exclude composable products using the product_type taxonomy
|
||||||
$args['meta_query'] = [
|
// (WooCommerce stores product types as taxonomy terms, NOT as postmeta)
|
||||||
|
$args['tax_query'] = [
|
||||||
|
'relation' => 'AND',
|
||||||
[
|
[
|
||||||
'key' => '_product_type',
|
'taxonomy' => 'product_type',
|
||||||
'value' => 'composable',
|
'field' => 'slug',
|
||||||
'compare' => '!=',
|
'terms' => ['composable'],
|
||||||
|
'operator' => 'NOT IN',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -148,10 +167,12 @@ class Product_Type extends \WC_Product {
|
|||||||
case 'sku':
|
case 'sku':
|
||||||
if (!empty($criteria['skus'])) {
|
if (!empty($criteria['skus'])) {
|
||||||
$skus = array_map('trim', explode(',', $criteria['skus']));
|
$skus = array_map('trim', explode(',', $criteria['skus']));
|
||||||
$args['meta_query'][] = [
|
$args['meta_query'] = [
|
||||||
'key' => '_sku',
|
[
|
||||||
'value' => $skus,
|
'key' => '_sku',
|
||||||
'compare' => 'IN',
|
'value' => $skus,
|
||||||
|
'compare' => 'IN',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -163,13 +184,28 @@ class Product_Type extends \WC_Product {
|
|||||||
if ($query->have_posts()) {
|
if ($query->have_posts()) {
|
||||||
foreach ($query->posts as $post) {
|
foreach ($query->posts as $post) {
|
||||||
$product = wc_get_product($post->ID);
|
$product = wc_get_product($post->ID);
|
||||||
if ($product && $product->is_in_stock() && $product->is_purchasable()) {
|
|
||||||
|
if (!$product) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle variable products by including their variations
|
||||||
|
if ($product->is_type('variable')) {
|
||||||
|
$variation_ids = $product->get_children();
|
||||||
|
foreach ($variation_ids as $variation_id) {
|
||||||
|
$variation = wc_get_product($variation_id);
|
||||||
|
if ($variation && ($include_unpublished || $variation->is_purchasable())) {
|
||||||
|
$products[] = $variation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($include_unpublished || $product->is_purchasable()) {
|
||||||
$products[] = $product;
|
$products[] = $product;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
|
|
||||||
return $products;
|
return $products;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
283
includes/Stock_Manager.php
Normal file
283
includes/Stock_Manager.php
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Stock Manager
|
||||||
|
*
|
||||||
|
* @package WC_Composable_Product
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace WC_Composable_Product;
|
||||||
|
|
||||||
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stock Manager Class
|
||||||
|
*
|
||||||
|
* Handles stock management for composable products
|
||||||
|
*/
|
||||||
|
class Stock_Manager {
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
// Hook into order completion to reduce stock
|
||||||
|
add_action('woocommerce_order_status_completed', [$this, 'reduce_stock_on_order_complete'], 10, 1);
|
||||||
|
add_action('woocommerce_order_status_processing', [$this, 'reduce_stock_on_order_complete'], 10, 1);
|
||||||
|
|
||||||
|
// Hook into order cancellation/refund to restore stock
|
||||||
|
add_action('woocommerce_order_status_cancelled', [$this, 'restore_stock_on_order_cancel'], 10, 1);
|
||||||
|
add_action('woocommerce_order_status_refunded', [$this, 'restore_stock_on_order_cancel'], 10, 1);
|
||||||
|
|
||||||
|
// Prevent double stock reduction
|
||||||
|
add_filter('woocommerce_can_reduce_order_stock', [$this, 'prevent_composable_stock_reduction'], 10, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate stock availability for selected products
|
||||||
|
*
|
||||||
|
* @param array $selected_product_ids Array of product IDs
|
||||||
|
* @param int $quantity Quantity of composable product being added
|
||||||
|
* @return bool|string True if in stock, error message otherwise
|
||||||
|
*/
|
||||||
|
public function validate_stock_availability($selected_product_ids, $quantity = 1) {
|
||||||
|
foreach ($selected_product_ids as $product_id) {
|
||||||
|
$product = wc_get_product($product_id);
|
||||||
|
|
||||||
|
if (!$product) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip stock check if stock management is disabled for this product
|
||||||
|
if (!$product->managing_stock()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stock_quantity = $product->get_stock_quantity();
|
||||||
|
|
||||||
|
// Check if product is in stock
|
||||||
|
if (!$product->is_in_stock()) {
|
||||||
|
return sprintf(
|
||||||
|
/* translators: %s: product name */
|
||||||
|
__('"%s" is out of stock and cannot be selected.', 'wc-composable-product'),
|
||||||
|
$product->get_name()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if enough stock is available
|
||||||
|
if ($stock_quantity !== null && $stock_quantity < $quantity) {
|
||||||
|
return sprintf(
|
||||||
|
/* translators: 1: product name, 2: stock quantity */
|
||||||
|
__('Only %2$d of "%1$s" are available in stock.', 'wc-composable-product'),
|
||||||
|
$product->get_name(),
|
||||||
|
$stock_quantity
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for backorders
|
||||||
|
if ($product->backorders_allowed()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a product has sufficient stock
|
||||||
|
*
|
||||||
|
* @param int $product_id Product ID
|
||||||
|
* @param int $required_quantity Required quantity
|
||||||
|
* @return array Stock information [in_stock, stock_quantity, backorders_allowed]
|
||||||
|
*/
|
||||||
|
public function get_product_stock_info($product_id, $required_quantity = 1) {
|
||||||
|
$product = wc_get_product($product_id);
|
||||||
|
|
||||||
|
if (!$product) {
|
||||||
|
return [
|
||||||
|
'in_stock' => false,
|
||||||
|
'stock_quantity' => 0,
|
||||||
|
'backorders_allowed' => false,
|
||||||
|
'stock_status' => 'outofstock',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stock_quantity = $product->get_stock_quantity();
|
||||||
|
$managing_stock = $product->managing_stock();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'in_stock' => $product->is_in_stock(),
|
||||||
|
'stock_quantity' => $stock_quantity,
|
||||||
|
'backorders_allowed' => $product->backorders_allowed(),
|
||||||
|
'stock_status' => $product->get_stock_status(),
|
||||||
|
'managing_stock' => $managing_stock,
|
||||||
|
'has_enough_stock' => !$managing_stock || $stock_quantity === null || $stock_quantity >= $required_quantity,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reduce stock for composable products when order is completed
|
||||||
|
*
|
||||||
|
* @param int $order_id Order ID
|
||||||
|
*/
|
||||||
|
public function reduce_stock_on_order_complete($order_id) {
|
||||||
|
$order = wc_get_order($order_id);
|
||||||
|
|
||||||
|
if (!$order) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if stock has already been reduced
|
||||||
|
if ($order->get_meta('_composable_stock_reduced', true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($order->get_items() as $item) {
|
||||||
|
$product = $item->get_product();
|
||||||
|
|
||||||
|
if (!$product || $product->get_type() !== 'composable') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get selected products from order item meta
|
||||||
|
$selected_products = $item->get_meta('_composable_products', true);
|
||||||
|
|
||||||
|
if (empty($selected_products) || !is_array($selected_products)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$quantity = $item->get_quantity();
|
||||||
|
|
||||||
|
// Reduce stock for each selected product
|
||||||
|
foreach ($selected_products as $product_id) {
|
||||||
|
$selected_product = wc_get_product($product_id);
|
||||||
|
|
||||||
|
if (!$selected_product || !$selected_product->managing_stock()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stock_quantity = $selected_product->get_stock_quantity();
|
||||||
|
|
||||||
|
if ($stock_quantity !== null) {
|
||||||
|
$new_stock = $stock_quantity - $quantity;
|
||||||
|
$selected_product->set_stock_quantity($new_stock);
|
||||||
|
$selected_product->save();
|
||||||
|
|
||||||
|
// Add order note
|
||||||
|
$order->add_order_note(
|
||||||
|
sprintf(
|
||||||
|
/* translators: 1: product name, 2: quantity, 3: remaining stock */
|
||||||
|
__('Stock reduced for "%1$s": -%2$d (remaining: %3$d)', 'wc-composable-product'),
|
||||||
|
$selected_product->get_name(),
|
||||||
|
$quantity,
|
||||||
|
$new_stock
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark stock as reduced
|
||||||
|
$order->update_meta_data('_composable_stock_reduced', true);
|
||||||
|
$order->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore stock when order is cancelled or refunded
|
||||||
|
*
|
||||||
|
* @param int $order_id Order ID
|
||||||
|
*/
|
||||||
|
public function restore_stock_on_order_cancel($order_id) {
|
||||||
|
$order = wc_get_order($order_id);
|
||||||
|
|
||||||
|
if (!$order) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if stock was reduced
|
||||||
|
if (!$order->get_meta('_composable_stock_reduced', true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($order->get_items() as $item) {
|
||||||
|
$product = $item->get_product();
|
||||||
|
|
||||||
|
if (!$product || $product->get_type() !== 'composable') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get selected products from order item meta
|
||||||
|
$selected_products = $item->get_meta('_composable_products', true);
|
||||||
|
|
||||||
|
if (empty($selected_products) || !is_array($selected_products)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$quantity = $item->get_quantity();
|
||||||
|
|
||||||
|
// Restore stock for each selected product
|
||||||
|
foreach ($selected_products as $product_id) {
|
||||||
|
$selected_product = wc_get_product($product_id);
|
||||||
|
|
||||||
|
if (!$selected_product || !$selected_product->managing_stock()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stock_quantity = $selected_product->get_stock_quantity();
|
||||||
|
|
||||||
|
if ($stock_quantity !== null) {
|
||||||
|
$new_stock = $stock_quantity + $quantity;
|
||||||
|
$selected_product->set_stock_quantity($new_stock);
|
||||||
|
$selected_product->save();
|
||||||
|
|
||||||
|
// Add order note
|
||||||
|
$order->add_order_note(
|
||||||
|
sprintf(
|
||||||
|
/* translators: 1: product name, 2: quantity, 3: new stock */
|
||||||
|
__('Stock restored for "%1$s": +%2$d (total: %3$d)', 'wc-composable-product'),
|
||||||
|
$selected_product->get_name(),
|
||||||
|
$quantity,
|
||||||
|
$new_stock
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark stock as restored
|
||||||
|
$order->update_meta_data('_composable_stock_reduced', false);
|
||||||
|
$order->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent WooCommerce from reducing stock for composable products
|
||||||
|
* We handle stock reduction manually for selected products
|
||||||
|
*
|
||||||
|
* @param bool $reduce_stock Whether to reduce stock
|
||||||
|
* @param \WC_Order $order Order object
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function prevent_composable_stock_reduction($reduce_stock, $order) {
|
||||||
|
foreach ($order->get_items() as $item) {
|
||||||
|
$product = $item->get_product();
|
||||||
|
|
||||||
|
if ($product && $product->get_type() === 'composable') {
|
||||||
|
// We'll handle stock reduction manually
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $reduce_stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store selected products in order item meta
|
||||||
|
*
|
||||||
|
* @param \WC_Order_Item_Product $item Order item
|
||||||
|
* @param string $cart_item_key Cart item key
|
||||||
|
* @param array $values Cart item values
|
||||||
|
*/
|
||||||
|
public function store_selected_products_in_order($item, $cart_item_key, $values) {
|
||||||
|
if (isset($values['composable_products']) && !empty($values['composable_products'])) {
|
||||||
|
$item->add_meta_data('_composable_products', $values['composable_products'], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
languages/wc-composable-product-de_CH.po
Normal file → Executable file
68
languages/wc-composable-product-de_CH.po
Normal file → Executable file
@@ -144,8 +144,16 @@ msgid "Pricing Mode"
|
|||||||
msgstr "Preismodus"
|
msgstr "Preismodus"
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "How to calculate the price. Leave empty to use global default."
|
msgid "How to calculate the price."
|
||||||
msgstr "Wie der Preis berechnet wird. Leer lassen, um den globalen Standard zu verwenden."
|
msgstr "Wie der Preis berechnet wird."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Fixed Price"
|
||||||
|
msgstr "Festpreis"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Enter the fixed price for this composable product."
|
||||||
|
msgstr "Geben Sie den Festpreis für dieses zusammenstellbare Produkt ein."
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "Use global default"
|
msgid "Use global default"
|
||||||
@@ -198,3 +206,59 @@ msgstr "Geben Sie Produkt-Artikelnummern durch Kommas getrennt ein."
|
|||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "SKU-1, SKU-2, SKU-3"
|
msgid "SKU-1, SKU-2, SKU-3"
|
||||||
msgstr "ART-1, ART-2, ART-3"
|
msgstr "ART-1, ART-2, ART-3"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "\"%s\" is out of stock and cannot be selected."
|
||||||
|
msgstr "\"%s\" ist nicht an Lager und kann nicht ausgewählt werden."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Only %2$d of \"%1$s\" are available in stock."
|
||||||
|
msgstr "Nur %2$d von \"%1$s\" sind an Lager verfügbar."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock reduced for \"%1$s\": -%2$d (remaining: %3$d)"
|
||||||
|
msgstr "Lagerbestand reduziert für \"%1$s\": -%2$d (verbleibend: %3$d)"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock restored for \"%1$s\": +%2$d (total: %3$d)"
|
||||||
|
msgstr "Lagerbestand wiederhergestellt für \"%1$s\": +%2$d (gesamt: %3$d)"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Out of stock"
|
||||||
|
msgstr "Nicht an Lager"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Only"
|
||||||
|
msgstr "Nur"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "left"
|
||||||
|
msgstr "übrig"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "In stock"
|
||||||
|
msgstr "An Lager"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "No products available for selection. Please configure the product criteria in the admin panel."
|
||||||
|
msgstr "Keine Produkte zur Auswahl verfügbar. Bitte konfigurieren Sie die Produktkriterien im Admin-Bereich."
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php, includes/Admin/Product_Data.php
|
||||||
|
msgid "Include Non-Public Products"
|
||||||
|
msgstr "Nicht-öffentliche Produkte einbeziehen"
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php
|
||||||
|
msgid "Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually."
|
||||||
|
msgstr "Entwürfe und private Produkte in der Auswahl zusammenstellbarer Produkte anzeigen. Nützlich, wenn Produkte nur als Teil einer Zusammenstellung verkauft werden sollen, nicht einzeln."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Allow draft and private products in the selection. Useful when products should only be sold as part of a composition."
|
||||||
|
msgstr "Entwürfe und private Produkte in der Auswahl zulassen. Nützlich, wenn Produkte nur als Teil einer Zusammenstellung verkauft werden sollen."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Yes"
|
||||||
|
msgstr "Ja"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "No"
|
||||||
|
msgstr "Nein"
|
||||||
|
|||||||
68
languages/wc-composable-product-de_CH_informal.po
Normal file → Executable file
68
languages/wc-composable-product-de_CH_informal.po
Normal file → Executable file
@@ -144,8 +144,16 @@ msgid "Pricing Mode"
|
|||||||
msgstr "Preismodus"
|
msgstr "Preismodus"
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "How to calculate the price. Leave empty to use global default."
|
msgid "How to calculate the price."
|
||||||
msgstr "Wie der Preis berechnet wird. Leer lassen, um den globalen Standard zu verwenden."
|
msgstr "Wie der Preis berechnet wird."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Fixed Price"
|
||||||
|
msgstr "Festpreis"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Enter the fixed price for this composable product."
|
||||||
|
msgstr "Gib den Festpreis für dieses zusammenstellbare Produkt ein."
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "Use global default"
|
msgid "Use global default"
|
||||||
@@ -198,3 +206,59 @@ msgstr "Gib Produkt-Artikelnummern durch Kommas getrennt ein."
|
|||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "SKU-1, SKU-2, SKU-3"
|
msgid "SKU-1, SKU-2, SKU-3"
|
||||||
msgstr "ART-1, ART-2, ART-3"
|
msgstr "ART-1, ART-2, ART-3"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "\"%s\" is out of stock and cannot be selected."
|
||||||
|
msgstr "\"%s\" ist nicht an Lager und kann nicht ausgewählt werden."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Only %2$d of \"%1$s\" are available in stock."
|
||||||
|
msgstr "Nur %2$d von \"%1$s\" sind an Lager verfügbar."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock reduced for \"%1$s\": -%2$d (remaining: %3$d)"
|
||||||
|
msgstr "Lagerbestand reduziert für \"%1$s\": -%2$d (verbleibend: %3$d)"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock restored for \"%1$s\": +%2$d (total: %3$d)"
|
||||||
|
msgstr "Lagerbestand wiederhergestellt für \"%1$s\": +%2$d (gesamt: %3$d)"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Out of stock"
|
||||||
|
msgstr "Nicht an Lager"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Only"
|
||||||
|
msgstr "Nur"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "left"
|
||||||
|
msgstr "übrig"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "In stock"
|
||||||
|
msgstr "An Lager"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "No products available for selection. Please configure the product criteria in the admin panel."
|
||||||
|
msgstr "Keine Produkte zur Auswahl verfügbar. Bitte konfiguriere die Produktkriterien im Admin-Bereich."
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php, includes/Admin/Product_Data.php
|
||||||
|
msgid "Include Non-Public Products"
|
||||||
|
msgstr "Nicht-öffentliche Produkte einbeziehen"
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php
|
||||||
|
msgid "Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually."
|
||||||
|
msgstr "Entwürfe und private Produkte in der Auswahl zusammenstellbarer Produkte anzeigen. Nützlich, wenn Produkte nur als Teil einer Zusammenstellung verkauft werden sollen, nicht einzeln."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Allow draft and private products in the selection. Useful when products should only be sold as part of a composition."
|
||||||
|
msgstr "Entwürfe und private Produkte in der Auswahl zulassen. Nützlich, wenn Produkte nur als Teil einer Zusammenstellung verkauft werden sollen."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Yes"
|
||||||
|
msgstr "Ja"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "No"
|
||||||
|
msgstr "Nein"
|
||||||
|
|||||||
68
languages/wc-composable-product-de_DE.po
Normal file → Executable file
68
languages/wc-composable-product-de_DE.po
Normal file → Executable file
@@ -144,8 +144,16 @@ msgid "Pricing Mode"
|
|||||||
msgstr "Preismodus"
|
msgstr "Preismodus"
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "How to calculate the price. Leave empty to use global default."
|
msgid "How to calculate the price."
|
||||||
msgstr "Wie der Preis berechnet wird. Leer lassen, um den globalen Standard zu verwenden."
|
msgstr "Wie der Preis berechnet wird."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Fixed Price"
|
||||||
|
msgstr "Festpreis"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Enter the fixed price for this composable product."
|
||||||
|
msgstr "Geben Sie den Festpreis für dieses zusammenstellbare Produkt ein."
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "Use global default"
|
msgid "Use global default"
|
||||||
@@ -198,3 +206,59 @@ msgstr "Geben Sie Produkt-Artikelnummern durch Kommas getrennt ein."
|
|||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "SKU-1, SKU-2, SKU-3"
|
msgid "SKU-1, SKU-2, SKU-3"
|
||||||
msgstr "ART-1, ART-2, ART-3"
|
msgstr "ART-1, ART-2, ART-3"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "\"%s\" is out of stock and cannot be selected."
|
||||||
|
msgstr "\"%s\" ist nicht auf Lager und kann nicht ausgewählt werden."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Only %2$d of \"%1$s\" are available in stock."
|
||||||
|
msgstr "Nur %2$d von \"%1$s\" sind auf Lager verfügbar."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock reduced for \"%1$s\": -%2$d (remaining: %3$d)"
|
||||||
|
msgstr "Lagerbestand reduziert für \"%1$s\": -%2$d (verbleibend: %3$d)"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock restored for \"%1$s\": +%2$d (total: %3$d)"
|
||||||
|
msgstr "Lagerbestand wiederhergestellt für \"%1$s\": +%2$d (gesamt: %3$d)"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Out of stock"
|
||||||
|
msgstr "Nicht auf Lager"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Only"
|
||||||
|
msgstr "Nur"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "left"
|
||||||
|
msgstr "übrig"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "In stock"
|
||||||
|
msgstr "Auf Lager"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "No products available for selection. Please configure the product criteria in the admin panel."
|
||||||
|
msgstr "Keine Produkte zur Auswahl verfügbar. Bitte konfigurieren Sie die Produktkriterien im Admin-Bereich."
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php, includes/Admin/Product_Data.php
|
||||||
|
msgid "Include Non-Public Products"
|
||||||
|
msgstr "Nicht-öffentliche Produkte einbeziehen"
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php
|
||||||
|
msgid "Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually."
|
||||||
|
msgstr "Entwürfe und private Produkte in der Auswahl zusammenstellbarer Produkte anzeigen. Nützlich, wenn Produkte nur als Teil einer Zusammenstellung verkauft werden sollen, nicht einzeln."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Allow draft and private products in the selection. Useful when products should only be sold as part of a composition."
|
||||||
|
msgstr "Entwürfe und private Produkte in der Auswahl zulassen. Nützlich, wenn Produkte nur als Teil einer Zusammenstellung verkauft werden sollen."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Yes"
|
||||||
|
msgstr "Ja"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "No"
|
||||||
|
msgstr "Nein"
|
||||||
|
|||||||
68
languages/wc-composable-product-de_DE_informal.po
Normal file → Executable file
68
languages/wc-composable-product-de_DE_informal.po
Normal file → Executable file
@@ -144,8 +144,16 @@ msgid "Pricing Mode"
|
|||||||
msgstr "Preismodus"
|
msgstr "Preismodus"
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "How to calculate the price. Leave empty to use global default."
|
msgid "How to calculate the price."
|
||||||
msgstr "Wie der Preis berechnet wird. Leer lassen, um den globalen Standard zu verwenden."
|
msgstr "Wie der Preis berechnet wird."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Fixed Price"
|
||||||
|
msgstr "Festpreis"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Enter the fixed price for this composable product."
|
||||||
|
msgstr "Gib den Festpreis für dieses zusammenstellbare Produkt ein."
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "Use global default"
|
msgid "Use global default"
|
||||||
@@ -198,3 +206,59 @@ msgstr "Gib Produkt-Artikelnummern durch Kommas getrennt ein."
|
|||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "SKU-1, SKU-2, SKU-3"
|
msgid "SKU-1, SKU-2, SKU-3"
|
||||||
msgstr "ART-1, ART-2, ART-3"
|
msgstr "ART-1, ART-2, ART-3"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "\"%s\" is out of stock and cannot be selected."
|
||||||
|
msgstr "\"%s\" ist nicht auf Lager und kann nicht ausgewählt werden."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Only %2$d of \"%1$s\" are available in stock."
|
||||||
|
msgstr "Nur %2$d von \"%1$s\" sind auf Lager verfügbar."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock reduced for \"%1$s\": -%2$d (remaining: %3$d)"
|
||||||
|
msgstr "Lagerbestand reduziert für \"%1$s\": -%2$d (verbleibend: %3$d)"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock restored for \"%1$s\": +%2$d (total: %3$d)"
|
||||||
|
msgstr "Lagerbestand wiederhergestellt für \"%1$s\": +%2$d (gesamt: %3$d)"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Out of stock"
|
||||||
|
msgstr "Nicht auf Lager"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Only"
|
||||||
|
msgstr "Nur"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "left"
|
||||||
|
msgstr "übrig"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "In stock"
|
||||||
|
msgstr "Auf Lager"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "No products available for selection. Please configure the product criteria in the admin panel."
|
||||||
|
msgstr "Keine Produkte zur Auswahl verfügbar. Bitte konfiguriere die Produktkriterien im Admin-Bereich."
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php, includes/Admin/Product_Data.php
|
||||||
|
msgid "Include Non-Public Products"
|
||||||
|
msgstr "Nicht-öffentliche Produkte einbeziehen"
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php
|
||||||
|
msgid "Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually."
|
||||||
|
msgstr "Entwürfe und private Produkte in der Auswahl zusammenstellbarer Produkte anzeigen. Nützlich, wenn Produkte nur als Teil einer Zusammenstellung verkauft werden sollen, nicht einzeln."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Allow draft and private products in the selection. Useful when products should only be sold as part of a composition."
|
||||||
|
msgstr "Entwürfe und private Produkte in der Auswahl zulassen. Nützlich, wenn Produkte nur als Teil einer Zusammenstellung verkauft werden sollen."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Yes"
|
||||||
|
msgstr "Ja"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "No"
|
||||||
|
msgstr "Nein"
|
||||||
|
|||||||
68
languages/wc-composable-product-fr_CH.po
Normal file → Executable file
68
languages/wc-composable-product-fr_CH.po
Normal file → Executable file
@@ -144,8 +144,16 @@ msgid "Pricing Mode"
|
|||||||
msgstr "Mode de tarification"
|
msgstr "Mode de tarification"
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "How to calculate the price. Leave empty to use global default."
|
msgid "How to calculate the price."
|
||||||
msgstr "Comment calculer le prix. Laisser vide pour utiliser la valeur par défaut globale."
|
msgstr "Comment calculer le prix."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Fixed Price"
|
||||||
|
msgstr "Prix fixe"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Enter the fixed price for this composable product."
|
||||||
|
msgstr "Entrez le prix fixe pour ce produit composable."
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "Use global default"
|
msgid "Use global default"
|
||||||
@@ -198,3 +206,59 @@ msgstr "Entrez les références des produits séparées par des virgules."
|
|||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "SKU-1, SKU-2, SKU-3"
|
msgid "SKU-1, SKU-2, SKU-3"
|
||||||
msgstr "REF-1, REF-2, REF-3"
|
msgstr "REF-1, REF-2, REF-3"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "\"%s\" is out of stock and cannot be selected."
|
||||||
|
msgstr "\"%s\" est en rupture de stock et ne peut pas être sélectionné."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Only %2$d of \"%1$s\" are available in stock."
|
||||||
|
msgstr "Seulement %2$d de \"%1$s\" sont disponibles en stock."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock reduced for \"%1$s\": -%2$d (remaining: %3$d)"
|
||||||
|
msgstr "Stock réduit pour \"%1$s\": -%2$d (restant: %3$d)"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock restored for \"%1$s\": +%2$d (total: %3$d)"
|
||||||
|
msgstr "Stock restauré pour \"%1$s\": +%2$d (total: %3$d)"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Out of stock"
|
||||||
|
msgstr "Rupture de stock"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Only"
|
||||||
|
msgstr "Seulement"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "left"
|
||||||
|
msgstr "restant"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "In stock"
|
||||||
|
msgstr "En stock"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "No products available for selection. Please configure the product criteria in the admin panel."
|
||||||
|
msgstr "Aucun produit disponible pour la sélection. Veuillez configurer les critères de produit dans le panneau d'administration."
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php, includes/Admin/Product_Data.php
|
||||||
|
msgid "Include Non-Public Products"
|
||||||
|
msgstr "Inclure les produits non publics"
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php
|
||||||
|
msgid "Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually."
|
||||||
|
msgstr "Autoriser les brouillons et les produits privés dans les sélections de produits composables. Utile lorsque les produits ne doivent être vendus que dans le cadre d'une composition, pas individuellement."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Allow draft and private products in the selection. Useful when products should only be sold as part of a composition."
|
||||||
|
msgstr "Autoriser les brouillons et les produits privés dans la sélection. Utile lorsque les produits ne doivent être vendus que dans le cadre d'une composition."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Yes"
|
||||||
|
msgstr "Oui"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "No"
|
||||||
|
msgstr "Non"
|
||||||
|
|||||||
68
languages/wc-composable-product-it_CH.po
Normal file → Executable file
68
languages/wc-composable-product-it_CH.po
Normal file → Executable file
@@ -144,8 +144,16 @@ msgid "Pricing Mode"
|
|||||||
msgstr "Modalità di prezzo"
|
msgstr "Modalità di prezzo"
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "How to calculate the price. Leave empty to use global default."
|
msgid "How to calculate the price."
|
||||||
msgstr "Come calcolare il prezzo. Lasciare vuoto per utilizzare il valore predefinito globale."
|
msgstr "Come calcolare il prezzo."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Fixed Price"
|
||||||
|
msgstr "Prezzo fisso"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Enter the fixed price for this composable product."
|
||||||
|
msgstr "Inserisci il prezzo fisso per questo prodotto componibile."
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "Use global default"
|
msgid "Use global default"
|
||||||
@@ -198,3 +206,59 @@ msgstr "Inserire i codici articolo dei prodotti separati da virgole."
|
|||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "SKU-1, SKU-2, SKU-3"
|
msgid "SKU-1, SKU-2, SKU-3"
|
||||||
msgstr "COD-1, COD-2, COD-3"
|
msgstr "COD-1, COD-2, COD-3"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "\"%s\" is out of stock and cannot be selected."
|
||||||
|
msgstr "\"%s\" è esaurito e non può essere selezionato."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Only %2$d of \"%1$s\" are available in stock."
|
||||||
|
msgstr "Solo %2$d di \"%1$s\" sono disponibili in magazzino."
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock reduced for \"%1$s\": -%2$d (remaining: %3$d)"
|
||||||
|
msgstr "Giacenza ridotta per \"%1$s\": -%2$d (rimanenti: %3$d)"
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock restored for \"%1$s\": +%2$d (total: %3$d)"
|
||||||
|
msgstr "Giacenza ripristinata per \"%1$s\": +%2$d (totale: %3$d)"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Out of stock"
|
||||||
|
msgstr "Esaurito"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Only"
|
||||||
|
msgstr "Solo"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "left"
|
||||||
|
msgstr "rimasti"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "In stock"
|
||||||
|
msgstr "Disponibile"
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "No products available for selection. Please configure the product criteria in the admin panel."
|
||||||
|
msgstr "Nessun prodotto disponibile per la selezione. Si prega di configurare i criteri del prodotto nel pannello di amministrazione."
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php, includes/Admin/Product_Data.php
|
||||||
|
msgid "Include Non-Public Products"
|
||||||
|
msgstr "Includi prodotti non pubblici"
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php
|
||||||
|
msgid "Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually."
|
||||||
|
msgstr "Consenti la visualizzazione di bozze e prodotti privati nelle selezioni dei prodotti componibili. Utile quando i prodotti devono essere venduti solo come parte di una composizione, non singolarmente."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Allow draft and private products in the selection. Useful when products should only be sold as part of a composition."
|
||||||
|
msgstr "Consenti bozze e prodotti privati nella selezione. Utile quando i prodotti devono essere venduti solo come parte di una composizione."
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Yes"
|
||||||
|
msgstr "Sì"
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "No"
|
||||||
|
msgstr "No"
|
||||||
|
|||||||
68
languages/wc-composable-product.pot
Normal file → Executable file
68
languages/wc-composable-product.pot
Normal file → Executable file
@@ -2,7 +2,7 @@
|
|||||||
# This file is distributed under the GPL v3 or later.
|
# This file is distributed under the GPL v3 or later.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: WooCommerce Composable Products 1.0.0\n"
|
"Project-Id-Version: WooCommerce Composable Products 1.1.6\n"
|
||||||
"Report-Msgid-Bugs-To: https://github.com/magdev/wc-composable-product/issues\n"
|
"Report-Msgid-Bugs-To: https://github.com/magdev/wc-composable-product/issues\n"
|
||||||
"POT-Creation-Date: 2024-12-31 00:00+0000\n"
|
"POT-Creation-Date: 2024-12-31 00:00+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
@@ -143,7 +143,15 @@ msgid "Pricing Mode"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "How to calculate the price. Leave empty to use global default."
|
msgid "How to calculate the price."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Fixed Price"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Enter the fixed price for this composable product."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
@@ -197,3 +205,59 @@ msgstr ""
|
|||||||
#: includes/Admin/Product_Data.php
|
#: includes/Admin/Product_Data.php
|
||||||
msgid "SKU-1, SKU-2, SKU-3"
|
msgid "SKU-1, SKU-2, SKU-3"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "\"%s\" is out of stock and cannot be selected."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Only %2$d of \"%1$s\" are available in stock."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock reduced for \"%1$s\": -%2$d (remaining: %3$d)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Stock_Manager.php
|
||||||
|
msgid "Stock restored for \"%1$s\": +%2$d (total: %3$d)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Out of stock"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "Only"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "left"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "In stock"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: templates/product-selector.twig
|
||||||
|
msgid "No products available for selection. Please configure the product criteria in the admin panel."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php, includes/Admin/Product_Data.php
|
||||||
|
msgid "Include Non-Public Products"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Admin/Settings.php
|
||||||
|
msgid "Allow draft and private products to appear in composable product selections. Useful when products should only be sold as part of a composition, not individually."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Allow draft and private products in the selection. Useful when products should only be sold as part of a composition."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "Yes"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/Admin/Product_Data.php
|
||||||
|
msgid "No"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
27
templates/product-selector.twig
Normal file → Executable file
27
templates/product-selector.twig
Normal file → Executable file
@@ -9,8 +9,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="composable-products-grid">
|
<div class="composable-products-grid">
|
||||||
|
{% if products is empty %}
|
||||||
|
<div class="composable-no-products">
|
||||||
|
<p>{{ __('No products available for selection. Please configure the product criteria in the admin panel.') }}</p>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
{% for product in products %}
|
{% for product in products %}
|
||||||
<div class="composable-product-item" data-product-id="{{ product.id }}" data-price="{{ product.price }}">
|
<div class="composable-product-item{% if not product.in_stock %} out-of-stock{% endif %}" data-product-id="{{ product.id }}" data-price="{{ product.price }}" data-stock-status="{{ product.stock_status }}">
|
||||||
<div class="product-item-inner">
|
<div class="product-item-inner">
|
||||||
<label class="product-item-label">
|
<label class="product-item-label">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
@@ -18,7 +23,8 @@
|
|||||||
value="{{ product.id }}"
|
value="{{ product.id }}"
|
||||||
class="composable-product-checkbox"
|
class="composable-product-checkbox"
|
||||||
data-product-id="{{ product.id }}"
|
data-product-id="{{ product.id }}"
|
||||||
data-price="{{ product.price }}">
|
data-price="{{ product.price }}"
|
||||||
|
{% if not product.in_stock %}disabled{% endif %}>
|
||||||
|
|
||||||
{% if show_images and product.image_url %}
|
{% if show_images and product.image_url %}
|
||||||
<div class="product-item-image">
|
<div class="product-item-image">
|
||||||
@@ -34,6 +40,16 @@
|
|||||||
{{ product.price_html|raw }}
|
{{ product.price_html|raw }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="product-item-stock">
|
||||||
|
{% if not product.in_stock %}
|
||||||
|
<span class="stock-status out-of-stock">{{ __('Out of stock') }}</span>
|
||||||
|
{% elseif product.managing_stock and product.stock_quantity is not null and product.stock_quantity <= 5 %}
|
||||||
|
<span class="stock-status low-stock">{{ __('Only') }} {{ product.stock_quantity }} {{ __('left') }}</span>
|
||||||
|
{% elseif product.in_stock %}
|
||||||
|
<span class="stock-status in-stock">{{ __('In stock') }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="product-item-checkmark"></span>
|
<span class="product-item-checkmark"></span>
|
||||||
@@ -41,16 +57,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if show_total %}
|
{% if show_total %}
|
||||||
<div class="composable-total">
|
<div class="composable-total">
|
||||||
<div class="total-label">{{ __('Total Price:') }}</div>
|
<div class="total-label">{{ __('Total Price:') }}</div>
|
||||||
<div class="total-price" data-currency="{{ currency_symbol }}">
|
<div class="total-price" data-currency="{{ currency_symbol }}" data-fixed-price="{{ fixed_price }}">
|
||||||
{% if pricing_mode == 'fixed' %}
|
{% if pricing_mode == 'fixed' %}
|
||||||
{{ currency_symbol }}{{ fixed_price }}
|
{{ fixed_price_html|raw }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="calculated-total">{{ currency_symbol }}0.00</span>
|
<span class="calculated-total">{{ zero_price_html|raw }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin Name: WooCommerce Composable Products
|
* Plugin Name: WooCommerce Composable Products
|
||||||
* Plugin URI: https://github.com/magdev/wc-composable-product
|
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wc-composable-product
|
||||||
* Description: Create composable products where customers select a limited number of items from a configurable set
|
* Description: Create composable products where customers select a limited number of items from a configurable set
|
||||||
* Version: 1.0.0
|
* Version: 1.3.0
|
||||||
* Author: Marco Graetsch
|
* Author: Marco Graetsch
|
||||||
* Author URI: https://example.com
|
* Author URI: https://src.bundespruefstelle.ch/magdev
|
||||||
* License: GPL v3 or later
|
* License: GPL v3 or later
|
||||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
* Text Domain: wc-composable-product
|
* Text Domain: wc-composable-product
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
defined('ABSPATH') || exit;
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
// Define plugin constants
|
// Define plugin constants
|
||||||
define('WC_COMPOSABLE_PRODUCT_VERSION', '1.0.0');
|
define('WC_COMPOSABLE_PRODUCT_VERSION', '1.3.0');
|
||||||
define('WC_COMPOSABLE_PRODUCT_FILE', __FILE__);
|
define('WC_COMPOSABLE_PRODUCT_FILE', __FILE__);
|
||||||
define('WC_COMPOSABLE_PRODUCT_PATH', plugin_dir_path(__FILE__));
|
define('WC_COMPOSABLE_PRODUCT_PATH', plugin_dir_path(__FILE__));
|
||||||
define('WC_COMPOSABLE_PRODUCT_URL', plugin_dir_url(__FILE__));
|
define('WC_COMPOSABLE_PRODUCT_URL', plugin_dir_url(__FILE__));
|
||||||
@@ -61,7 +62,17 @@ function wc_composable_product_init() {
|
|||||||
// Initialize main plugin class
|
// Initialize main plugin class
|
||||||
WC_Composable_Product\Plugin::instance();
|
WC_Composable_Product\Plugin::instance();
|
||||||
}
|
}
|
||||||
add_action('plugins_loaded', 'wc_composable_product_init');
|
// Use woocommerce_init to ensure all WooCommerce classes including settings are loaded
|
||||||
|
add_action('woocommerce_init', 'wc_composable_product_init');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare HPOS compatibility
|
||||||
|
*/
|
||||||
|
add_action('before_woocommerce_init', function() {
|
||||||
|
if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
|
||||||
|
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activation hook
|
* Activation hook
|
||||||
|
|||||||
Reference in New Issue
Block a user