Run Export from a Function
-
Hi guys!
I am customizing my website and I would like to be able to run an Export from within a function that I am writing. How can I make the call for this?
Thank you very much in advance!
-
hi
Could you try this code ?
thanks, Alex$_REQUEST['profile'] = 'now'; WC_Order_Export_Ajax::run_one_job(); die();Hi Alex!
I tried the code, but I get this php error:
“Call to undefined method WC_Order_Export_Ajax::run_one_job()”
What could be the issue?
Thanks!
Tamashi Tamas
The plugin loads in backend context only, by default.
Can it be a reason ?
-
This reply was modified 6 years, 7 months ago by
algol.plus.
Could you edit file “woo-order-export-lite.php” and comment these lines ?
if ( ! woe_check_running_options() ) { return; } //don't load for frontend !Will you still see the error ?
Hi Alex
I am running the code from the functions.php and it is triggered by a button in the backend.
I did what you said and I still get the same error.
What I want basically is to have an “Export” button on the Order List Page in the admin panel, that downloads the xls with the settings defined by the plugin page.
Can you try this solution https://wordpress.org/support/topic/copy-export-button-to-frontend/#post-11644593 ?
I already did.
Unfortunately nothing is happening when I push the button.
try to replace
action=”/wp-admin/admin-ajax.php”
with full urlOk, I did. Unfortunately still nothing is happening.
is there js code which prevents submitting the form?
You can construct link too , something like
http://yoursite.com/wp-admin/admin-ajax.php?action=order_exporter&method=run_one_job&profile=now
I checked but I didn’t find any code preventing it. I disabled all plugins except Woocommerce and Advanced Order Export and still nothing.
I tried to construct the link as well and it gives an empty white page with ‘0’ on it.
UPDATE
I tried the link again and something happened, because now it is working. The function is still not working though. How could I assign the link elegantly to a button then?
-
This reply was modified 6 years, 7 months ago by
tom3r.
the link/button works only if you’re logged in.
https://www.w3docs.com/snippets/html/how-to-create-an-html-button-that-acts-like-a-link.html
That is no problem, in fact it should only work when user is logged in and clicks the button on the admin panel. Thanks for the link.
Do you have any idea why the function call is not working? That would be the best way to go about it.
I can’t write JS code for you š
run Firefox debugger and check event listeners for the form/button
I am not sure what am I looking at in the event listener, or how to find an indication to the form.
Well, at least the link construct works and I can have the job done that way. Thanks a lot for everything Alex!
-
This reply was modified 6 years, 7 months ago by
The topic ‘Run Export from a Function’ is closed to new replies.