| | |
| | | <?php |
| | | namespace JVBase\ui; |
| | | |
| | | use JVBase\base\Site; |
| | | use JVBase\integrations\Integrations; |
| | | use JVBase\meta\Form; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | |
| | | */ |
| | | 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. |
| | | * |
| | |
| | | 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' => [ |
| | |
| | | <p class="total">GRAND TOTAL: <span></span></p> |
| | | </div> |
| | | </form> |
| | | </div> |
| | | </aside>'; |
| | | |
| | | $form .= self::templates($providerName); |
| | |
| | | <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> |
| | | |
| | |
| | | $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> |
| | | </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> |
| | |
| | | */ |
| | | 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>'; |
| | | } |
| | | } |