Knowband Blog | Ecommerce Modules

How to open “Terms & Conditions” link in a new tab on checkout page (OpenCart)?

Objectives of the blog

After reading this blog we will be able to add the html attribute in “Terms and Condition” link to open it in new tab.

Current Scenario

Presently, The “Terms & Conditions” link shows entire page in a popup window on checkout page of Opencart. But for “Terms & Conditions” having custom texts and html we want to open the same link in new tab as the content of page may not look appropriate in pop-up.

Refer below screenshot for the same-

 

Procedure:

STEP 1:-

Terms and Conditions link displayed on default checkout page resides in catalog/view/theme/default/template/checkout/payment_method.tpl, Block of code used for link is as below :

 

<div class="pull-right"><?php echo $text_agree; ?>

 

$text_agree is the variable that prints the link on page and this variable is set at location catalog/controller/checkout/payment_method.php

Variable definition looks as below :-

$data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_checkout_id'), true), $information_info['title'], $information_info['title']);

 

You need to replace this definition with new one –

$data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information', 'information_id=5' , true), $information_info['title'], $information_info['title']);

 

we have replaced the href :-

https://your_store_url/index.php?route=information/information/agree&information_id=5

 

that does not contain header, footer and other content with

https://your_store_url.com/index.php?route=information/information&information_id=5

 

which contains header, footer and other content in the page.

STEP 2 :-

Lastly, you have to edit the definition of link in catalog/language/en-gb/checkout/checkout.php

In above file location there would be a definition as below : –

 

$_['text_agree'] = 'I have read and agree to the <a href="%s" class="agree"><b>%s</b></a>';

 

We have to add a attribute  target=”_blank” and remove  class=”agree” in above anchor tag to open the link in new tab. The new definition of text_agree key would be as follow:-

$_['text_agree'] = 'I have read and agree to the <a href="%s" target="_blank"><b>%s</b></a>';

 

After saving the above changes, we will be able to open the “Terms & Conditions” link in a new tab on checkout page.

Please refer to the screenshot below :-

 

Summary:

After following above changes, we will be able to open the “Terms & Conditions” link in a new tab on checkout page.

NOTE: This demonstration is for default template but this will work same for other templates having similar code.