I had a similar problem to the one you have described. In the end i had to hook into woocommerce_subscription_status_active from which you can access the related $subscription object as a single argument. If you need any further details from the standard $order object also then you can access that via $subscription->get_parent() within your function.
The issue seems to be that the end date value attached to a subscription only gets set really late in the order of hooks/actions, so any of the standard hooks you would usually use post-checkout may not have access to the subscription dates yet since they are still not set.
I tried all of the following before i got it to work for me;
woocommerce_thankyou
woocommerce_payment_complete
woocommerce_checkout_order_processed
woocommerce_order_status_completed
woocommerce_subscription_payment_complete
and in each case the end date (and next payment date) were both empty even though i could see them in the wordpress admin later on.
Related Posts:
- Use wc_enqueue_js only on specific pages – nested add_action
- Automated Cart Update With Alert Box Each Time
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to auto fetch customer details in Woocommerce in checkout page
- I want to add custom add to cart link [closed]
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Change product_base programmatically
- Can a plugin redirect product page based on IF condition?
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- custom post type with role Vendor
- Woocommerce custom Plugin in wordpress [closed]
- Add a custom WooCommerce settings tab with sections
- Payment field disappears on custom Paypal plugin
- I am having errors with checkout on wordpress
- product_type_options get saved value [closed]
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- Looping through and combining calls to Woocommerce REST API
- How to import woocommerce custom fields data into another site?
- How do I remove an action hook inside a class that is called by another class?
- How keep woocommerce users separeted in multisite install and keep admins on network
- Custom field fetch error on woocommerce pdf invoice
- Woocommerce Convert existing order to the cart
- How to change product SKU’s in bulk with a plugin
- How to add product in woocommerce with php code [closed]
- Should I use spl_autoload_register() in my plugin?
- How can I save a multiple select array with the settings API for a plug-in options page?
- Using register_activation_hook in classes
- Is there a way for a plugin to add an attribute to the tag of a theme?
- How to add date range in woocommerce with code
- Creating custom Woocommerce attribute taxonomies from a plugin
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- How to get the original price of the product in woocommerce?
- How to Remove a Filter from the Admin List Table?
- Woocommerce, recognize the loop of related products
- Remove commas from WooCommerce checkout addresses fields
- My shortcode is showing up twice
- Database “Migration” for Plugins?
- WooCommerce Link to Product Category
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Append a term to WooCommerce product existing product category terms
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Making Quote Plugin more efficient
- Writing scripts using WordPress / WooCommerce classes?
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- How to make custom total price reactive in navigation
- Change description on specific WooCommerce product status change
- Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price
- Will simple function names in a class structure conflict with other plugins?
- How to add a second ‘place order’ button in WooCommerce [closed]
- Instantiate class to be available to all plugin functions
- How to test nonce with AJAX – Plugin development
- WP nonce invalid
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- Custom filter in admin edit custom post type responding with invalid post type?
- How to find error in my code when the error message is pointing to WP core file?
- How to access global variable $menu inside a class function
- Custom user login page by creating a plugin
- Woocommerce product variation backorder
- Status 400 for AJAX POST Request with admin-ajax.php
- Singelton class does not work, multiple initialization on page reload
- How to upload a file to a folder named after the user_id via plugin
- WooCommerce Webhooks not firing because of error in wp-includes/meta.php
- developing a wordpress plugin, have a few PHP Woocommerce related coding questions
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- WooCommerce: How can I get orders with a custom ID in order meta data object?
- adjust section according to country?
- Sum the total amount of a specific product purchased per user and display in table
- Redirect to another page using contact form 7? [closed]
- Custom plugin settings link doesn’t append current class to menu item when visited? Why?
- How to hook code to show after the_content?
- woocommerce related product title length
- Woocommerce disable order item link (backend) [closed]
- Post form – AJAX won’t upload featured image – Plugin development
- Set all WooCommerce Products to Simple, Virtual & Downloadable
- How do I programmatically add ‘reviews_allowed’ to WooCommerce product?
- Problem with my Login Plugin
- How to return html as a string from php for WordPress
- How to override WooCommerce Order Item Meta with data from Cart?
- Taxonomy Child Term, Counter is staying on 0
- How can i style “echo apply_filters”
- How to properly create multiple conditions to redirect users roles to different pages
- Help on Wp_query to print an term
- Upload images from one server to an other in wordpress
- Problem with conditional woocommerce custom checkout field
- How do I prevent a folder from reappearing in my home directory?
- How to use Amazon Elastic Transcoder from WordPress using AWS SDK for PHP?
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- Add specific phrase after every product title including the discounted price? [closed]
- Display Sale Price Before Regular Price (WooCommerce)
- How do I change the Go To Categories link in the term_updated_messages
- WooCommerce – Show ‘Sales’ badge on variable products where only some variations have sales price [closed]
- How to create a container in php then customise it in CSS
- Displaying custom meta box value in a custom post page
- Create a custom plugin with dynamic child pages listing database records
- Woocommerce – how can i add items to cart using onclick – multiple items at once with custom prices