Jake Vanderwerf
2026-06-22 715e26a9eb219808d5c899d418e1d596f9318f61
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' => [
@@ -79,6 +93,7 @@
            <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,7 +264,7 @@
      $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>
@@ -245,7 +274,12 @@
            </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>';
   }
}