You've already forked wc-licensed-product
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9826c8181e | |||
| fa972ceaf0 |
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.5.9] - 2026-01-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed frontend error on licensed variable products when no attributes are defined
|
||||
- Added null checks for `get_variation_attributes()`, `get_available_variations()`, and `get_default_attributes()`
|
||||
- Show informative message instead of error when product has no variations configured
|
||||
- Changed product type check from `instanceof` to `is_type()` for better compatibility
|
||||
|
||||
## [0.5.8] - 2026-01-27
|
||||
|
||||
### Fixed
|
||||
|
||||
BIN
releases/wc-licensed-product-0.5.8.zip
Normal file
BIN
releases/wc-licensed-product-0.5.8.zip
Normal file
Binary file not shown.
1
releases/wc-licensed-product-0.5.8.zip.sha256
Normal file
1
releases/wc-licensed-product-0.5.8.zip.sha256
Normal file
@@ -0,0 +1 @@
|
||||
670c2f5182ea7140ccf9533c2b4179daf7890019a244973f467f2a5c7622b9f4 wc-licensed-product-0.5.8.zip
|
||||
@@ -338,19 +338,45 @@ final class LicensedProductType
|
||||
{
|
||||
global $product;
|
||||
|
||||
if (!$product instanceof \WC_Product_Variable) {
|
||||
// Check if product is a variable type (includes LicensedVariableProduct which extends WC_Product_Variable)
|
||||
if (!$product || !$product->is_type('licensed-variable')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get attributes - ensure we have an array even if no attributes are set
|
||||
$attributes = $product->get_variation_attributes();
|
||||
if (!is_array($attributes)) {
|
||||
$attributes = [];
|
||||
}
|
||||
|
||||
// If no attributes defined, show a message instead of broken form
|
||||
if (empty($attributes)) {
|
||||
echo '<p class="woocommerce-info">' . esc_html__('This product has no variations available.', 'wc-licensed-product') . '</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Get variations count to determine if we should load them via AJAX
|
||||
$getVariations = count($product->get_children()) <= apply_filters('woocommerce_ajax_variation_threshold', 30, $product);
|
||||
$children = $product->get_children();
|
||||
$getVariations = count($children) <= apply_filters('woocommerce_ajax_variation_threshold', 30, $product);
|
||||
|
||||
// Get available variations - ensure we have an array
|
||||
$availableVariations = $getVariations ? $product->get_available_variations() : false;
|
||||
if ($getVariations && !is_array($availableVariations)) {
|
||||
$availableVariations = [];
|
||||
}
|
||||
|
||||
// Get default/selected attributes - ensure we have an array
|
||||
$selectedAttributes = $product->get_default_attributes();
|
||||
if (!is_array($selectedAttributes)) {
|
||||
$selectedAttributes = [];
|
||||
}
|
||||
|
||||
wc_get_template(
|
||||
'single-product/add-to-cart/variable.php',
|
||||
[
|
||||
'available_variations' => $getVariations ? $product->get_available_variations() : false,
|
||||
'attributes' => $product->get_variation_attributes(),
|
||||
'selected_attributes' => $product->get_default_attributes(),
|
||||
'available_variations' => $availableVariations,
|
||||
'attributes' => $attributes,
|
||||
'selected_attributes' => $selectedAttributes,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: WooCommerce Licensed Product
|
||||
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wc-licensed-product
|
||||
* Description: WooCommerce plugin to sell software products using license keys with domain-based validation.
|
||||
* Version: 0.5.8
|
||||
* Version: 0.5.9
|
||||
* Author: Marco Graetsch
|
||||
* Author URI: https://src.bundespruefstelle.ch/magdev
|
||||
* License: GPL-2.0-or-later
|
||||
@@ -28,7 +28,7 @@ if (!defined('ABSPATH')) {
|
||||
}
|
||||
|
||||
// Plugin constants
|
||||
define('WC_LICENSED_PRODUCT_VERSION', '0.5.8');
|
||||
define('WC_LICENSED_PRODUCT_VERSION', '0.5.9');
|
||||
define('WC_LICENSED_PRODUCT_PLUGIN_FILE', __FILE__);
|
||||
define('WC_LICENSED_PRODUCT_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||
define('WC_LICENSED_PRODUCT_PLUGIN_URL', plugin_dir_url(__FILE__));
|
||||
|
||||
Reference in New Issue
Block a user