From 715e26a9eb219808d5c899d418e1d596f9318f61 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 22 Jun 2026 16:59:19 +0000
Subject: [PATCH] =Debugging and implementing the Checkout.js logic. Will be uploading to test integration with square next.
---
inc/ui/Checkout.php | 54 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/inc/ui/Checkout.php b/inc/ui/Checkout.php
index 974d09f..f1a6d24 100644
--- a/inc/ui/Checkout.php
+++ b/inc/ui/Checkout.php
@@ -1,6 +1,8 @@
<?php
namespace JVBase\ui;
+use JVBase\base\Site;
+use JVBase\integrations\Integrations;
use JVBase\meta\Form;
if (!defined('ABSPATH')) {
@@ -26,6 +28,15 @@
*/
class Checkout
{
+ public static function getProvider():Integrations|false
+ {
+ foreach (Site::getIntegrations() as $integration => $active) {
+ if (in_array($integration, ['square', 'helcim']) && $active) {
+ return JVB()->connect($integration);
+ }
+ }
+ return false;
+ }
/**
* Render the checkout aside and append to actions.
*
@@ -37,15 +48,18 @@
return $actions;
}
- $provider = jvbGetPaymentProvider();
+ $provider = self::getProvider();
if (!$provider || !$provider->isSetUp()) {
return $actions;
}
$providerName = strtolower($provider->getServiceName());
- $form = '<aside id="cart" class="right main">
- <form id="checkout" data-form-id="checkout" data-save="checkout" data-provider="' . esc_attr($providerName) . '">';
+ $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)
+ );
$tabs = [
'cartItems' => [
@@ -74,11 +88,12 @@
$form .= jvbRenderTabs($tabs, true);
- $form .= '<div class="cart-total row end">
+ $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>
</aside>';
$form .= self::templates($providerName);
@@ -150,9 +165,23 @@
<th scope="col">Item</th>
<th scope="col">Price</th>
<th scope="col">Total</th>
+ <th scope="col"></th>
</tr>
</thead>
- <tbody></tbody>
+ <tfoot>
+ <tr>
+ <th scope="col"></th>
+ <th scope="col">TAX</th>
+ <td class="tax"></td>
+ <th scope="col"></th>
+ </tr>
+ <tr>
+ <th scope="col"></th>
+ <th scope="col">Net:</th>
+ <td class="total"></td>
+ <th scope="col"></th>
+ </tr>
+ </tfoot>
</table>
</div>
@@ -235,17 +264,22 @@
$browseText = apply_filters('jvb_checkout_browse_text', 'browse our products');
return '<template class="restoredCart">
- <div class="restored">
+ <div class="fstatus restored">
<h3>Looks like we left things hanging</h3>
<p>We\'ve restored your cart from your last session below.</p>
<p>If you\'d rather start over, click the button below.</p>
- <div class="row btw">
+ <div class="row x-btw">
<button type="button" data-clear-cart>' . jvbIcon('trash') . 'Clear Cart</button>
<button type="button" data-dismiss>' . jvbIcon('x') . 'Dismiss</button>
</div>
</div>
</template>
- <template class="cartItem">
+ <template class="mainCartItem">
+ <tbody>
+ <tr class="header"><th></th></tr>
+ </tbody>
+ </template>
+ <template class="childCartItem">
<tr class="item">
<td class="item">
<label for="quantity"></label>
@@ -275,11 +309,11 @@
*/
private static function toggleButton(): string
{
- return '<button type="button" class="toggle-cart row" title="Your Cart"
+ return '<button type="button" class="toggle-cart row empty" title="Your Cart"
data-action="toggle-cart" aria-label="Open Cart"
aria-controls="checkout" aria-expanded="false">'
. jvbIcon('shopping-cart')
- . '<span class="abs"></span><span class="abs count"></span>
+ . '<span class="abs close"></span><span class="abs count"></span>
</button>';
}
}
--
Gitblit v1.10.0