feat: Add Copy Cart/Checkout links and licensing settings to product editor

Copy Cart/Checkout Links:
- Added to GeneralTab for simple products (same pattern as variations)
- Link generation with add-to-cart and redirect params

Licensing Settings:
- 'Enable licensing for this product' checkbox in Additional Options
- License settings panel: activation limit, duration (days)
- State management in ProductFormTabbed
- Backend: ProductsController saves/loads licensing meta fields

Backend:
- _licensing_enabled, _license_activation_limit, _license_duration_days post meta
This commit is contained in:
Dwindi Ramadhana
2026-01-05 17:10:04 +07:00
parent 26ab626966
commit 60d749cd65
3 changed files with 192 additions and 8 deletions

View File

@@ -413,6 +413,17 @@ class ProductsController {
$product->save();
// Licensing meta
if (isset($data['licensing_enabled'])) {
update_post_meta($product->get_id(), '_licensing_enabled', $data['licensing_enabled'] ? 'yes' : 'no');
}
if (isset($data['license_activation_limit'])) {
update_post_meta($product->get_id(), '_license_activation_limit', self::sanitize_number($data['license_activation_limit']));
}
if (isset($data['license_duration_days'])) {
update_post_meta($product->get_id(), '_license_duration_days', self::sanitize_number($data['license_duration_days']));
}
// Handle variations for variable products
if ($type === 'variable' && !empty($data['attributes']) && is_array($data['attributes'])) {
self::save_product_attributes($product, $data['attributes']);
@@ -546,6 +557,17 @@ class ProductsController {
$product->save();
// Licensing meta
if (isset($data['licensing_enabled'])) {
update_post_meta($product->get_id(), '_licensing_enabled', $data['licensing_enabled'] ? 'yes' : 'no');
}
if (isset($data['license_activation_limit'])) {
update_post_meta($product->get_id(), '_license_activation_limit', self::sanitize_number($data['license_activation_limit']));
}
if (isset($data['license_duration_days'])) {
update_post_meta($product->get_id(), '_license_duration_days', self::sanitize_number($data['license_duration_days']));
}
// Allow plugins to perform additional updates (Level 1 compatibility)
do_action('woonoow/product_updated', $product, $data, $request);
@@ -738,6 +760,11 @@ class ProductsController {
$data['download_expiry'] = $product->get_download_expiry() !== -1 ? (string) $product->get_download_expiry() : '';
}
// Licensing fields
$data['licensing_enabled'] = get_post_meta($product->get_id(), '_licensing_enabled', true) === 'yes';
$data['license_activation_limit'] = get_post_meta($product->get_id(), '_license_activation_limit', true) ?: '';
$data['license_duration_days'] = get_post_meta($product->get_id(), '_license_duration_days', true) ?: '';
// Images array (URLs) for frontend - featured + gallery
$images = [];
$featured_image_id = $product->get_image_id();