Home / Admin / WP Simple Pay: Custom Smart Tags for Fee Recovery and Subtotal Amounts
Duplicate Snippet

Embed Snippet on Your Site

WP Simple Pay: Custom Smart Tags for Fee Recovery and Subtotal Amounts

Provide custom Smart Tags for Fee Recovery and Subtotal Amounts for payment confirmation pages and emails.

Code Preview
php
<?php
/**
 * Plugin Name: WP Simple Pay - Custom Smart Tags
 */
add_filter(
	'simpay_payment_details_template_tags',
	function( $smart_tags ) {
		$smart_tags[] = 'fee-recovery-amount';
		$smart_tags[] = 'pre-fee-amount';
		return $smart_tags;
	}
);
add_filter(
	'simpay_payment_confirmation_template_tag_fee-recovery-amount',
	function( $value, $payment_confirmation_data ) {
		$object = current( $payment_confirmation_data['paymentintents'] );
		return simpay_format_currency(
			$object->metadata->simpay_fee_recovery_unit_amount,
			$object->currency
		);
	},
	10,
	2
);
add_filter(
	'simpay_payment_confirmation_template_tag_pre-fee-amount',
	function( $value, $payment_confirmation_data ) {
		$object = current( $payment_confirmation_data['paymentintents'] );
		return simpay_format_currency(
			$object->amount - $object->metadata->simpay_fee_recovery_unit_amount,
			$object->currency
		);
	},
	10,
	2
);

Comments

Add a Comment