Home / Admin / WP Simple Pay: Custom Subscription Price Option Labels
Duplicate Snippet

Embed Snippet on Your Site

WP Simple Pay: Custom Subscription Price Option Labels

Change the price option labels that are output in the price option selector. Changes the output of the form's plan label to "{name} {amount} {currency} every {interval_count} {interval}".

Code Preview
php
<?php
/**
 * @link https://library.wpcode.com/snippet/e5009459/
 */
add_filter(
	'simpay_plan_name_label',
	/**
	 * @param string $label Plan label.
	 * @param \Stripe\Plan $plan Stripe Plan.
	 * @return string
	 */
	function( $label, $plan ) {
		return sprintf(
			'%1$s %2$s %3$s every %4$s %5$s(s)',
			$plan->name,
			simpay_format_currency(
				simpay_convert_amount_to_dollars( $plan->amount ),
				$plan->currency
			),
			strtoupper( $plan->currency ),
			$plan->interval_count,
			$plan->interval
		);
	},
	10,
	2
);

Comments

Add a Comment