<?php

if (!defined('ABSPATH')) {
    die('You are not allowed to call this page directly.');
}

/**
 * Checkout coupon field.
 *
 * Rendered by MeprCouponsCtrl on the mepr_checkout_coupon_field action for
 * every checkout form variant, so brand builds without coupons can exclude
 * this file together with the module.
 *
 * @var MeprProduct $product          The product being purchased.
 * @var string      $mepr_coupon_code The submitted or applicable coupon code.
 * @var string      $field_id         The id attribute for the coupon input.
 */
?>
<a class="have-coupon-link" data-prdid="<?php echo esc_attr($product->ID); ?>" href="">
    <?php echo esc_html(MeprCouponsHelper::show_coupon_field_link_content($mepr_coupon_code)); ?>
</a>
<div class="mp-form-row mepr_coupon mepr_coupon_<?php echo esc_attr($product->ID); ?> mepr-hidden">
  <div class="mp-form-label">
    <label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html_x('Coupon Code:', 'ui', 'memberpress'); ?></label>
    <span class="mepr-coupon-loader mepr-hidden">
      <img src="<?php echo esc_url(includes_url('js/thickbox/loadingAnimation.gif')); ?>" alt="<?php esc_attr_e('Loading...', 'memberpress'); ?>" title="<?php echo esc_attr_x('Loading icon', 'ui', 'memberpress'); ?>" width="100" height="10" />
    </span>
    <span class="cc-error"><?php echo esc_html_x('Invalid Coupon', 'ui', 'memberpress'); ?></span>
    <span class="cc-success"><?php echo esc_html_x('Coupon applied successfully', 'ui', 'memberpress'); ?></span>
  </div>
  <input type="text" id="<?php echo esc_attr($field_id); ?>" class="mepr-form-input mepr-coupon-code" name="mepr_coupon_code" value="<?php echo esc_attr(stripslashes($mepr_coupon_code)); ?>" data-prdid="<?php echo esc_attr($product->ID); ?>" />
</div>
