From: Chuck Scott Date: Tue, 10 Oct 2017 21:04:53 +0000 (-0400) Subject: Completed cart link widget. Use [glm-members-registrations-cart-link-widget] to place... X-Git-Tag: v1.0.0^2~356 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=ddacd5d7e9f1af9dfd63b1bcf7cb1e0e14e863c2;p=WP-Plugins%2Fglm-member-db-registrations.git Completed cart link widget. Use [glm-members-registrations-cart-link-widget] to place widget. --- diff --git a/assets/registrationBlack.png b/assets/registrationBlack.png new file mode 100644 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 index 0000000..d6cd3d6 --- /dev/null +++ b/assets/registrationBlack.svg @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/assets/registrationBlue.png b/assets/registrationBlue.png new file mode 100644 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 index 0000000..8e067da --- /dev/null +++ b/assets/registrationBlue.svg @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index 2c3933c..1714ad0 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -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 */ diff --git a/defines.php b/defines.php index 67bce71..4edcd47 100644 --- a/defines.php +++ b/defines.php @@ -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__)); diff --git a/models/front/registrations/cartLinkWidget.php b/models/front/registrations/cartLinkWidget.php index 93ffb2c..aef9c53 100644 --- a/models/front/registrations/cartLinkWidget.php +++ b/models/front/registrations/cartLinkWidget.php @@ -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 "
".print_r($templateData,1)."
"; + // echo "
".print_r($templateData,1)."
"; $view = 'cartLinkWidget'; diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index e777627..aa9a084 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -40,6 +40,7 @@ $loginAccount = ''; $cartId = false; + $haveCart = false; $regEventFirstTime = false; // Have Backbone.js loaded @@ -91,21 +92,44 @@ 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 ); } @@ -268,6 +292,7 @@ // echo '
$regEvent: ' . print_r( $regEvent, true ) . '
'; // Compile template data $templateData = array( + 'haveCart' => $haveCart, 'regEvent' => $regEvent, 'regEventFirstTime' => $regEventFirstTime, 'thisJsUrl' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL . '/js', diff --git a/views/admin/registrations/eventEditLevels.html b/views/admin/registrations/eventEditLevels.html index a1fa14a..0dd78ef 100644 --- a/views/admin/registrations/eventEditLevels.html +++ b/views/admin/registrations/eventEditLevels.html @@ -36,7 +36,7 @@