form-coupon.php 1.85 KB
Newer Older
cyrille's avatar
cyrille committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
<?php
/**
 * Coupon area of the checkout form
 *
 * @package LifterLMS/Templates
 *
 * @since Unknown
 * @version 3.35.2
 */

defined( 'ABSPATH' ) || exit;

// don't display if the plan is marked as free.
if ( isset( $plan ) && $plan->is_free() ) {
	return;
}
?>
<div class="llms-coupon-wrapper">

	<?php if ( empty( $coupon ) ) : ?>

		<?php _e( 'Have a coupon?', 'lifterlms' ); ?>
		<a href="#llms-coupon-toggle"><?php _e( 'Click here to enter your code', 'lifterlms' ); ?></a>

		<div class="llms-coupon-entry llms-form-fields flush">

			<div class="llms-coupon-messages"></div>

			<?php
			llms_form_field(
				array(

					'columns'     => 12,
					'id'          => 'llms_coupon_code',
					'placeholder' => __( 'Coupon Code', 'lifterlms' ),
					'last_column' => true,
					'required'    => false,
					'type'        => 'text',

				)
			);
			?>
			<?php
			llms_form_field(
				array(

					'columns'     => 12,
					'classes'     => 'llms-button-secondary',
					'id'          => 'llms-apply-coupon',
					'value'       => __( 'Apply Coupon', 'lifterlms' ),
					'last_column' => true,
					'required'    => false,
					'type'        => 'button',

				)
			);
			?>
		</div>

	<?php else : ?>

		<?php
		// Translators: %s = coupon code.
		llms_print_notice( sprintf( __( 'Coupon code "%s" has been applied to your order.', 'lifterlms' ), $coupon->get( 'title' ) ), 'success' );
		?>

		<div class="llms-form-fields flush">
			<?php
			llms_form_field(
				array(

					'columns'     => 12,
					'classes'     => 'llms-button-secondary',
					'id'          => 'llms-remove-coupon',
					'value'       => __( 'Remove Coupon', 'lifterlms' ),
					'last_column' => true,
					'required'    => false,
					'type'        => 'button',

				)
			);
			?>

		</div>

		<input name="llms_coupon_code" type="hidden" value="<?php echo $coupon->get( 'title' ); ?>">

	<?php endif; ?>

</div>