Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Last active November 29, 2018 17:17
Show Gist options
  • Save jrick1229/9911d03ecba9a923c1ddffc196f19517 to your computer and use it in GitHub Desktop.
Save jrick1229/9911d03ecba9a923c1ddffc196f19517 to your computer and use it in GitHub Desktop.
renewal_choice_type_cart
<?php
function renewal_choice_type_cart() {
?>
<div class="renewal-cart-choice-field">
<label for="renewal-cart-choice">Renewal method:</label>
<select id="renewal-cart-choice" name="renewal-cart-choice">
<option value="auto">Automatic Renewal</option>
<option value="manual">Manual Renewal</option>
</select>
</div>
<?php
if ($_POST['renewal-cart-choice'] === 'auto') {
$subscription->set_requires_manual_renewal( false );
}
elseif ( $_POST['renewal-cart-choice'] === 'manual' ) {
$subscription->set_requires_manual_renewal( true );
}
}
add_action( 'woocommerce_cart_contents', 'renewal_choice_type_cart', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment