| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plan detail - Durations tab. Each term is its own card: icon + name and |
| 4 |
* a muted meta line (breakdown, trial, signup fee, expiry) + toggle, edit and delete actions. |
| 5 |
* |
| 6 |
* @var array $plan Plan (PlanPresenter shape). |
| 7 |
* |
| 8 |
* @package SpringDevs\Subscription\Admin |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
?> |
| 15 |
<div style="padding-top:8px;"> |
| 16 |
|
| 17 |
<?php if ( empty( $plan['terms'] ) ) : ?> |
| 18 |
<div class="wpsubs-empty"> |
| 19 |
<div class="wpsubs-empty__icon">🗓️</div> |
| 20 |
<h3 class="wpsubs-empty__title"><?php esc_html_e( 'No durations yet', 'subscription' ); ?></h3> |
| 21 |
<p class="wpsubs-empty__desc"><?php esc_html_e( 'A duration sets how often the customer is charged, like every month or every year. Add at least one so this plan can be sold.', 'subscription' ); ?></p> |
| 22 |
<button type="button" class="wpsubs-btn wpsubs-btn--primary" style="margin-top:20px;" data-wpsubs-modal-open="subscrpt-term-modal" data-subscrpt-add-term> |
| 23 |
<?php esc_html_e( 'Add your first duration', 'subscription' ); ?> |
| 24 |
</button> |
| 25 |
</div> |
| 26 |
<?php else : ?> |
| 27 |
<div data-subscrpt-browse data-per-page="10"> |
| 28 |
<div data-subscrpt-sortable="terms" style="display:flex;flex-direction:column;gap:10px;"> |
| 29 |
<?php foreach ( $plan['terms'] as $selling_term ) : ?> |
| 30 |
<div class="wpsubs-table-card" data-term-id="<?php echo esc_attr( $selling_term['id'] ); ?>" data-subscrpt-browse-item data-subscrpt-sort-item="<?php echo esc_attr( $selling_term['id'] ); ?>" data-name="<?php echo esc_attr( strtolower( $selling_term['name'] ) ); ?>" style="display:flex;align-items:center;gap:14px;padding:14px 16px;"> |
| 31 |
<button type="button" class="wpsubs-sort-handle" data-subscrpt-sort-handle title="<?php esc_attr_e( 'Drag to reorder', 'subscription' ); ?>" aria-label="<?php esc_attr_e( 'Drag to reorder', 'subscription' ); ?>"> |
| 32 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="16" height="16" fill="currentColor" aria-hidden="true"><circle cx="7" cy="5" r="1.5"/><circle cx="13" cy="5" r="1.5"/><circle cx="7" cy="10" r="1.5"/><circle cx="13" cy="10" r="1.5"/><circle cx="7" cy="15" r="1.5"/><circle cx="13" cy="15" r="1.5"/></svg> |
| 33 |
</button> |
| 34 |
<span style="flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:var(--wpsubs-radius);background:var(--wpsubs-brand-light);color:var(--wpsubs-brand);"> |
| 35 |
<span class="dashicons dashicons-calendar-alt"></span> |
| 36 |
</span> |
| 37 |
<div style="flex:1 1 auto;min-width:0;"> |
| 38 |
<?php // min-height is the badge's height, so a draft row is exactly as tall as an active one. ?> |
| 39 |
<div data-subscrpt-term-name-row style="display:flex;align-items:center;gap:6px;min-height:24px;min-width:0;"> |
| 40 |
<span style="font-weight:600;font-size:13.5px;"><?php echo esc_html( $selling_term['name'] ); ?></span> |
| 41 |
<?php if ( 'draft' === $selling_term['status'] ) : ?> |
| 42 |
<span class="wpsubs-badge wpsubs-badge--draft" data-subscrpt-term-badge><?php esc_html_e( 'Draft', 'subscription' ); ?></span> |
| 43 |
<?php endif; ?> |
| 44 |
</div> |
| 45 |
<?php $subscrpt_meta_parts = array_merge( array( $selling_term['breakdown'] ), $selling_term['chips'] ); ?> |
| 46 |
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:2px;font-size:12px;color:var(--wpsubs-text-muted);"> |
| 47 |
<span title="<?php esc_attr_e( 'Plan ID', 'subscription' ); ?>">#<?php echo esc_html( $selling_term['id'] ); ?></span> |
| 48 |
<span style="color:var(--wpsubs-text-subtle);">·</span> |
| 49 |
<?php foreach ( $subscrpt_meta_parts as $subscrpt_i => $subscrpt_part ) : ?> |
| 50 |
<?php |
| 51 |
if ( $subscrpt_i > 0 ) : |
| 52 |
?> |
| 53 |
<span style="color:var(--wpsubs-text-subtle);">·</span><?php endif; ?> |
| 54 |
<span><?php echo esc_html( $subscrpt_part ); ?></span> |
| 55 |
<?php endforeach; ?> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
<?php $subscrpt_is_active = 'draft' !== $selling_term['status']; ?> |
| 59 |
<div style="flex:0 0 auto;display:inline-flex;align-items:center;gap:10px;"> |
| 60 |
<label |
| 61 |
title="<?php echo esc_attr( $subscrpt_is_active ? __( 'Set as Draft', 'subscription' ) : __( 'Set as Active', 'subscription' ) ); ?>" |
| 62 |
data-subscrpt-set-term-status="<?php echo $subscrpt_is_active ? 'draft' : 'active'; ?>" |
| 63 |
data-term-id="<?php echo esc_attr( $selling_term['id'] ); ?>" |
| 64 |
style="display:inline-flex;align-items:center;cursor:pointer;" |
| 65 |
> |
| 66 |
<input type="checkbox" class="wpsubs-toggle" <?php checked( $subscrpt_is_active ); ?> aria-label="<?php esc_attr_e( 'Toggle active status', 'subscription' ); ?>" /> |
| 67 |
<span class="wpsubs-toggle-ui" aria-hidden="true"></span> |
| 68 |
</label> |
| 69 |
<span style="display:inline-flex;align-items:center;gap:2px;"> |
| 70 |
<button type="button" class="wpsubs-icon-action" data-subscrpt-edit-term="<?php echo esc_attr( $selling_term['id'] ); ?>" title="<?php esc_attr_e( 'Edit', 'subscription' ); ?>" aria-label="<?php esc_attr_e( 'Edit', 'subscription' ); ?>"> |
| 71 |
<span class="dashicons dashicons-edit"></span> |
| 72 |
</button> |
| 73 |
<button type="button" class="wpsubs-icon-action wpsubs-icon-action--danger" data-subscrpt-delete-term="<?php echo esc_attr( $selling_term['id'] ); ?>" title="<?php esc_attr_e( 'Delete', 'subscription' ); ?>" aria-label="<?php esc_attr_e( 'Delete', 'subscription' ); ?>"> |
| 74 |
<span class="dashicons dashicons-trash"></span> |
| 75 |
</button> |
| 76 |
</span> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
<?php endforeach; ?> |
| 80 |
</div> |
| 81 |
|
| 82 |
<div data-subscrpt-browse-pager style="margin-top:14px;"></div> |
| 83 |
</div> |
| 84 |
<?php endif; ?> |
| 85 |
|
| 86 |
</div> |
| 87 |
|