Implement comprehensive stock management integration (v1.1.0)

Added complete inventory tracking system for composable products:
- Stock validation during product selection and add-to-cart
- Automatic stock deduction on order completion/processing
- Automatic stock restoration on order cancellation/refund
- Stock status indicators with visual feedback (In stock, Low stock, Out of stock)
- Prevention of out-of-stock item selection
- Low stock warnings when 5 or fewer items remain
- Order notes documenting all stock changes

New files:
- includes/Stock_Manager.php: Core stock management logic

Modified files:
- includes/Cart_Handler.php: Integrated stock validation
- includes/Product_Selector.php: Added stock info to product data
- includes/Plugin.php: Added Stock_Manager to includes
- templates/product-selector.twig: Stock status display
- assets/css/frontend.css: Stock indicator styling
- languages/*.pot/*.po: 8 new translatable strings

Version bumped to 1.1.0 with updated CHANGELOG.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-31 16:41:53 +01:00
parent a581ef42e6
commit e9df6e4278
11 changed files with 489 additions and 5 deletions

View File

@@ -10,7 +10,7 @@
<div class="composable-products-grid">
{% 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">
<label class="product-item-label">
<input type="checkbox"
@@ -18,7 +18,8 @@
value="{{ product.id }}"
class="composable-product-checkbox"
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 %}
<div class="product-item-image">
@@ -34,6 +35,16 @@
{{ product.price_html|raw }}
</div>
{% 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>
<span class="product-item-checkmark"></span>