Jump to content

How do I add a row in order detail section in front end ?


Codify Solutions

Recommended Posts

Hello everyone,

 

I stuck with one of the problem I am creating a module , which will have option on shipping page. I used "displayCarrierList" hook to display my option/selection after carrierlist. It appears. My option has checkbox and a price.

 

What I want if I select that option on shipping page it will appear on order total section on the next page and it must maintain rest of the orders in email, admin orders etc. Which hook I have to use for that ?

 

I found "displayOrderDetail" hook but I didn't get any help that how I can use that. I tried to use also but it didn't return anything from that hook in order detail section.

 

Please give input if possible and thx in advanced :)

 

 

 

Link to comment
Share on other sites

There is no hook there unfortunately. What you can do is hooking to the shopping cart hook (displayShopping cart, or without display, I forgot)

Then use js to append your row to it

Hi,

 

As you said to use js to append row after tax, I did that successfully. What I did on hookHeader I put code to check page

and after that I write js like below to add a row :

 

$my_fee_row = '<tr class=\"cart_total_my_fee\"><td class=\"text-right\" colspan=\"4\">My Fee: </td><td id=\"total_my_fee\" class=\"price\" colspan=\"2\">$10</td></tr>';

            return '

                <script>

                    jQuery(document).ready(function () {    

                        $( ".cart_total_tax" ).after("'.$my_fee_row.'")

                    })

                </script>';

 

It worked and add a row after tax. But further I want to add fee amount to the total as well as it must maintain "My fee" in order total section. e.g it shows in admin on my account order histroy, order emails as well.

 

So for to do so like above , shall I need to override controller or classes ?

 

 

Thanks!

Link to comment
Share on other sites

It depends on how you calculate the fee. If it's not added to the total already, it will probably not in the order either. Is it? Otherwise you need to append it to Cart::GetOrderTotal (with an override)

Thanks NemoPS for your quick reply. Let me try to override GetOrderTotal in order to show my field in order total section and do calculation accordingly. I will do and get back to you :)

 

Thanks again :)

Link to comment
Share on other sites

Well, I tried a lot order total can be change use override in the module but I thought that for the time being I have displayed my price in order total section

but what about in admin, invoice order email and order history page of my account. I can't use js / jquery all over those places.

 

So I am finding something permanent way to do it so it appears in order total in all over the places like "Total TAX" etc.

 

Please share ideas if someone knows. I am stuck on it last 2 days and its really frustrating :(.

 

Thanks in Advanced.

Link to comment
Share on other sites

Hello,

Well I found a way to add a row there in order total section. I don't know if its the correct way or not
I did it with front end and admin section as well.

Hope it helps someone.

For Admin
with DisplayAdminOrder hook
$admin_extra_total_row = '<tr class=\"cart_total_extra\"><td class=\"text-right\">extra Fee: </td><td class=\"amount text-right nowrap\">'.$fee.'</td></tr>';
            return '
                <script>
                    jQuery(document).ready(function () {    
                        $( "#total_taxes" ).after("'.$admin_extra_total_row.'")
                    })
                </script>';

For Front end:

I checked the page where I want to place. For example I want to place on step 3
used hook DisplayHeader

        if (($check_order_page == 'order' and $_GET['step'] == '3') or ($check_order_page == 'order' and $_GET['step'] == '')) {        
            $extra_fee =  Tools::displayPrice(Configuration::get('EXTRA_FEE'), $currency);
            $extra_total_row = '<tr class=\"cart_total_extra_fee\"><td class=\"text-right\" colspan=\"4\">Extra Fee: </td><td id=\"total_extra_fee\" class=\"price\" colspan=\"2\">'.$wli_price.'</td></tr>';
            return '
                <script>
                    jQuery(document).ready(function () {    
                        $( ".cart_total_tax" ).after("'.$extra_total_row.'")
                    })
                </script>';
            
        }        


Hope if helps someone. other suggestions and ideas are welcome. I am also want to do with Invoice, email etc. for now I don't know how to do it
and what hooks I have to be used with it but I will get back for this if I get anything.
If someone have idea so please share.

Thanks very much. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...