You've already forked wc-licensed-product
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c4232f14f | |||
| 0638767ce3 | |||
| 9826c8181e | |||
| fa972ceaf0 |
18
CHANGELOG.md
18
CHANGELOG.md
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.5.10] - 2026-01-27
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed licensed variable products not showing variations even when attributes are defined
|
||||||
|
- Re-load product via `wc_get_product()` to ensure correct class instance is used
|
||||||
|
- Removed overly strict type check that was preventing variations from displaying
|
||||||
|
- Now mirrors WooCommerce's standard `woocommerce_variable_add_to_cart()` implementation
|
||||||
|
|
||||||
|
## [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
|
## [0.5.8] - 2026-01-27
|
||||||
|
|
||||||
### Fixed
|
### 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
|
||||||
BIN
releases/wc-licensed-product-0.5.9.zip
Normal file
BIN
releases/wc-licensed-product-0.5.9.zip
Normal file
Binary file not shown.
1
releases/wc-licensed-product-0.5.9.zip.sha256
Normal file
1
releases/wc-licensed-product-0.5.9.zip.sha256
Normal file
@@ -0,0 +1 @@
|
|||||||
|
fae77dab56cb8f46693cf44fe6a1dc38ad0526d881cab2cd1f0878b234afaa8b wc-licensed-product-0.5.9.zip
|
||||||
@@ -333,24 +333,51 @@ final class LicensedProductType
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add to cart template for variable licensed products
|
* Add to cart template for variable licensed products
|
||||||
|
* This mirrors WooCommerce's woocommerce_variable_add_to_cart() function
|
||||||
*/
|
*/
|
||||||
public function variableAddToCartTemplate(): void
|
public function variableAddToCartTemplate(): void
|
||||||
{
|
{
|
||||||
global $product;
|
global $product;
|
||||||
|
|
||||||
if (!$product instanceof \WC_Product_Variable) {
|
// The hook woocommerce_licensed-variable_add_to_cart only fires for this product type
|
||||||
|
// so we just need to verify the product exists
|
||||||
|
if (!$product) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we're working with a product that has variable product methods
|
||||||
|
// Re-load the product to ensure we get the correct class instance
|
||||||
|
$productId = $product->get_id();
|
||||||
|
$variableProduct = wc_get_product($productId);
|
||||||
|
|
||||||
|
if (!$variableProduct || !method_exists($variableProduct, 'get_variation_attributes')) {
|
||||||
|
// Fallback to simple add to cart if not a variable product
|
||||||
|
wc_get_template('single-product/add-to-cart/simple.php');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get variations count to determine if we should load them via AJAX
|
// 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);
|
$getVariations = count($variableProduct->get_children()) <= apply_filters('woocommerce_ajax_variation_threshold', 30, $variableProduct);
|
||||||
|
|
||||||
|
// Get template variables - WooCommerce expects these to be set
|
||||||
|
$availableVariations = $getVariations ? $variableProduct->get_available_variations() : false;
|
||||||
|
$attributes = $variableProduct->get_variation_attributes();
|
||||||
|
$selectedAttributes = $variableProduct->get_default_attributes();
|
||||||
|
|
||||||
|
// Ensure arrays (WooCommerce template expects arrays, not null)
|
||||||
|
if (!is_array($attributes)) {
|
||||||
|
$attributes = [];
|
||||||
|
}
|
||||||
|
if (!is_array($selectedAttributes)) {
|
||||||
|
$selectedAttributes = [];
|
||||||
|
}
|
||||||
|
|
||||||
wc_get_template(
|
wc_get_template(
|
||||||
'single-product/add-to-cart/variable.php',
|
'single-product/add-to-cart/variable.php',
|
||||||
[
|
[
|
||||||
'available_variations' => $getVariations ? $product->get_available_variations() : false,
|
'available_variations' => $availableVariations,
|
||||||
'attributes' => $product->get_variation_attributes(),
|
'attributes' => $attributes,
|
||||||
'selected_attributes' => $product->get_default_attributes(),
|
'selected_attributes' => $selectedAttributes,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: WooCommerce Licensed Product
|
* Plugin Name: WooCommerce Licensed Product
|
||||||
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wc-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.
|
* Description: WooCommerce plugin to sell software products using license keys with domain-based validation.
|
||||||
* Version: 0.5.8
|
* Version: 0.5.10
|
||||||
* Author: Marco Graetsch
|
* Author: Marco Graetsch
|
||||||
* Author URI: https://src.bundespruefstelle.ch/magdev
|
* Author URI: https://src.bundespruefstelle.ch/magdev
|
||||||
* License: GPL-2.0-or-later
|
* License: GPL-2.0-or-later
|
||||||
@@ -28,7 +28,7 @@ if (!defined('ABSPATH')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Plugin constants
|
// Plugin constants
|
||||||
define('WC_LICENSED_PRODUCT_VERSION', '0.5.8');
|
define('WC_LICENSED_PRODUCT_VERSION', '0.5.10');
|
||||||
define('WC_LICENSED_PRODUCT_PLUGIN_FILE', __FILE__);
|
define('WC_LICENSED_PRODUCT_PLUGIN_FILE', __FILE__);
|
||||||
define('WC_LICENSED_PRODUCT_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
define('WC_LICENSED_PRODUCT_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||||
define('WC_LICENSED_PRODUCT_PLUGIN_URL', plugin_dir_url(__FILE__));
|
define('WC_LICENSED_PRODUCT_PLUGIN_URL', plugin_dir_url(__FILE__));
|
||||||
|
|||||||
Reference in New Issue
Block a user