Jump to content

Change <title> from the cart template?


Regia

Recommended Posts

Hi,

I am looking for a way to change the title of the page from the cart template - is it possible to "force" a change? Currently <title> says "Shopping cart - [site name]" - I can change the text in the translation file, but it will not work in my case, as I have two product offerings with different cart templates, and if I change the text this way , then the new title will be the same of both products - but my goal is to have different titles.

Link to comment
Share on other sites

Look into the clientAreaPage hook point. You should be able to use a conditional statement to check for the product_id or possibly the cart template and set the $title variable accordingly.

 

Thanks.

Where I can find the cart template variable name? As the $template returns my page template name, and not my cart template name.

 

Also, I tried to test this in the hooks file:

$pagetitle = "Споделен хостинг - РЕГИЯ";

 

But it doesnt set up the page title. Am I doing something wrong?

Link to comment
Share on other sites

What you want to do is return an array with a containing new variables for pagetitle and companyname since the title is displayed as {$pagetitle} - {$companyname}.

 

return array("pagetitle" => "custom page title", "companyname" =>"custom company name");

 

In your hook you can check if it is a shopping cart page by looking at the filename variable, it will show cart or you can look at the pagetitle variable before you change it.

Link to comment
Share on other sites

Put {debug} at the top of your header.tpl file. Then open your site in a browser. A popup window will show you all the variables you have to work with in your page.

 

All the available variables are held in an array called $vars.

 

I think there will be a $carttpl var and a $productsinfo array, that may be useful to determine what page you are on.

 

To modify from a hooks file you need to do $vars['pagetitle'] = 'abc123';

Link to comment
Share on other sites

Thanks.

It works perfectly now. Here is the code, in case someone needs a similar solution:

 

<?php

function change_page_title($vars) {

 

$pagetitle = $vars['pagetitle'];

$template = $vars['carttpl'];

if ($template=="order for template")

{

return array("pagetitle" => "Page title", "companyname" =>"Company name");

}

 

 

}

add_hook("ClientAreaPage",1,"change_page_title");

 

?>

Link to comment
Share on other sites

  • 8 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated