0

I am using Woocommerce Subscription extension, and I would like to display the current subscription orders located in the my-subscriptions.php template on the orders.php template (normal woocommerce template).

When I copy the code over, I get the message of "Undefined variable: subscriptions".

How do I get round this?

EDIT: My files are as follows :

Orders.php - https://pastebin.com/0fxgAjyp
my-subscriptions.php - https://pastebin.com/XhbWEBSp
RForster
  • 11
  • 4

1 Answers1

0

I think you are accessing the variable inside the function. Please try with global

my-subscriptions.php

function custom_func(){
  global $subscriptions;
}

orders.php

include `my-subscriptions.php`;
 global $subscriptions;
echo   $subscriptions;
Arshid KV
  • 9,631
  • 3
  • 35
  • 36
  • thank you for this - i have tried but did not work, i have put links to my two files in pastebin in the original post. there will be some code there that is irrelevant – RForster May 16 '18 at 12:37
  • For anyone interested I got round this with the following: `$mainContent = jQuery('#load-subscription'); $mainContent.load('/my-account/subscriptions/ #mycurrentsubscription > *', function() { ...code here to do stuff }` – RForster May 17 '18 at 13:15