PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.3.1
Subscriptions for WooCommerce with Stripe Recurring Payments v1.3.1
2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / assets / js / admin.js

admin.js in Subscriptions for WooCommerce with Stripe Recurring Payments 1.3.1, at assets/js/admin.js

82 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery( document ).ready( () => {
2 let sdevs_enable_subscription = jQuery( 'input#subscrpt_enable' );
3 sdevs_enable_subscription.change( () => {
4 if ( sdevs_enable_subscription.is( ':checked' ) ) {
5 jQuery( '.show_if_subscription' ).show();
6 } else {
7 jQuery( '.show_if_subscription' ).hide();
8 }
9 } );
10 if ( sdevs_enable_subscription.is( ':checked' ) ) {
11 jQuery( '.show_if_subscription' ).show();
12 } else {
13 jQuery( '.show_if_subscription' ).hide();
14 }
15
16 jQuery( document ).on( 'woocommerce_variations_loaded', () => {
17 let total_variations = JSON.parse(
18 jQuery( '.woocommerce_variations' ).attr( 'data-total' )
19 );
20 for ( let index = 0; index < total_variations; index++ ) {
21 let element = document.getElementById(
22 'subscrpt_enable[' + index + ']'
23 );
24 if ( element && element.checked ) {
25 jQuery( 'div#show_if_subscription_' + index ).show();
26 } else {
27 jQuery( 'div#show_if_subscription_' + index ).hide();
28 }
29 }
30 } );
31
32 let subscrpt_renewal_process = jQuery( '#subscrpt_renewal_process' );
33 subscrpt_renewal_process.change( () => {
34 if ( subscrpt_renewal_process.val() === 'manual' ) {
35 jQuery( '#sdevs_renewal_cart_tr' ).show();
36 jQuery( '#subscrpt_stripe_auto_renew_tr' ).hide();
37 jQuery( '#subscrpt_auto_renewal_toggle_tr' ).hide();
38 } else {
39 jQuery( '#sdevs_renewal_cart_tr' ).hide();
40 jQuery( '#subscrpt_stripe_auto_renew_tr' ).show();
41 jQuery( '#subscrpt_auto_renewal_toggle_tr' ).show();
42 }
43 } );
44 if ( subscrpt_renewal_process.val() === 'manual' ) {
45 jQuery( '#sdevs_renewal_cart_tr' ).show();
46 jQuery( '#subscrpt_stripe_auto_renew_tr' ).hide();
47 jQuery( '#subscrpt_auto_renewal_toggle_tr' ).hide();
48 } else {
49 jQuery( '#sdevs_renewal_cart_tr' ).hide();
50 jQuery( '#subscrpt_stripe_auto_renew_tr' ).show();
51 jQuery( '#subscrpt_auto_renewal_toggle_tr' ).show();
52 }
53 } );
54
55 function hellochange( index ) {
56 if ( document.getElementById( 'subscrpt_enable[' + index + ']' ).checked ) {
57 jQuery( 'div#show_if_subscription_' + index ).show();
58 } else {
59 jQuery( 'div#show_if_subscription_' + index ).hide();
60 }
61 }
62
63 let subscrpt_product_type = jQuery( '#product-type' );
64 let latest_value_of_subscrpt_product_type = subscrpt_product_type.val();
65
66 subscrpt_product_type.change( () => {
67 if (
68 'simple' === latest_value_of_subscrpt_product_type &&
69 'simple' !== subscrpt_product_type.val() &&
70 'variable' !== subscrpt_product_type.val()
71 ) {
72 const confirmTypeChange = confirm(
73 "Are you sure to change the product type ? If product type changed then You'll lose related subscriptions beacuse of they can't be renewed !"
74 );
75 if ( confirmTypeChange ) {
76 latest_value_of_subscrpt_product_type = subscrpt_product_type.val();
77 } else {
78 subscrpt_product_type.val( 'simple' );
79 }
80 }
81 } );
82