Skip to content

Instantly share code, notes, and snippets.

View jrglass's full-sized avatar

Jonathan Glass jrglass

  • Manchester By-The-Sea
View GitHub Profile
@jrglass
jrglass / switch-subscription-link.php
Last active October 23, 2022 06:17 — forked from thenbrent/switch-subscription-link.php
Woocommerce Subscriptions: Output a link to switch a subscription for the current user.
@jrglass
jrglass / cancel-button-snippet.php
Created August 23, 2024 00:15
Woo Subscriptions Function: Custom shortcode for cancel subscription button
function cwpai_cancel_user_subscription_button() {
if ( ! is_user_logged_in() ) {
echo '<p>You need to be logged in to cancel your subscription.</p>';
return;
}
$user_id = get_current_user_id();
$subscriptions = wcs_get_users_subscriptions( $user_id );
if ( empty( $subscriptions ) ) {