I was looking for the same thing but couldn’t find it anywhere so I tried to do it myself. Here’s my code by the way. Hope this helps.
function addCancelButton($subscription) {
$actions = wcs_get_all_user_actions_for_subscription( $subscription, get_current_user_id() );
if(!empty($actions)){
foreach ( $actions as $key => $action ){
if(strtolower($action['name']) == "cancel"){
$cancelLink = esc_url( $action['url'] );
echo "<a href="https://wordpress.stackexchange.com/questions/292246/$cancelLink" class="button cancel">".$action['name']."</a>";
}
}
}
}
add_action( 'woocommerce_my_subscriptions_actions', 'addCancelButton', 10 );
Related Posts:
- Correct function to get the user’s latest Woocommerce Subscription?
- Limit users to one active subscription in WooCommerce Subscriptions? [closed]
- WooCommerce Subscriptions: Show monthly Price for annual Product
- How to get woocommerce subscription next payment date or date when subscription expires in woocommerce_subscription_renewal_payment_complete hook?
- Woocommerce Subscription Pricing/Billing Schedule
- WooCommerce subscription, give option to prorate or not to prorate to user while switching subscription
- Subscription on Checkout
- How to subscribe free subscription on user registration in woocommerce subscription plugin?
- How to change a WooCommerce Subscription Deposit and Monthly Payment? [closed]
- Synchronise Renewals on existing subscriptions [closed]
- WooCommerce Subscriptions: Hide one variation subscription
- wp-cron and woocommerce subscriptions killing performance
- Applying pre-production modifications
- How to send welcome email once user buys the subscription
- How to apply a custom coupon to a WooCommerce Subscription recurring amount?
- How Do I Access Parameters Emitted by an Action?
- How to disable the “Upgrade or Downgrade” button in “My account” of WooCommerce Subscriptions
- Edit woocommerce subscription email
- Membership website with discount on scheduled appointment
- How do I remove the recurring total from thank you for your order email?
- Question about WooCommerce Subscription
- I want to update shipping charge $0 for all Woocommeerce Subscription auto-renewal orders
- WooCommerce: Can’t use wc_get_products for custom REST API endpoints
- How to disable Woocommerce password recovery and use the default WordPress password reset page?
- Display WooCommerce size product attribute on shop page
- WooCommerce add_to_cart() with custom price [closed]
- Declaring custom woocommerce product type as virtual / downloadable only [closed]
- How to remove_action inside class [duplicate]
- Redirect if current user is logged out and current page is /my-account
- WP WPQuery, not running properly in WP CLI
- How to get all products from an order including variations via SQL query?
- What is the action hook for an order that fails on frontend checkout in WooCommerce?
- Woocommerce change tax rate programmaticly
- WooCommerce shipping – Different product different shipping? [closed]
- Remove action added through function
- Filter get_adjacent_post to follow woocommerce product category
- Run function on “Place Order” [closed]
- Add custom order meta to Order Completed email
- Hiding products with a specific tag from WooCommerce main shop page
- Woocommerce Customs Endpoint
- Woocommerce add payment method outside of checkout and my account
- Changing the Woocommerce breadcrumb menu [closed]
- show content of a page built using yootheme builder on different page/template
- How to detect if this post is a woocommerce product?
- Set a custom field to all orders
- Force User Registration before visitng Checkout Page
- Complex price options. Am I stuck with 180 variations?
- Position image widget in mega menu
- short description in shop page after title
- Improve WooCommerce checkout process [closed]
- How can I put the contents of My Account > Order into a separate page, Woocommerce
- WooCommerce Cart URL bug
- WP_Error on attribute + term insert
- change woocommerce product statut (draft ->publish // publish->draft) depends on the month [closed]
- How to add taxonomy term under the thumbnail on woocommerce product page
- woocommerce breadcrumbs in theme [closed]
- Convert WordPress Woocomerce product to WordPress post
- How to set the meta description of a WooCommerce product as its primary category description?
- Create a shortcode for native WooCommerce search form [closed]
- add to cart button not adding products in cart only in safari and edge browser [closed]
- How to use Custom Field to display product brief description in shop page with Woocommerce?
- What happens in the database when you link variations in woocommerce? [closed]
- remove sale price after finished countdown in woocommerce
- Woocommerce. How can I charge a fee from seller
- Add “new” tag for existing products
- How to retrieve a Menu Name by Menu Location with ACF fields
- How to update permalink programmatically?
- Display shipping class in single product page woocommerce
- Is it ok to 301 redirect product-category pages to custom pages?
- how i can limit woo Category number like as ‘posts_per_page’ => -1, but it cannot work please help me
- Woocommerce – Add custom email footer to specific email template
- WooCommerce related product – only show from primary category
- Woocommerce: Variable Product – get variation name
- Forgot password flow does not work, getting email with a link but after clicking link it’s not working
- Html code is not showing in woocommerce shop page on adding in header.php?
- Correct method of reducing the number of images created by WP and Woo together
- How to skip woocommerce checkout after payment page? [closed]
- Product thumbnail size in catalog
- WordPress Migration
- how can i import the csv file in wordpress woocommerce.?
- some products free and some product is not free for shipping
- Importing Attributes in to Woocommerce
- woocomerce products and categories don’t display fixed
- Save Woocomerce discount as percentage to database
- Woocommerce Shipping based on condition and cart value
- How to bypass Woocommerce checkout validation from the plugin? [closed]
- Category with description and thumbnail
- Custom product loop avoiding duplicates
- Woocommerce – Remove ‘Buy Product’ Button + Make Product Thumbnails Clickable
- Issue with Woocommerce and extra field in orders data
- Give auto discount to upsells products
- WooCommerce Table Rates not splitting up
- How can I let the user choose size of a shoe in the store? [closed]
- Hide/show specific products for backend users in woocommerce
- Making product image in woocommerce invoice linkable [closed]
- Woocommerce checkout column total too small can not get it wider [closed]
- error 500 in Back Office when using a woocommerce function in functions.php
- Sort by price when price is set in multiple keys
- Add a custom code with custom link after add to cart for every product
- WooCommerce product permalink based on product’s current category