| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
$items = isset( $context['items'] ) && is_array( $context['items'] ) ? $context['items'] : array(); |
| 7 |
$plugin_url = isset( $context['plugin_url'] ) ? untrailingslashit( $context['plugin_url'] ) : ''; |
| 8 |
$logo_base = $plugin_url . '/assets/payment-logos'; |
| 9 |
?> |
| 10 |
<div class="ebook-store-template-2026"> |
| 11 |
<div class="ebook-store-template-2026__stack<?php echo count( $items ) === 1 ? ' is-single' : ''; ?>"> |
| 12 |
<?php foreach ( $items as $item ) : ?> |
| 13 |
<?php $payment_methods = isset( $item['payment_methods'] ) && is_array( $item['payment_methods'] ) ? $item['payment_methods'] : array(); ?> |
| 14 |
<article class="ebook-2026-card"> |
| 15 |
<div class="ebook-2026-card__main"> |
| 16 |
<div class="ebook-2026-card__media"> |
| 17 |
<div class="ebook-2026-card__cover-shell"> |
| 18 |
<?php if ( ! empty( $item['cover_url'] ) ) : ?> |
| 19 |
<img src="<?php echo esc_url( $item['cover_url'] ); ?>" alt="<?php echo esc_attr( $item['title'] ); ?>" class="ebook-2026-card__cover" /> |
| 20 |
<?php else : ?> |
| 21 |
<div class="ebook-2026-card__cover-placeholder"><?php esc_html_e( 'Ebook cover', 'ebook-store' ); ?></div> |
| 22 |
<?php endif; ?> |
| 23 |
</div> |
| 24 |
<div class="ebook-2026-card__meta"> |
| 25 |
<?php if ( ! empty( $item['authors'] ) || ! empty( $item['publishers'] ) || ! empty( $item['date_text'] ) || ! empty( $item['pages_text'] ) ) : ?> |
| 26 |
<div class="ebook-2026-facts"> |
| 27 |
<?php if ( ! empty( $item['authors'] ) ) : ?> |
| 28 |
<div class="ebook-2026-fact"> |
| 29 |
<span class="ebook-2026-fact__label"><?php esc_html_e( 'Author', 'ebook-store' ); ?></span> |
| 30 |
<strong class="ebook-2026-fact__value"><?php echo esc_html( $item['authors'] ); ?></strong> |
| 31 |
</div> |
| 32 |
<?php endif; ?> |
| 33 |
<?php if ( ! empty( $item['publishers'] ) ) : ?> |
| 34 |
<div class="ebook-2026-fact"> |
| 35 |
<span class="ebook-2026-fact__label"><?php esc_html_e( 'Publisher', 'ebook-store' ); ?></span> |
| 36 |
<strong class="ebook-2026-fact__value"><?php echo esc_html( $item['publishers'] ); ?></strong> |
| 37 |
</div> |
| 38 |
<?php endif; ?> |
| 39 |
<?php if ( ! empty( $item['date_text'] ) ) : ?> |
| 40 |
<div class="ebook-2026-fact"> |
| 41 |
<span class="ebook-2026-fact__label"><?php esc_html_e( 'Released', 'ebook-store' ); ?></span> |
| 42 |
<strong class="ebook-2026-fact__value"><?php echo esc_html( $item['date_text'] ); ?></strong> |
| 43 |
</div> |
| 44 |
<?php endif; ?> |
| 45 |
<?php if ( ! empty( $item['pages_text'] ) ) : ?> |
| 46 |
<div class="ebook-2026-fact"> |
| 47 |
<span class="ebook-2026-fact__label"><?php esc_html_e( 'Length', 'ebook-store' ); ?></span> |
| 48 |
<strong class="ebook-2026-fact__value"><?php echo esc_html( $item['pages_text'] ); ?></strong> |
| 49 |
</div> |
| 50 |
<?php endif; ?> |
| 51 |
</div> |
| 52 |
<?php endif; ?> |
| 53 |
</div> |
| 54 |
</div> |
| 55 |
|
| 56 |
<div class="ebook-2026-card__content"> |
| 57 |
<div class="ebook-2026-card__header"> |
| 58 |
<div> |
| 59 |
<span class="ebook-2026-card__eyebrow"><?php esc_html_e( 'Digital edition', 'ebook-store' ); ?></span> |
| 60 |
<h3 class="ebook-2026-card__title"><?php echo esc_html( $item['title'] ); ?></h3> |
| 61 |
</div> |
| 62 |
<div class="ebook-2026-card__price-block"> |
| 63 |
<?php if ( ! empty( $item['ebook']['donate_or_download'] ) ) : ?> |
| 64 |
<span class="ebook-2026-status"> |
| 65 |
<?php |
| 66 |
if ( $item['ebook']['donate_or_download'] === 'free' ) { |
| 67 |
esc_html_e( 'Free', 'ebook-store' ); |
| 68 |
} elseif ( $item['ebook']['donate_or_download'] === 'donate' ) { |
| 69 |
esc_html_e( 'Donate', 'ebook-store' ); |
| 70 |
} else { |
| 71 |
esc_html_e( 'Paid', 'ebook-store' ); |
| 72 |
} |
| 73 |
?> |
| 74 |
</span> |
| 75 |
<?php endif; ?> |
| 76 |
<p class="ebook-2026-card__price"><?php echo esc_html( $item['price_display'] ); ?></p> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
|
| 80 |
<div class="ebook-2026-card__description"> |
| 81 |
<?php echo $item['content_html']; ?> |
| 82 |
</div> |
| 83 |
|
| 84 |
<?php $file_facts = isset( $item['file_facts'] ) && is_array( $item['file_facts'] ) ? $item['file_facts'] : array(); ?> |
| 85 |
<ul class="ebook-2026-card__supporting"> |
| 86 |
<?php if ( ! empty( $file_facts ) ) : ?> |
| 87 |
<?php foreach ( $file_facts as $fact ) : ?> |
| 88 |
<li><?php echo esc_html( $fact ); ?></li> |
| 89 |
<?php endforeach; ?> |
| 90 |
<?php else : ?> |
| 91 |
<li><?php esc_html_e( 'Primary format is ready for download', 'ebook-store' ); ?></li> |
| 92 |
<?php endif; ?> |
| 93 |
</ul> |
| 94 |
</div> |
| 95 |
</div> |
| 96 |
|
| 97 |
<aside class="ebook-2026-card__checkout"> |
| 98 |
<div class="ebook-2026-checkout"> |
| 99 |
<span class="ebook-2026-checkout__eyebrow"><?php esc_html_e( 'Checkout', 'ebook-store' ); ?></span> |
| 100 |
<h4><?php echo ! empty( $payment_methods ) ? esc_html__( 'Select payment method', 'ebook-store' ) : esc_html__( 'Get this ebook', 'ebook-store' ); ?></h4> |
| 101 |
<p> |
| 102 |
<?php |
| 103 |
echo ! empty( $payment_methods ) |
| 104 |
? esc_html__( 'Choose the payment option you prefer. Each method opens its own secure checkout flow.', 'ebook-store' ) |
| 105 |
: esc_html__( 'Start the delivery flow below. If a preview is available, you can review it first.', 'ebook-store' ); |
| 106 |
?> |
| 107 |
</p> |
| 108 |
|
| 109 |
<?php if ( ! empty( $payment_methods ) ) : ?> |
| 110 |
<div class="ebook-2026-checkout__methods"> |
| 111 |
<?php foreach ( $payment_methods as $method ) : ?> |
| 112 |
<?php |
| 113 |
$method_key = isset( $method['key'] ) ? sanitize_key( $method['key'] ) : 'payment'; |
| 114 |
$method_label = isset( $method['label'] ) ? $method['label'] : ucfirst( $method_key ); |
| 115 |
$method_logo = $logo_base . '/' . $method_key . '.svg'; |
| 116 |
$method_href = ! empty( $method['href'] ) ? $method['href'] : '#'; |
| 117 |
$method_onclick = ! empty( $method['onclick'] ) ? $method['onclick'] : ''; |
| 118 |
?> |
| 119 |
<a class="ebook-2026-method ebook-2026-method--<?php echo esc_attr( $method_key ); ?>" href="<?php echo esc_url( $method_href ); ?>" data-ebook-store-payment-method="<?php echo esc_attr( $method_key ); ?>" data-ebook-store-add-payment-info="1" data-ebook-store-begin-checkout="1" data-ebook-store-item-id="<?php echo esc_attr( $item['ebook_id'] ); ?>" data-ebook-store-item-name="<?php echo esc_attr( $item['title'] ); ?>" data-ebook-store-currency="<?php echo esc_attr( $item['paypal_currency'] ); ?>" data-ebook-store-value="<?php echo esc_attr( (string) ebook_store_price_plus_vat( $item['ebook']['ebook_price'] ) ); ?>"<?php echo $method_onclick ? ' onClick="' . esc_attr( $method_onclick ) . '"' : ''; ?>> |
| 120 |
<span class="ebook-2026-method__brand"> |
| 121 |
<img src="<?php echo esc_url( $method_logo ); ?>" alt="<?php echo esc_attr( $method_label ); ?>" /> |
| 122 |
</span> |
| 123 |
<span class="ebook-2026-method__copy"> |
| 124 |
<strong><?php echo esc_html( $method_label ); ?></strong> |
| 125 |
<small><?php esc_html_e( 'Checkout', 'ebook-store' ); ?></small> |
| 126 |
</span> |
| 127 |
<span class="ebook-2026-method__arrow">></span> |
| 128 |
</a> |
| 129 |
<?php endforeach; ?> |
| 130 |
</div> |
| 131 |
<?php else : ?> |
| 132 |
<a style="<?php echo (int) $item['hide_buy_now'] > 0 ? 'display:none;' : ''; ?>" class="ebook_buy_link ebook-2026-primary-action" data-md5_nonce="<?php echo esc_attr( $item['md5_nonce'] ); ?>" href="<?php echo esc_url( $item['buy_link_href'] ); ?>" onClick="<?php echo esc_attr( $item['buy_link_onclick'] ); ?>"<?php echo ! empty( $item['primary_payment_method'] ) ? ' data-ebook-store-payment-method="' . esc_attr( $item['primary_payment_method'] ) . '" data-ebook-store-add-payment-info="1" data-ebook-store-begin-checkout="1" data-ebook-store-item-id="' . esc_attr( $item['ebook_id'] ) . '" data-ebook-store-item-name="' . esc_attr( $item['title'] ) . '" data-ebook-store-currency="' . esc_attr( $item['paypal_currency'] ) . '" data-ebook-store-value="' . esc_attr( (string) ebook_store_price_plus_vat( $item['ebook']['ebook_price'] ) ) . '"' : ''; ?>> |
| 133 |
<?php echo esc_html( $item['buy_link_text'] ); ?> |
| 134 |
</a> |
| 135 |
<?php endif; ?> |
| 136 |
|
| 137 |
<div class="ebook-2026-checkout__secondary"> |
| 138 |
<?php if ( ! empty( $item['add_to_cart_html'] ) ) : ?> |
| 139 |
<?php echo $item['add_to_cart_html']; ?> |
| 140 |
<?php endif; ?> |
| 141 |
<?php if ( ! empty( $item['preview_url'] ) ) : ?> |
| 142 |
<a class="ebook-2026-secondary-action" target="_blank" rel="noopener" href="<?php echo esc_url( $item['preview_url'] ); ?>"><?php echo esc_html( isset( $item['preview_label'] ) ? $item['preview_label'] : __( 'Preview', 'ebook-store' ) ); ?></a> |
| 143 |
<?php endif; ?> |
| 144 |
</div> |
| 145 |
|
| 146 |
<ul class="ebook-2026-checkout__trust"> |
| 147 |
<li><?php esc_html_e( 'Secure payment routing', 'ebook-store' ); ?></li> |
| 148 |
<li><?php esc_html_e( 'Fast order confirmation', 'ebook-store' ); ?></li> |
| 149 |
<li><?php esc_html_e( 'Digital fulfillment after payment', 'ebook-store' ); ?></li> |
| 150 |
</ul> |
| 151 |
</div> |
| 152 |
<?php echo $item['form_html']; ?> |
| 153 |
</aside> |
| 154 |
</article> |
| 155 |
<?php endforeach; ?> |
| 156 |
</div> |
| 157 |
</div> |
| 158 |
|