Im using woocommerce for a website and where the client sells software. One of the options I have to add is request a license button on my account page.
I already have the function that does this in a file request-license.php in the woocommerce folder in my theme but I’m having problems to add a new point.
when you click view the endpoint calls view-order.php file so I want to call request-license when the request license button is clicked.
here is how is called
<?php
$actions = array();
if ( in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ) ) ) {
$actions['pay'] = array(
'url' => $order->get_checkout_payment_url(),
'name' => __( 'Pay', 'woocommerce' )
);
}
if ( in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
$actions['cancel'] = array(
'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
'name' => __( 'Cancel', 'woocommerce' )
);
}
$actions['license'] = array(
'url' => $order->get_request_license_url(),
'name' => __( 'Request License', 'woocommerce' )
);
$actions['view'] = array(
'url' => $order->get_view_order_url(),
'name' => __( 'View', 'woocommerce' )
);
$actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order );
if ( $actions ) {
foreach ( $actions as $key => $action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
?>
I know I have to create the get_request_license_url() function but not sure how to implement it. Hope I can have some help here