Skip to content

Commit

Permalink
Got the first option (free) working.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhogg committed Nov 5, 2024
1 parent 8be8db9 commit ddbf5af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
22 changes: 21 additions & 1 deletion assets/js/llms-metabox-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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',
Expand Down
8 changes: 4 additions & 4 deletions includes/admin/views/access-plans/metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<div class="llms-plans-actions">
<div class="d-all">
<button class="llms-button-secondary small" id="llms-new-access-plan" type="button" data-a11y-dialog-show="llms-access-plan-dialog">
<button class="llms-button-secondary small" id="llms-new-access-plan" type="button">
<span class="fa fa-plus"></span>
<?php esc_html_e( 'Add New Plan', 'lifterlms' ); ?>
</button>
Expand Down Expand Up @@ -76,15 +76,15 @@ class="llms-dialog-container"
<h1 id="llms-access-plan-dialog-title"><?php echo esc_html( __( 'What type of Access Plan do you want to create?', 'lifterlms' ) ); ?></h1>

<div class="llms-access-plan-templates">
<button class="template">
<button class="template" data-template="free">
<strong>Free</strong>
<span>Free access that never expires.</span>
</button>
<button class="template">
<button class="template" data-template="monthly">
<strong>Monthly</strong>
<span>Charge a recurring monthly subscription that never ends.</span>
</button>
<button class="template">
<button class="template" data-template="annual">
<strong>Annual</strong>
<span>Charge a recurring annual subscription that never ends.</span>
</button>
Expand Down

0 comments on commit ddbf5af

Please sign in to comment.