Completed cart link widget. Use [glm-members-registrations-cart-link-widget] to place...
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 10 Oct 2017 21:04:53 +0000 (17:04 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 10 Oct 2017 21:04:53 +0000 (17:04 -0400)
assets/registrationBlack.png [new file with mode: 0644]
assets/registrationBlack.svg [new file with mode: 0644]
assets/registrationBlue.png [new file with mode: 0644]
assets/registrationBlue.svg [new file with mode: 0644]
classes/regCartSupport.php
defines.php
models/front/registrations/cartLinkWidget.php
models/front/registrations/registration.php
views/admin/registrations/eventEditLevels.html
views/front/registrations/cartLinkWidget.html

diff --git a/assets/registrationBlack.png b/assets/registrationBlack.png
new file mode 100644 (file)
index 0000000..d057824
Binary files /dev/null and b/assets/registrationBlack.png differ
diff --git a/assets/registrationBlack.svg b/assets/registrationBlack.svg
new file mode 100644 (file)
index 0000000..d6cd3d6
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"><svg version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 96.127 100" enable-background="new 0 0 96.127 100" xml:space="preserve"><path d="M46.21,49.882c-1.839,1.713-16.58,16.014-16.58,16.014l3.935,3.881c0,0,13.096-12.087,15.063-13.915\r
+       c0.487-0.451,1.31-1.309,2.833-1.309h44.667v-6.185H49.909C48.557,48.369,47.276,48.898,46.21,49.882z"></path><path d="M72.673,16.261c5.237,0,8.095-3.627,8.095-8.095c0-4.467-3.627-8.091-8.095-8.091c-4.471,0-8.095,3.624-8.095,8.091\r
+       C64.578,12.634,68.202,16.261,72.673,16.261z"></path><path d="M60.668,30.172h2.715l-3.978,14.291H85.94l-3.981-14.291h2.715l4.128,14.291h7.015L90.179,25.5\r
+       c-0.744-2.619-4.057-7.258-9.791-7.258H64.953c-5.73,0-9.039,4.639-9.79,7.258l-5.63,18.963h7.014L60.668,30.172z"></path><path d="M37.72,43.712l-3.441-6.415l-3.685-6.871c0,0-0.418-0.633-1.194-0.258c-0.698,0.336-0.383,1.123-0.383,1.123l2.364,4.511\r
+       l1.47,2.811l-1.696-0.764c-3.004-1.354-4.661-1.933-5.326-2.23c-0.118-0.054-0.701-0.375-0.977-0.983\r
+       c-0.787-1.76-4.149-10.27-4.904-12.151c-0.637-1.592-2.21-3.852-5.444-4.653c-3.681-0.911-7.39,1.411-8.267,5.104L1.216,44.102\r
+       C0.769,45.808,0,50.426,0,52.372c0,1.946,0.032,41.343,0.032,41.343c0.025,3.488,2.543,6.299,6.027,6.285\r
+       c3.48-0.011,5.863-2.847,5.852-6.332c0,0-0.003-22.514-0.007-35.024l5.354-22.605c0.626,1.529,1.399,3.392,1.653,3.839\r
+       c0.604,1.055,1.198,1.781,2.415,2.354c0,0,7.011,2.901,9.722,4.139c1.634,0.626,3.409,0.072,4.442-1.23l0.375-0.776l0.129,0.247\r
+       c0,0,0.798,1.406,1.979,1.47C38.31,45.007,37.72,43.712,37.72,43.712z"></path><circle cx="18.789" cy="8.095" r="8.097"></circle><polygon points="30.532,60.925 46.307,46.243 44.257,44.043 28.48,58.727 "></polygon></svg>
\ No newline at end of file
diff --git a/assets/registrationBlue.png b/assets/registrationBlue.png
new file mode 100644 (file)
index 0000000..94516c7
Binary files /dev/null and b/assets/registrationBlue.png differ
diff --git a/assets/registrationBlue.svg b/assets/registrationBlue.svg
new file mode 100644 (file)
index 0000000..8e067da
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"><svg fill="#51A7F9" version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 96.127 100" enable-background="new 0 0 96.127 100" xml:space="preserve"><path d="M46.21,49.882c-1.839,1.713-16.58,16.014-16.58,16.014l3.935,3.881c0,0,13.096-12.087,15.063-13.915\r
+       c0.487-0.451,1.31-1.309,2.833-1.309h44.667v-6.185H49.909C48.557,48.369,47.276,48.898,46.21,49.882z"></path><path d="M72.673,16.261c5.237,0,8.095-3.627,8.095-8.095c0-4.467-3.627-8.091-8.095-8.091c-4.471,0-8.095,3.624-8.095,8.091\r
+       C64.578,12.634,68.202,16.261,72.673,16.261z"></path><path d="M60.668,30.172h2.715l-3.978,14.291H85.94l-3.981-14.291h2.715l4.128,14.291h7.015L90.179,25.5\r
+       c-0.744-2.619-4.057-7.258-9.791-7.258H64.953c-5.73,0-9.039,4.639-9.79,7.258l-5.63,18.963h7.014L60.668,30.172z"></path><path d="M37.72,43.712l-3.441-6.415l-3.685-6.871c0,0-0.418-0.633-1.194-0.258c-0.698,0.336-0.383,1.123-0.383,1.123l2.364,4.511\r
+       l1.47,2.811l-1.696-0.764c-3.004-1.354-4.661-1.933-5.326-2.23c-0.118-0.054-0.701-0.375-0.977-0.983\r
+       c-0.787-1.76-4.149-10.27-4.904-12.151c-0.637-1.592-2.21-3.852-5.444-4.653c-3.681-0.911-7.39,1.411-8.267,5.104L1.216,44.102\r
+       C0.769,45.808,0,50.426,0,52.372c0,1.946,0.032,41.343,0.032,41.343c0.025,3.488,2.543,6.299,6.027,6.285\r
+       c3.48-0.011,5.863-2.847,5.852-6.332c0,0-0.003-22.514-0.007-35.024l5.354-22.605c0.626,1.529,1.399,3.392,1.653,3.839\r
+       c0.604,1.055,1.198,1.781,2.415,2.354c0,0,7.011,2.901,9.722,4.139c1.634,0.626,3.409,0.072,4.442-1.23l0.375-0.776l0.129,0.247\r
+       c0,0,0.798,1.406,1.979,1.47C38.31,45.007,37.72,43.712,37.72,43.712z"></path><circle cx="18.789" cy="8.095" r="8.097"></circle><polygon points="30.532,60.925 46.307,46.243 44.257,44.043 28.48,58.727 "></polygon></svg>
\ No newline at end of file
index 2c3933c..1714ad0 100644 (file)
@@ -178,8 +178,7 @@ class GlmRegCartSupport
         // Try to get the base registration request data
         $this->cart['request'] = $RegRequest->getEntry($requestId);
         if (!$this->cart['request']) {
-            $this->cart['errorMsg'] = 'Unable to retrieve the requested registration request.';
-            return $this->cart;
+            return false;
         }
 
         // Add submitting account if not guest submission (at this point)
@@ -330,8 +329,6 @@ class GlmRegCartSupport
 
                     // Do event Checks
 
-
-
                     // Check if Event exists in Events add-on and is active in registrations or if doing admin (admin_active)
                     $regEvent = $RegEvent->getEntry($event['reg_event']);
                     if (!$regEvent) {
@@ -340,6 +337,8 @@ class GlmRegCartSupport
 
                     // Check if the event is time-specific and if there's a list of times for this event - If not, should be a default
 
+
+
                     /*
                      * Classes (levels) Processing
                      */
index 67bce71..4edcd47 100644 (file)
@@ -55,6 +55,8 @@ define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL', plugin_dir_url(__FILE__));
 define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_ADMIN_URL', admin_url('admin.php'));
 define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG);
 define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_CURRENT_URL', $urlParts['scheme'].'://'.$urlParts['host'].$pageUri[0]);
+define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_ASSETS_URL', GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL.'assets');
+
 
 // Directories
 define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH', dirname(__FILE__));
index 93ffb2c..aef9c53 100644 (file)
@@ -90,8 +90,9 @@ class GlmMembersFront_registrations_cartLinkWidget
         // Compile template data
         $templateData = $cartData;
         $templateData['haveCart'] = $haveCart;
+        $templateData['assetUrl'] = GLM_MEMBERS_REGISTRATIONS_PLUGIN_ASSETS_URL;
 
-        //echo "<pre>".print_r($templateData,1)."</pre>";
+        // echo "<pre>".print_r($templateData,1)."</pre>";
 
         $view = 'cartLinkWidget';
 
index e777627..aa9a084 100644 (file)
@@ -40,6 +40,7 @@
 
         $loginAccount      = '';
         $cartId            = false;
+        $haveCart          = false;
         $regEventFirstTime = false;
 
         // Have Backbone.js loaded
         require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH . '/regCartSupport.php';
         $RegCart = new GlmRegCartSupport( $this->wpdb, $this->config );
 
-        // Check if there's a current session
-        if ( isset( $_SESSION['glm_reg_cart_id'] ) ) {
-            $cartId = $_SESSION['glm_reg_cart_id'];
-        } else {
+        // If we have a session
+        if ( isset($_SESSION['glm_reg_cart_id']) ) {
 
-            // There isn't so create one
+            // Get cart ID from session
+            $cartId = $_SESSION['glm_reg_cart_id']-0;
+
+            // If it's a positive integer, try to get the cart
+            if ($cartId > 0) {
+                $cart = $RegCart->getRegistrationCart( $cartId );
+                if ($cart !== false && is_array($cart)) {
+                    $haveCart = true;
+                }
+            }
+
+        }
+
+        // If we don't have a valid cart
+        if (!$haveCart) {
+
+            // Create a cart
             $cartId = $RegCart->createRegistrationCart();
-            if ( isset( $cartId ) && filter_var( $cartId, FILTER_VALIDATE_INT ) ) {
-                $_SESSION['glm_reg_cart_id'] = $cartId;
+
+            // If we now have a cart ID
+            if ($cartId) {
+
+                // Try to get the new cart
+                $cart = $RegCart->getRegistrationCart( $cartId );
+                if ($cart !== false && is_array($cart)) {
+                    $haveCart = true;
+                    $_SESSION['glm_reg_cart_id'] = $cartId;
+                }
+
             }
 
         }
 
-        if ( isset( $cartId ) && filter_var( $cartId, FILTER_VALIDATE_INT ) ) {
-            $cart = $RegCart->getRegistrationCart( $cartId );
+        // If we have a good cart, convert to JSON for view
+        if ($haveCart) {
             $regRequestJSON = json_encode( $cart['request'], JSON_NUMERIC_CHECK );
         }
 
 // echo '<pre>$regEvent: ' . print_r( $regEvent, true ) . '</pre>';
         // Compile template data
         $templateData = array(
+            'haveCart'          => $haveCart,
             'regEvent'          => $regEvent,
             'regEventFirstTime' => $regEventFirstTime,
             'thisJsUrl'         => GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL . '/js',
index a1fa14a..0dd78ef 100644 (file)
@@ -36,7 +36,7 @@
         </script>
     
         <script type="text/template" id="regClass-template">
-            <div class="class-display-template">
+            <div class="class-display-template" style="display: none;">
                 <div class="glm-class-header">
                     <div class="glm-right">
                         <a class="class-edit button button-secondary glm-button-small">Edit</a>
index a80d598..7adc746 100644 (file)
@@ -1,25 +1,23 @@
-<div id="registrations-cart-link-widget">
-
-    <h3>Registrations Cart</h3>
-
-    {if $haveCart}
-        <a href="{$cartUrl}">
-        <div style="border: 1px solid black;">
-            <p>
-                Hi {$account_fname} {$account_lname}, you have {$numb_registrants} registrants for {$numb_events} events currently selected.
-                Click this box to view your registration request cart.
-            </p>
-            <p>
-                This is a temporary cart link widget - see views/front/registrations/cartLinkWiget.html
-                or build your own using data from the glm_members_registrations_cart_summary_data filter.
-            </p>
-        </div>  
-        </a>
-    {else}
-        <div style="border: 1px solid black;">
-            <p>No current cart</p>
+{if $haveCart}
+<a href="{$cartUrl}">
+    <div id="registrations-cart-link-widget" style="width: 80px; height: 75px; padding: 5px; background-color: #ffffff; border: 1px black solid; position: relative">
+        <img src="{$assetUrl}/registrationBlue.svg" width="50" style="position: absolute; z-index: 1;">
+        <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 14px; top: 65px; z-index: 2; font-style: italic;">REGISTRATION</div>
+        <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 19px; top: 42px; z-index: 2;">
+            {$numb_events} Event{if $numb_events > 1}s{/if}<br>
+            {$numb_registrants} Registrant{if $numb_registrants > 1}s{/if}
         </div>
-    {/if}
+    </div>
+</a>
+{else}
 
+    <div id="registrations-cart-link-widget" style="width: 80px; height: 75px; padding: 5px; background-color: #f0f0f0; border: 1px black solid; position: relative">
+        <img src="{$assetUrl}/registrationBlack.svg" width="50" style="position: absolute; z-index: 2;">
+        <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 14px; top: 65px; z-index: 2; font-style: italic;">REGISTRATION</div>
+        <div style="font-size: .5em; line-height: 1.1em; position: absolute; left: 25px; top: 42px; z-index: 2;">
+             Cart<br>Empty
+        </div>
+    </div>
+    
+{/if}
 
-</div>
\ No newline at end of file