From 42dd4e26d10b5a5c57a89106aeb6e68d7e3c7a8f Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 27 Oct 2017 12:05:16 -0400 Subject: [PATCH] Adding Ajax action for refreshing the registration widget. Wrap the widget into div with id. Setup a global javascript object with function to update the widget. --- models/admin/ajax/cartLinkWidget.php | 79 +++++++++ setup/validActions.php | 1 + views/front/registrations/cartLinkWidget.html | 154 ++++++++++-------- 3 files changed, 163 insertions(+), 71 deletions(-) create mode 100644 models/admin/ajax/cartLinkWidget.php diff --git a/models/admin/ajax/cartLinkWidget.php b/models/admin/ajax/cartLinkWidget.php new file mode 100644 index 0000000..1dedda5 --- /dev/null +++ b/models/admin/ajax/cartLinkWidget.php @@ -0,0 +1,79 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/models/front/registrations/cartLinkWidget.php'; +/** + * Steve Note... + * + * You can get to this using the following URL. + * + * {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=login + * + * You should be able to do this as POST or GET and should be able to add and read additional parameters. + * I added a "mystuff" parameter to the URL above and it does output from the code in the + * modelAction() function below. + * + * To add another model under models/admin/ajax all you need to do is create it and add it to the + * setup/validActions.php file. + * + */ + +/** + * This class performs the work of handling images passed to it via + * an AJAX call that goes through the WorPress AJAX Handler. + * + */ +class GlmMembersAdmin_ajax_cartLinkWidget extends GlmMembersFront_registrations_cartLinkWidget +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for data class + // parent::__construct(false, false); + + } + +} diff --git a/setup/validActions.php b/setup/validActions.php index 2e6834a..063f008 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -63,6 +63,7 @@ $glmMembersRegistrationsAddOnValidActions = array( 'account' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'regAdmin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'regFront' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'cartLinkWidget' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, ), 'registrations' => array( 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, diff --git a/views/front/registrations/cartLinkWidget.html b/views/front/registrations/cartLinkWidget.html index 6ee49d2..82cc733 100644 --- a/views/front/registrations/cartLinkWidget.html +++ b/views/front/registrations/cartLinkWidget.html @@ -1,78 +1,90 @@ -{if $haveCart} - -