Skip to content

Instantly share code, notes, and snippets.

@thomasplevy
Last active August 11, 2018 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasplevy/c7b65cf2dde1931b87a4fe094061ebb6 to your computer and use it in GitHub Desktop.
Save thomasplevy/c7b65cf2dde1931b87a4fe094061ebb6 to your computer and use it in GitHub Desktop.
change free text access plan text
<?php // don't include this line in your functions.php file!
/*
* Change the text displayed for free ($0.00) access plans
* @param string $text the default text ("Free")
* @return string
*/
function my_free_pricing_text( $text ) {
return __( 'INCLUDED', 'my-text-domain' ); // change text to whatever you want here
}
add_filter( 'llms_get_free_access_plan_pricing_text', 'my_free_pricing_text' );
@AndreaBarghigiani
Copy link

AndreaBarghigiani commented Aug 11, 2018

Hi Thomas,
I have to appreciate your creation of this filter but I would like bring it a bit further.

Let me explain. I am building a new website and I need to use the membership feature to sell some courses in bulk but instead of write the same word for every free price I would like to get the price of the access plan for the membership.

Now I've started to dig into your code and I came up with this code that I am usign inside my template file lifterlms/product/pricing-table.php inside the foreach that you use to loop all the access plan:

// Check if the current plan has restrictions
if( $plan->get_array( 'availability_restrictions' ) != 0 ){
	
	// Get membership ID
	$membership_id = $plan->get_array( 'availability_restrictions' );

	// Get instance of the product with the membership ID
	$membership = new LLMS_Product( $membership_id );

	// Get all the access plan for the membership
	$membership_plans = $membership->get_access_plans();

	// Loop the access plans (even if the membership has only one)
	foreach( $membership_plans as $i > $m_plan ){

		// Stuck here because it gets me ALL the access plans in my installation
		var_dump( $m_plan->get_price( 'price' ) );
	}
	
}   

Hope that you can show me a way to work this out.

Sorry if I comment this snippet to get help but I didn't know if it was better to open an issue on the repo or contact you directly.
Let me know if you prefer a way of contact.

All the best,
Andrea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment