Remove print invoice from order details page

Im facing a hard time to comprehend the concept of using hooks.

For example i have to remove print invoice without touch the core files and add the change to my changes addon folder, that part I know very good.

But, using hooks to reflect those things to the view from the changes addon, that i dont know.

Im using cscart free version and not every fn_ functions works on my version.

would be good to have an option in cs cart to show/hide that link

1 Like

You should use not hooks, but overrides. It is required to override the following template

design/themes/responsive/templates/addons/pdf_documents/hooks/orders/details_tools.post.tpl

Changes in the core files are not required

1 Like

So, I have overridden the file details_tools.post.tpl by creating a file in the same directory called details_tools.post.override.tpl

{$print_pdf_order = __("print_pdf_invoice")}
{if $status_settings.appearance_type == "C" && $order_info.doc_ids[$status_settings.appearance_type]}
    {$print_pdf_order = __("print_pdf_credit_memo")}
{elseif $status_settings.appearance_type == "O"}
    {$print_pdf_order = __("print_pdf_order_details")}
{/if}

{if isset($tools)}
    {foreach from=$tools item="tool"}
        {if $tool != 'print_invoice'}
            {include file="design/themes/responsive/templates/addons/pdf_documents/hooks/orders/{$tool}.tpl"
            tools_count=$tools_count order_info=$order_info}
        {/if}
    {/foreach}
{else}
    {foreach from=$default_tools item="tool"}
        {if $tool !='print_invoice'}
            {include file="design/themes/responsive/templates/addons/pdf_documents/hooks/orders/{$tool}.tpl"
            tools_count=$tools_count order_info=$order_info}
        {/if}
    {/foreach}
{/if}

{include file="buttons/button.tpl"
    but_role="text"
    but_meta="orders-print__pdf ty-btn__text cm-no-ajax"
    but_text=$print_pdf_order
    but_href="orders.print_invoice?order_id={$order_info.order_id}&pdf=1"
    but_icon="ty-icon-doc-text orders-print__icon"
}

It should reflect the results but nothing changes
I have cleared the cache in browser, administrative, the cache folder but nothing I also used this way in clearing cache cc=&ctpl=

What am I missing???

im using cscart free version, also I have installed PDF documents addon

The path and file name should be

design/themes/responsive/templates/addons/my_changes/overrides/addons/pdf_documents/hooks/orders/details_tools.post.tpl

1 Like

Okay, done that the override file started to make changes (I’m using localhost to test my code) but then suddenly stopped reflecting then I went to my development site anything I type in my override file it reflects, so what is wrong with my localhost??

Another thing I wanted to check my version of the Smarty template so I wrote this code

{if $smarty.version >= '3.0.0'}
    <p>Smarty version 3 or higher is being used.</p>
{else}
    <p>Smarty version 2 or lower is being used.</p>
{/if}

It uses version 3, plus I have this code to remove the print invoice

{if isset($tools)}
   {assign var="tools" value=$tools|without:'print_invoice'}
    {assign var="tools_count" value=$tools_count-1}
   {foreach from=$tools item="tool"}
       {if $tool != 'print_invoice'}
            {include file="design/themes/responsive/templates/addons/pdf_documents/hooks/orders/{$tool}.tpl"
            tools_count=$tools_count order_info=$order_info}
        {/if}
   {/foreach}
{/if}

But it says without modifier is unknown even though the Smarty template starting from version 3 does support without modifier, what do I have to do to solve this challenge and prevent this from happening?

Clear cs-cart cache.

Maybe it isn’t available standard in cs-cart, you can check, goto ‘app/lib/vendor/smarty/smarty/libs/plugins/modifier.without.php’. If missing, you can obtain it from the official Smarty repository or another compatible CS-Cart installation.

If still not work, it is not advisable but you could modify CS-Cart core files:

a. Locate the file ‘app/Tygh/SmartyEngine/Core.php’ in your CS-Cart installation.

b. Open the file and search for the following line:

phpCopy code

$smarty->addPluginsDir(Registry::get('config.dir.functions') . 'smarty_plugins');

c. Add the following line just below it:

phpCopy code

$smarty->addPluginsDir(Registry::get('config.dir.lib') . 'vendor/smarty/smarty/libs/plugins');

clear the cache and try again.

1 Like

Looking at the Smarty documentation, there is no such modifier or function:

https://smarty-php.github.io/smarty/4.x/designers/language-modifiers/

1 Like

Looks like you wanted to use default not without? Please confirm

1 Like

I have open the link was provided by @CS-Cart_team

And no I didn’t wanted to use default.
I’m looking for a built in function or a variable that would help me to remove print invoice

I only looking for a way to remove the print invoice button from the order details page

@CS-Cart_team I was wondering why not create a setting in cs cart so show hide that link.
It would be useful also to hide packing slip as I dont use that feature.
It is more elegant to have options like I mentioned and teh platform will be more stable consistent without changes in code in multiple places and when you upgrade don t need to worry that you have changes everywhere. Let’s improve cs cart and improve experience of us customer of our clients also

2 Likes

Thank you for the offer, @gurdji but I’m afraid that adding separate settings for each existing corner of CS-Cart contradicts the idea of our product “Launch Fast”, as it will increase the difficulty of the product for new customers. So I’m afraid such changes won’t be made in the near future.

As for the changes, most of them can be achieved with using hooks, so there is nothing to worry about during the upgrade. If there are not enough hooks to achieve a specific result you want, please let me know, I will check if there really is no way and notify the developers to create a new hook for that case.

@Aya in order to hide the Print invoice menu item, you can create the following override (I’ll be using the My changes add-on for this example:
design/backend/templates/addons/my_changes/hooks/orders/details_tools.override.tpl with the following content:

<li>{btn type="list" text=__("print_packing_slip") href="orders.print_packing_slip?order_id=`$order_info.order_id`" class="cm-new-window"}</li>
<li>{btn type="list" text=__("edit_order") href="order_management.edit?order_id=`$order_info.order_id`"}</li>
<li>{btn type="list" text=__("copy") href="order_management.edit?order_id=`$order_info.order_id`&copy=1"}</li>
<li>
    {btn type="list"
    text=__("delete")
    href="orders.delete?order_id={$order_info.order_id}&redirect_url=orders.manage"
    class="cm-confirm"
    method="POST"
    }
</li>
{$smarty.capture.adv_tools nofilter}

The code was taken from the design/backend/templates/views/orders/details.tpl template, where I simply removed everything that corresponded to the invoice.

I hope it will help you.

1 Like

Thank you for your feedback!
I see things in a different way. Launch product “Launch Fast” means also setting by default so diplay as it is now in cs cart and the ones who need to hide some links to use the setting to hide them

2 Likes

Can you explain why you took from details.tpl? because aren’t we supposed to override the details_tools.post.tpl because it is responsible for displaying the tools section?

Also, I have this code that responsible for displaying print invoice in the details.tpl, the one you provided I don’t have

 {capture name="order_actions"}
            {if $view_only != "Y"}
                <div class="ty-orders__actions">
                    {hook name="orders:details_tools"}
                        {$print_order = __("print_invoice")}
                        {if $status_settings.appearance_type == "C" && $order_info.doc_ids[$status_settings.appearance_type]}
                            {$print_order = __("print_credit_memo")}
                        {elseif $status_settings.appearance_type == "O"}
                            {$print_order = __("print_order_details")}
                        {/if}
                        {hook name="my_changes:order_details_before_invoice_links"}
                        {include file="buttons/button.tpl" but_role="text" but_text=$print_order but_href="orders.print_invoice?order_id=`$order_info.order_id`" but_meta="cm-new-window ty-btn__text" but_icon="ty-icon-print orders-print__icon" items_hook="fn_my_changes_remove_print_invoice"}
                        {/hook}
                    {/hook}

                    <div class="ty-orders__actions-right">
                        {if $view_only != "Y"}
                            {hook name="orders:details_bullets"}
                            {/hook}
                        {/if}

                        {include file="buttons/button.tpl" but_meta="ty-btn__text" but_role="text" but_text=__("re_order") but_href="orders.reorder?order_id=`$order_info.order_id`" but_icon="ty-orders__actions-icon ty-icon-cw"}
                    </div>

                </div>
            {/if}
        {/capture}

Im facing an issue with the btn tag after I added the code provided

<li>{btn type="list" text=__("print_packing_slip") href="orders.print_packing_slip?order_id=`$order_info.order_id`" class="cm-new-window"}</li>
<li>{btn type="list" text=__("edit_order") href="order_management.edit?order_id=`$order_info.order_id`"}</li>
<li>{btn type="list" text=__("copy") href="order_management.edit?order_id=`$order_info.order_id`&copy=1"}</li>
<li>
    {btn type="list"
    text=__("delete")
    href="orders.delete?order_id={$order_info.order_id}&redirect_url=orders.manage"
    class="cm-confirm"
    method="POST"
    }
</li>
{$smarty.capture.adv_tools nofilter}

this is the error and the screenshot

Syntax error in template “tygh:/home/riwayaco/public_html/development/design/themes/responsive/templates/addons/my_changes/overrides/addons/pdf_documents/hooks/orders/details_tools.post.tpl” on line 7 “{btn type=“list” text=__(“print_packing_slip”) href=“orders.print_packing_slip?order_id=$order_info.order_id” class=“cm-new-window”}” unknown tag ‘btn’

So I tried to locate the btn tag it is in

{include file=“design/backend/templates/buttons/helpers.tpl”}

correct me if I’m wrong and if so please provide the correct link.

here is the full code im using

{include file="design/backend/templates/buttons/helpers.tpl"}

<li>{btn type="list" text=__("print_packing_slip") href="orders.print_packing_slip?order_id=`$order_info.order_id`"
    class="cm-new-window"}
</li>
<li>{btn type="list" text=__("edit_order") href="order_management.edit?order_id=`$order_info.order_id`"}</li>
<li>{btn type="list" text=__("copy") href="order_management.edit?order_id=`$order_info.order_id`&copy=1"}</li>
<li>
                {btn type="list"
                    text=__("delete")
                    href="orders.delete?order_id={$order_info.order_id}&redirect_url=orders.manage"
                    class="cm-confirm"
                    method="POST"}
</li>
{$smarty.capture.adv_tools nofilter}

this file path of my override folder

design/themes/responsive/templates/addons/my_changes/overrides/addons/pdf_documents/hooks/orders/details_tools.post.tpl

The hook orders:details_tools is located in the details.tpl template, so that is why I took the code from it.

This is from the front end template. Could you please let me know, where do you trying to hide those buttons, from the frontend or from the backend?

Yes, you are correct, the btn function is defined in the design/backend/templates/buttons/helpers.tpl template.

1 Like

I’m trying to remove/hide the button of the order details page that exists on the front end.

please review the image below.

I apologize for the late reply, thank you @chickentwisty for your help

1 Like

Also when I add this code it takes so much time in reloading to view the changes on this page, why??
I have cleared all caching and everything called cache.

<li>{btn type="list" text=__("print_packing_slip") href="orders.print_packing_slip?order_id=`$order_info.order_id`"
    class="cm-new-window"}
</li>
<li>{btn type="list" text=__("edit_order") href="order_management.edit?order_id=`$order_info.order_id`"}</li>
<li>{btn type="list" text=__("copy") href="order_management.edit?order_id=`$order_info.order_id`&copy=1"}</li>
<li>
                {btn type="list"
                    text=__("delete")
                    href="orders.delete?order_id={$order_info.order_id}&redirect_url=orders.manage"
                    class="cm-confirm"
                    method="POST"}
</li>
{$smarty.capture.adv_tools nofilter}

Take into account I’m new to the Smarty template, my work experience has always been with Laravel.