Jump to content

Add something to meta title if statement


hakeryk2

Recommended Posts

Hello community,

 

I have a question. In my case I would love to achieve this effect. If my product have addition shipping cost = 0 then add to current meta title "- Free shipping"! 

 

Can anyone help how to achieve this effect?

 

Thanks in advance - I think that a lot of people would love to see this in their shops.

Link to comment
Share on other sites

You will need to override the Smarty variable "meta_title" to include text "Free Shipping" in initContent() method of product controller.

 

/controllers/front/ProductController.php

 

It is better to use override 

 

 

/override/controllers/front/ProductController.php

 

 

The code will be something like this

    public function initContent()
    {
        parent::initContent();
        // some logic here to determine if the product is a free shipping
       $this->context->smarty->assign(array('meta_title', $new_meta_title));


......
Link to comment
Share on other sites

Thank You for You reply but I used a little bit stone and stick method :D

 

I edited header.tpl and I replaced 

<title>{$meta_title|escape:'html':'UTF-8'}

with this

<title>{$meta_title|escape:'html':'UTF-8'}
    {if $page_name == 'product'}
        {if $product->additional_shipping_cost == 0.00}
            - Free shipping!
        {/if}
    {/if}
</title>

and it works :)

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...