Post by doktorek » Mon Dec 12, 2016 11:15 am

I need this for SEO purposes.
I was thinking for adding a "price" short code of some short to Meta title section or meta description. What would I use in the product edit Meta title section? I tried <?php echo $price; ?> or {price} or {$price} but no success.
What would be a Admin side "code" to show price? If that is even possible. If not, what file do I edit and put price meta tag? I know some seo modules have predefined codes. How do they create it?
ps. I know I can always just type in the price when creating item but I want it to change when I update price or when its discounted.

New member


Thu Apr 28, 2016 8:40 pm

Post by opencartmart » Mon Dec 12, 2016 3:25 pm

Lets consider the placeholder is {price}. So whenever you enter meta title for a product, you will put {price} inside it.
Now in the file catalog/controller/product/product.php and find the line $this->document->setTitle($product_info['meta_title']); and add following lines of code before it

Code: Select all

$price = ((float)$product_info['special']) ? $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']) : 
         $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
$product_info['meta_title'] = str_replace('{price}', $price, $product_info['meta_title']);

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart

Active Member


Wed Oct 02, 2013 3:59 am

Post by sajuk » Sat Jun 29, 2019 12:07 am


I have tried this code on OC but does not work,, No changes seen to the meta title



Tue Feb 07, 2017 7:10 pm
Who is online

Users browsing this forum: No registered users and 10 guests