Release version 1.1.20 - Fix WooCommerce Blocks fatal error

## Fixed
- Fatal error in WooCommerce Blocks: "Cannot use object of type WC_Product_Simple as array"
- Error occurred in class-wc-tpp-cart.php:233 in block_quantity_editable() method

## Technical Details
- Filter woocommerce_store_api_product_quantity_editable passes WC_Product object as second parameter, not cart item array
- Updated method signature from block_quantity_editable($editable, $cart_item) to block_quantity_editable($editable, $product)
- Changed parameter access from $cart_item['id'] to $product->get_id()
- Added proper product object validation with is_a($product, 'WC_Product')

## Added
- CLAUDE.md - Comprehensive AI context document for future development
- Complete project architecture documentation
- Historical bug context and solutions
- Development guidelines and testing checklists

## Release
- Version bumped to 1.1.20
- Release package created with MD5 and SHA256 checksums

🤖 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-23 00:17:01 +01:00
parent dfe1a4364a
commit d721ab123a
6 changed files with 441 additions and 5 deletions

View File

@@ -226,11 +226,16 @@ if (!class_exists('WC_TPP_Cart')) {
* Make quantity non-editable for restricted products in WooCommerce blocks
*
* @param bool $editable Whether the quantity is editable
* @param array $cart_item Cart item data
* @param WC_Product $product Product object
* @return bool
*/
public function block_quantity_editable($editable, $cart_item) {
$product_id = $cart_item['id'] ?? ($cart_item['product_id'] ?? 0);
public function block_quantity_editable($editable, $product) {
// Validate product object
if (!$product || !is_a($product, 'WC_Product')) {
return $editable;
}
$product_id = $product->get_id();
if (!$product_id) {
return $editable;