| 1 |
<?php |
| 2 |
use SpringDevs\Subscription\Illuminate\Helper; |
| 3 |
/* |
| 4 |
STYLE GUIDE FOR WP SUBSCRIPTION ADMIN PAGES: |
| 5 |
- Use .wp-subscription-admin-content for main content area. |
| 6 |
- Use .wp-subscription-admin-box for white card/box with shadow and 6-8px border-radius. |
| 7 |
- Use .widefat.wp-subscription-list-table for tables, with no outer border, only row bottom borders. |
| 8 |
- Use compact table cells: font-size 14px, padding 8px 10px. |
| 9 |
- Use .button, .button-primary, .button-small for actions, with rounded corners, soft backgrounds, and subtle hover. |
| 10 |
- Use pill-shaped status labels (e.g., .subscrpt-active) for status. |
| 11 |
- Use Georgia, serif for titles, system sans-serif for body. |
| 12 |
- Keep all sections visually consistent, compact, and modern. |
| 13 |
- Avoid excessive spacing or large paddings. |
| 14 |
- All new UI/UX changes must follow these conventions. |
| 15 |
*/ |
| 16 |
if (!isset($post) || !is_object($post)) { |
| 17 |
global $post; |
| 18 |
} |
| 19 |
$order_id = get_post_meta($post->ID, '_subscrpt_order_id', true); |
| 20 |
$order = wc_get_order($order_id); |
| 21 |
$order_item_id = get_post_meta($post->ID, '_subscrpt_order_item_id', true); |
| 22 |
$order_item = $order ? $order->get_item($order_item_id) : null; |
| 23 |
$product_name = $order_item ? $order_item->get_name() : '-'; |
| 24 |
$cost = $order_item ? Helper::format_price_with_order_item(get_post_meta($post->ID, '_subscrpt_price', true), $order_item_id) : '-'; |
| 25 |
$qty = $order_item ? 'x' . $order_item->get_quantity() : '-'; |
| 26 |
$customer = $order ? $order->get_formatted_billing_full_name() : '-'; |
| 27 |
$customer_id = $order ? $order->get_customer_id() : 0; |
| 28 |
$customer_url = $customer_id ? admin_url('user-edit.php?user_id=' . $customer_id) : ''; |
| 29 |
$start_date = get_post_meta($post->ID, '_subscrpt_start_date', true); |
| 30 |
$end_date = get_post_meta($post->ID, '_subscrpt_end_date', true); |
| 31 |
$renewal_date = get_post_meta($post->ID, '_subscrpt_next_date', true); |
| 32 |
$status_obj = get_post_status_object(get_post_status($post->ID)); |
| 33 |
$payment_method = $order ? $order->get_payment_method_title() : '-'; |
| 34 |
$billing_address = $order ? $order->get_formatted_billing_address() : '-'; |
| 35 |
$shipping_address = $order ? $order->get_formatted_shipping_address() : '-'; |
| 36 |
|
| 37 |
|
| 38 |
?> |
| 39 |
<div class="wp-subscription-admin-content"> |
| 40 |
<div class="wp-subscription-info-grid" style="display:flex;gap:28px;align-items:flex-start;flex-wrap:nowrap;"> |
| 41 |
<!-- Left: Main Info --> |
| 42 |
<div class="wp-subscription-admin-box wp-subscription-info-left" style=" box-shadow: 0 1px 3px rgb(29 35 39 / 30%);flex:1 1 50%;max-width:50%;margin:25px 0 18px 18px;"> |
| 43 |
<table class="widefat striped wp-subscription-list-table" style="border-radius:8px;overflow:hidden;margin-bottom:16px;"> |
| 44 |
<tbody> |
| 45 |
<tr> |
| 46 |
<th style="width:120px;padding:8px 10px;">Product</th> |
| 47 |
<td style="padding:8px 10px;"><?php echo esc_html($product_name); ?></td> |
| 48 |
</tr> |
| 49 |
<tr> |
| 50 |
<th style="padding:8px 10px;">Cost</th> |
| 51 |
<td style="padding:8px 10px;"><?php echo $cost; ?></td> |
| 52 |
</tr> |
| 53 |
<tr> |
| 54 |
<th style="padding:8px 10px;">Qty</th> |
| 55 |
<td style="padding:8px 10px;"><?php echo esc_html($qty); ?></td> |
| 56 |
</tr> |
| 57 |
<tr> |
| 58 |
<th style="padding:8px 10px;">Started date</th> |
| 59 |
<td style="padding:8px 10px;"><?php echo $start_date ? esc_html(gmdate('F d, Y', $start_date)) : '-'; ?></td> |
| 60 |
</tr> |
| 61 |
<tr> |
| 62 |
<th style="padding:8px 10px;">Payment due date</th> |
| 63 |
<td style="padding:8px 10px;"><?php echo $renewal_date ? esc_html(gmdate('F d, Y', $renewal_date)) : '-'; ?></td> |
| 64 |
</tr> |
| 65 |
<tr> |
| 66 |
<th style="padding:8px 10px;">Status</th> |
| 67 |
<td style="padding:8px 10px;"><span class="subscrpt-status-badge subscrpt-status-<?php echo esc_attr($status_obj->name); ?>"><?php echo esc_html($status_obj->label); ?></span></td> |
| 68 |
</tr> |
| 69 |
<tr> |
| 70 |
<th style="padding:8px 10px;">Payment Method</th> |
| 71 |
<td style="padding:8px 10px;"><?php echo esc_html($payment_method); ?></td> |
| 72 |
</tr> |
| 73 |
</tbody> |
| 74 |
</table> |
| 75 |
</div> |
| 76 |
<!-- Right: Billing & Shipping --> |
| 77 |
<div class="wp-subscription-admin-box wp-subscription-info-right" style=" box-shadow: 0 1px 3px rgb(29 35 39 / 30%);background:#fff;flex:1 1 50%;max-width:50%;margin:25px 0 18px 0;"> |
| 78 |
<table class="widefat wp-subscription-list-table" style="border-radius:8px;overflow:hidden;margin-bottom:0;background:none;"> |
| 79 |
<tbody> |
| 80 |
<tr> |
| 81 |
<th style="width:70px;padding:8px 10px;">Billing</th> |
| 82 |
<td style="padding:8px 10px;"><?php echo $billing_address ? wp_kses_post($billing_address) : '-'; ?></td> |
| 83 |
</tr> |
| 84 |
<tr> |
| 85 |
<th style="width:70px;padding:8px 10px;">Shipping</th> |
| 86 |
<td style="padding:8px 10px;"><?php echo $shipping_address ? wp_kses_post($shipping_address) : '-'; ?></td> |
| 87 |
</tr> |
| 88 |
</tbody> |
| 89 |
</table> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
</div> |
| 93 |
<style> |
| 94 |
.subscrpt-status-badge { |
| 95 |
display: inline-block; |
| 96 |
min-width: 48px; |
| 97 |
padding: 2px 8px; |
| 98 |
border-radius: 4px; |
| 99 |
font-size: 12px; |
| 100 |
font-weight: 500; |
| 101 |
color: #222; |
| 102 |
text-align: center; |
| 103 |
letter-spacing: 0.01em; |
| 104 |
background: #e9ecef; |
| 105 |
box-shadow: none; |
| 106 |
text-transform: capitalize; |
| 107 |
} |
| 108 |
.subscrpt-status-active { background: #27c775 !important; color: #ffffff !important; } |
| 109 |
.subscrpt-status-cancelled { background: #fee2e2 !important; color: #b91c1c !important; } |
| 110 |
.subscrpt-status-draft { background: #e0e7ef !important; color: #374151 !important; } |
| 111 |
.subscrpt-status-pending { background: #fef9c3 !important; color: #b45309 !important; } |
| 112 |
.subscrpt-status-expired { background: #e5e7eb !important; color: #6b7280 !important; } |
| 113 |
.subscrpt-status-pe_cancelled { background: #ffedd5 !important; color: #b45309 !important; } |
| 114 |
@media (max-width: 900px) { |
| 115 |
.wp-subscription-info-left, .wp-subscription-info-right { |
| 116 |
flex-basis: 100% !important; |
| 117 |
max-width: 100% !important; |
| 118 |
margin-left: 0 !important; |
| 119 |
margin-right: 0 !important; |
| 120 |
} |
| 121 |
.wp-subscription-info-grid { |
| 122 |
flex-direction: column !important; |
| 123 |
gap: 18px !important; |
| 124 |
} |
| 125 |
} |
| 126 |
</style> |
| 127 |
|