ulgm_new_group_license_order_price_type
Filters the price type for new group license orders, allowing customization of how prices are determined.
add_filter( 'ulgm_new_group_license_order_price_type', $callback, 10, 1 );
Description
Filters the price type assigned to a new group license order. Developers can use this hook to dynamically change the price type from the default 'closed' to another value, influencing how the group license is handled in WooCommerce. This filter fires after a group license order is processed but before the price type is saved.
Usage
add_filter( 'ulgm_new_group_license_order_price_type', 'your_function_name', 10, 1 );
Parameters
-
$group_id(mixed) - This parameter is the default price type for the new group license order.
Return Value
The filtered value.
Examples
/**
* Change the group license order price type for specific groups.
*
* This example demonstrates how to modify the price type of a group license
* based on the group ID. If the group ID is, for instance, 123, it will set
* the price type to 'free'. Otherwise, it will use the default or previously
* filtered value.
*
* @param mixed $price_type The current price type. Defaults to 'closed'.
* @param int $group_id The ID of the group.
* @return string The modified price type.
*/
add_filter(
'ulgm_new_group_license_order_price_type',
function( $price_type, $group_id ) {
// Check if the group ID is a specific one we want to treat differently.
if ( intval( $group_id ) === 123 ) {
// For group ID 123, set the price type to 'free'.
return 'free';
}
// For all other group IDs, return the original or previously filtered price type.
return $price_type;
},
10, // Priority: The order in which the filter is applied.
2 // Accepted Args: The number of arguments the filter function accepts.
);
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/classes/woocommerce/woocommerce-license.php:1044
$transient_key = 'learndash_course_groups_' . $course_id;
delete_transient( $transient_key );
}
}
$price_type = apply_filters( 'ulgm_new_group_license_order_price_type', 'closed', $group_id );
update_post_meta( $group_id, '_ld_price_type', $price_type );
update_post_meta(
$group_id,
'_groups',
array(