| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying the free gifts module widget contents |
| 4 |
* |
| 5 |
* @var $args array template args |
| 6 |
* |
| 7 |
* @since 1.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; // Exit if accessed directly |
| 12 |
} |
| 13 |
|
| 14 |
$settings = isset( $args['settings'] ) ? $args['settings'] : array(); |
| 15 |
?> |
| 16 |
|
| 17 |
<?php foreach ( $args['offers'] as $offer ): ?> |
| 18 |
<?php if ( $args['cart_total'] < $offer['amount'] ) : ?> |
| 19 |
<div class="merchant-free-gifts-widget-offer"> |
| 20 |
<div class="merchant-free-gifts-widget-offer-label"> |
| 21 |
<?php |
| 22 |
$amount = wc_price( $offer['amount'] - $args['cart_total'] ); |
| 23 |
echo isset( $settings['spending_text'] ) |
| 24 |
? wp_kses( str_replace( |
| 25 |
'{amount}', |
| 26 |
$amount, |
| 27 |
sanitize_text_field( Merchant_Translator::translate( $settings['spending_text'] ) ) |
| 28 |
), merchant_kses_allowed_tags( ['bdi'] ) ) |
| 29 |
: wp_kses( |
| 30 |
/* Translators: 1. Amount */ |
| 31 |
sprintf( __( 'Spend %s more to receive this free gift!', 'merchant' ), $amount ), |
| 32 |
merchant_kses_allowed_tags( ['bdi'] ) |
| 33 |
); ?> |
| 34 |
</div> |
| 35 |
<div class="merchant-free-gifts-widget-offer-product"> |
| 36 |
<?php echo wp_kses_post( $offer['product']['image'] ); ?> |
| 37 |
<div class="merchant-free-gifts-widget-offer-product-contents"> |
| 38 |
<p class="woocommerce-loop-product__title"> |
| 39 |
<a class="merchant-free-gifts-widget-offer-product-title" href="<?php echo esc_url( $offer['product']['permalink'] ); ?>" target="_blank"> |
| 40 |
<?php echo esc_html( $offer['product']['title'] ); ?> |
| 41 |
</a> |
| 42 |
</p> |
| 43 |
<div class="merchant-free-gifts-widget-offer-product-price price"> |
| 44 |
<del> |
| 45 |
<?php echo wp_kses( wc_price( $offer['product']['price'] ), merchant_kses_allowed_tags( array( 'bdi' ) ) ); ?> |
| 46 |
</del> |
| 47 |
<strong class="merchant-free-gifts-widget-offer-product-free"> |
| 48 |
<?php echo isset( $settings['free_text'] ) ? esc_html( Merchant_Translator::translate( $settings['free_text'] ) ) : esc_html__( 'Free', 'merchant' ) ?> |
| 49 |
</strong> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
</div> |
| 53 |
</div> |
| 54 |
<?php endif; ?> |
| 55 |
<?php endforeach; ?> |