Support » Developing with WordPress » Buttons that execute a .php file instead of a URL

  • Resolved Alex


    Hello everyone! I am pretty new to developing with wordpress and php, and new to developing in general. I am working on a plugin that uses woocommerce. In my woocommerce orders page, I am trying to make a button that updates the payment status of all items (or at least one at a time). I’ve figured out how to add buttons for the orders, though they arent exactly how I want them, I think it is an ok start, but what I have not been able to figure out is how to trigger a .php file to be executed instead of taking the user to some URL. I’ve put the code down below that sets the buttons and can trigger, when clicked, a different URL to take the user.
    What I want to happen is:
    1) Click button
    2) Open and execute .php file I have written to handle the status updates
    What I can make happen:
    1) Click button
    2) Link to another page in my website, which I can pass variables to to do things like open the checkout page with some specific product in the cart and the user just needs to provide a payment method and the product is ordered.

    I feel like I am missing html/css/php knowledge to make this happen. I would love if someone could point me in the right direction to solve how to execute a file instead of linking to a new URL. The only solution I can think of (which I cannot do easily) is make a webpage that cannot be accessed directly but when I press this button, gets linked to and executes my script. Thank you!

    function add_button($actions, $order){
    $actions[‘Status Update’] = array(
    ‘url’ => ‘my_URL’, //Here is the URL that is linked
    ‘name’ => __(‘Status Update’, ‘woocommerce’),
    return $actions;
    add_filter(‘woocommerce_my_account_my_orders_actions’, ‘add_button’, 50, 2);

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Buttons that execute a .php file instead of a URL’ is closed to new replies.