From ddbf5af2c83e64ab2bf7284dffa101e49e94e453 Mon Sep 17 00:00:00 2001 From: Brian Hogg Date: Tue, 5 Nov 2024 09:51:00 -0500 Subject: [PATCH] Got the first option (free) working. --- assets/js/llms-metabox-product.js | 22 ++++++++++++++++++- includes/admin/views/access-plans/metabox.php | 8 +++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/assets/js/llms-metabox-product.js b/assets/js/llms-metabox-product.js index 834b5453da..8d53e9922e 100644 --- a/assets/js/llms-metabox-product.js +++ b/assets/js/llms-metabox-product.js @@ -180,9 +180,12 @@ // trigger changes on load for all existing plans $( '#llms-access-plans [data-controller-id]' ).trigger( 'change' ); + self.$plan_dialog = new A11yDialog( document.getElementById( 'llms-access-plan-dialog' ) ); + // add a new empty plan interface on new plan button click. $( '#llms-new-access-plan' ).on( 'click', function() { self.init_plan(); + self.$plan_dialog.show(); self.toggle_create_button( 'disable' ); self.toggle_save_button( 'enable' ); setTimeout( function() { @@ -192,7 +195,24 @@ }, 500 ); } ); - self.$plan_dialog = new A11yDialog( document.getElementById( 'llms-access-plan-dialog' ) ); + $( '#llms-access-plan-dialog .llms-access-plan-templates button.template').on( 'click', function( e ) { + e.preventDefault(); + self.$plan_dialog.hide(); + + var $last_access_plan = self.$plans.find( '.llms-access-plan' ).last(); + + switch ( $( this ).attr( 'data-template' ) ) { + case 'free': + $last_access_plan.find('select[name^="_llms_plans["][name$="[is_free]"]').val( 'yes' ).change(); + break; + case 'monthly': + break; + case 'annual': + break; + } + + + } ); self.$plans.sortable( { handle: '.llms-drag-handle', diff --git a/includes/admin/views/access-plans/metabox.php b/includes/admin/views/access-plans/metabox.php index bcbf9dad77..fd0725aaf4 100644 --- a/includes/admin/views/access-plans/metabox.php +++ b/includes/admin/views/access-plans/metabox.php @@ -40,7 +40,7 @@
- @@ -76,15 +76,15 @@ class="llms-dialog-container"

- - -