Created
March 13, 2020 14:18
-
-
Save Yiannistaos/db9cdb7eb6b0bbc5b77c5953f27b140d to your computer and use it in GitHub Desktop.
Woocommerce Subscriptions - Increase the subscription period interval (e.g. Lifetime subscriptions)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * If you would like to increase the subscription period interval (e.g. for lifetime subscriptions). | |
| */ | |
| add_action( 'admin_enqueue_scripts', 'web357_woocommerce_subscription_lifetime' ); | |
| function web357_woocommerce_subscription_lifetime() | |
| { | |
| global $post; | |
| if ( ! wp_script_is( 'jquery', 'done' ) ) { | |
| wp_enqueue_script( 'jquery' ); | |
| } | |
| $subscription_period_interval = get_post_meta( $post->ID, '_subscription_period_interval', true ); | |
| if ($subscription_period_interval > 0) | |
| { | |
| $js_code = <<<JS | |
| jQuery(document).ready(function($){ | |
| var spi_selected = {$subscription_period_interval} === 100 ? ' selected' : ''; | |
| $('#_subscription_period_interval').append('<option value="100"'+spi_selected+'>every 100th</option>'); | |
| }); | |
| JS; | |
| } | |
| wp_add_inline_script( 'jquery-migrate', $js_code ); | |
| } | |
| ?> |
Author
Yiannistaos
commented
Mar 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
