From 4089ba01e0881c89a72332e13bc3a80b6bddec2a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 29 Jun 2026 22:15:55 +0000
Subject: [PATCH] =DashboardManager overhaul. A bit easier to modify the output of pages. Still have to get the account pages to work as expected, as well as verify the integrations and others are working - but registrar/content pages work as expected. Also fixed up the table generation in CRUD.js and CRUDSkeleton.php
---
inc/ui/Checkout.php | 166 ++++++++++++++++++++++++++-----------------------------
1 files changed, 78 insertions(+), 88 deletions(-)
diff --git a/inc/ui/Checkout.php b/inc/ui/Checkout.php
index f1a6d24..ad21146 100644
--- a/inc/ui/Checkout.php
+++ b/inc/ui/Checkout.php
@@ -4,6 +4,7 @@
use JVBase\base\Site;
use JVBase\integrations\Integrations;
use JVBase\meta\Form;
+use JVBase\meta\Meta;
if (!defined('ABSPATH')) {
exit;
@@ -55,52 +56,51 @@
$providerName = strtolower($provider->getServiceName());
- $form = sprintf(
- '<aside id="cart" class="right main"><div class="wrap">
- <form id="checkout" data-form-id="checkout" data-save="checkout" data-provider="%s">',
- esc_attr($providerName)
- );
+ $aside = '<aside id="cart" class="right main"><div class="wrap">';
+ $tabs = new Tabs();
+ $tabs->addTab('cartItems')
+ ->title('Your Cart')
+ ->icon('shopping-cart-simple')
+ ->description('Here\'s your order. You can change quantities, remove items, or clear your cart. To checkout, click the checkout tab.')
+ ->content(self::cartContent($providerName));
- $tabs = [
- 'cartItems' => [
- 'title' => 'Your Order',
- 'icon' => 'cart',
- 'description' => 'Here\'s your order. You can change quantities, remove items, or clear your cart.',
- 'content' => self::cartContent(),
- ],
- 'checkout' => [
- 'title' => 'Checkout',
- 'icon' => 'checkout',
- 'description' => apply_filters('jvb_checkout_description',
- 'Securely checkout with your name, email, and payment.',
- $providerName
- ),
- 'content' => self::checkoutContent($providerName),
- ],
- 'order' => [
- 'title' => 'Your Order',
- 'icon' => 'truck',
- 'hidden' => true,
- 'description' => '',
- 'content' => self::orderStatus(),
- ],
- ];
+ if (!is_user_logged_in()) {
+ $tabs->addTab('thelogin')
+ ->title('Login')
+ ->description('Login to see past orders and access your saved cards')
+ ->content(JVB()->magicLink()->renderForm());
+ } else {
+ $tabs->addTab('account')
+ ->title('Account')
+ ->description('Manage your contact information, saved cards, and see past orders')
+ ->content(self::renderAccount());
+ }
- $form .= jvbRenderTabs($tabs, true);
+ $tabs->addTab('checkout')
+ ->title('Checkout')
+ ->icon('hand-coins')
+ ->description(apply_filters('jvb_checkout_description',
+ 'Securely checkout with your name, email, and payment.', $providerName))
+ ->content(self::checkoutContent($providerName));
- $form .= '<div class="cart-total row right">
- <p class="tax">Tax: <span></span></p>
- <p class="total">GRAND TOTAL: <span></span></p>
- </div>
- </form>
- </div>
+ $tabs->addTab('order')
+ ->title('Your Order')
+ ->icon('truck')
+ ->hidden()
+ ->content(self::orderStatus());
+
+ $aside .= $tabs->render();
+
+
+
+ $aside .= '</div>
</aside>';
- $form .= self::templates($providerName);
+ $aside .= self::templates($providerName);
$actions[] = [
'button' => self::toggleButton(),
- 'content' => $form,
+ 'content' => $aside,
];
return $actions;
@@ -115,50 +115,66 @@
*/
private static function checkoutContent(string $provider): string
{
- $fields = '<div class="checkout-section">
- <h3>Customer Information</h3>'
- . Form::render('cart_name', null, [
+ $name = $email = $phone = '';
+ if (is_user_logged_in()) {
+ $meta = Meta::forUser(get_current_user_id());
+ if ($meta) {
+ $name = $meta->get('display_name');
+ $email = $meta->get('user_email');
+ $phone = $meta->get('phone');
+ }
+
+ }
+ $form = sprintf(
+ '<form id="checkout" data-handled>
+ <h3>Your Information</h3>
+ %s%s%s',
+ Form::render('cart_name', $name, [
'type' => 'text',
'label' => 'Your Name',
'required' => true,
'autocomplete' => 'name',
- ])
- . Form::render('cart_email', null, [
+ ]),
+ Form::render('cart_email', $email, [
'type' => 'email',
'label' => 'Your Email',
'required' => true,
'autocomplete' => 'email',
- ])
- . Form::render('cart_phone', null, [
+ ]),
+ Form::render('cart_phone', $phone, [
'type' => 'tel',
'label' => 'Your Phone',
'required' => true,
'autocomplete' => 'phone',
- ]);
+ ])
+ );
+
// Optional sections — integrations can add pickup, scheduling, etc.
- $fields .= apply_filters('jvb_checkout_fields', '', $provider);
+ $form .= apply_filters('jvb_checkout_fields', '', $provider);
- $fields .= '</div>';
+
// Payment section — provider JS mounts its own UI inside #payment-container
- $fields .= '<div class="checkout-section">
+ $form .= '<div class="checkout-section">
<h3>Payment Information</h3>
<div id="saved-cards"></div>
<div id="payment-container" data-provider="' . esc_attr($provider) . '"></div>
- </div>';
+ </div>
+ </form>';
- return $fields;
+ return $form;
}
/**
* Cart items tab: table + account details
*/
- private static function cartContent(): string
+ private static function cartContent(string $provider): string
{
- ob_start();
- ?>
- <div class="cart-items">
+ $content = sprintf('<form id="checkout" data-form-id="checkout" data-save="checkout" data-provider="%s">',
+ esc_attr($provider)
+ );
+ $content.= '<div class="cart-items">
<table>
<thead>
<tr>
@@ -184,39 +200,8 @@
</tfoot>
</table>
</div>
-
- <details class="account">
- <summary>
- <?php
- if (is_user_logged_in()) {
- echo 'Your Favourites and Order History';
- } else {
- echo '<a href="' . wp_login_url(get_the_permalink()) . '">Log in</a> to save your favourites and view order history.';
- }
- ?>
- </summary>
- <?php
- if (is_user_logged_in()) {
- $tabs = [
- 'history' => [
- 'title' => 'Order History',
- 'icon' => 'checkout',
- 'description' => 'View your past orders and quickly reorder',
- 'content' => apply_filters('jvb_checkout_order_history', ''),
- ],
- 'favourites' => [
- 'title' => 'Favourites',
- 'icon' => 'heart',
- 'description' => 'View your favourites',
- 'content' => apply_filters('jvb_checkout_favourites', ''),
- ],
- ];
- jvbRenderTabs($tabs);
- }
- ?>
- </details>
- <?php
- return ob_get_clean();
+ </form>';
+ return $content;
}
/**
@@ -253,6 +238,11 @@
return ob_get_clean();
}
+ private static function renderAccount():string
+ {
+ return '';
+ }
+
/*****************************************************************
* TEMPLATES — cloned by JS at runtime
*****************************************************************/
--
Gitblit v1.10.0