WooCommerce customer order detail in BS Modal

admin

Administrator
Staff member
In a WordPress website running WooCommerce, the user can login in his (default) personal area and display information like:

<ul>
<li>Orders history</li>
<li>Download</li>
<li>Addresses</li>
<li>Edit info</li>
<li>Logout</li>
</ul>

In the <strong>
Code:
orders
</strong> tab, a table is presented by default, showing a list of all orders, with a
Code:
View
button which redirects to the full detail page of that order.

What I'm trying to do is showing that table view in a modal window.

I don't have any problem in showing the modal with the target url loaded in it.
The real problem is that the targeted url is that of the full page which is showing like in an
Code:
&lt;iframe&gt;
, and is not what I want.

I think there is some shortcode allowing to load just that table, or maybe some woocommerce function like
Code:
load_order_content_by_id($id)
?

Can anybody point me in the right direction?

Thanks

<strong>===SOLVED===</strong>

Thanks to Raunak Gupta for pointing me to the right function.
I override the orders.php template, added Modal window html and edited
Code:
$actions
:

Code:
'view'   =&gt; array(
    'url'  =&gt; 'javascript:;',
    'data' =&gt; [
        'order-number' =&gt; $order-&gt;get_order_number()
    ],
    'name' =&gt; __( 'View', 'woocommerce' )
),

and on same file:

Code:
foreach ( $actions as $key =&gt; $action ) {
    echo '&lt;a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '"';
    if(isset($action['data']) &amp;&amp; is_array($action['data'])){
        foreach($action['data'] AS $data_attr=&gt;$data_value){
            echo 'data-' . sanitize_html_class($data_attr) .'="' .esc_html($data_value) . '" ';
        }
    }
    echo '&gt;' . esc_html( $action['name'] ) . '&lt;/a&gt;';
}

A little JS

Code:
$('.woocommerce-MyAccount-orders .button.view').on('click', function(e){
    e.preventDefault();
    var data = {};
    data.action = 'modal_order';
    data.order_number = $(this).data('order-number');

    $.get( ajax_script.ajax_url, data, function(response) {
        $('#modalOrderDetail').modal('show').find('.modal-body').html(response);
    });
});

and hooked into wordpress by
Code:
function.php

Code:
function modal_order() {
    if(is_user_logged_in()) {
        $order_number = $_GET['order_number'];
        woocommerce_order_details_table($order_number);
    }
}

add_action('wp_ajax_modal_order', 'modal_order');
add_action('wp_ajax_nopriv_modal_order', 'modal_order');