Latest News: (loading..)
Jack_mcs

Header Tags SEO

8,280 posts in this topic

I think it may be caused due to the currency symbol $
Google was also picky when the currency symbol was included with the price. And as we define the currency in an extra property, that might cause the problem. What do you think?
I don't know how I can test it without it, since I don't know know which code to change.

Share this post


Link to post
Share on other sites
Quote

<meta property="og:price" content="$179.00" />

<meta property="og:currency" content="USD" />

I wouldn't be terribly surprised if giving the currency twice (explicit '$' in price, and 'USD' in currency), is upsetting somebody. Can you format the price as simply '179.00'? If the code is pulling the price from some other field, and it already has '$' in it, something as simple as changing $price to 

...substr($price, 1)... 

might do the job.

Share this post


Link to post
Share on other sites

Markus: The fix Phil mention is how to do it. In the includes/modules.header_tags_opengraph.php file, find this line

$og_price = $currencies->display_price($new_price, tep_get_tax_rate($og['products_tax_class_id']));

and add this one below it

$og_price = substr($og_price, 1);

 

Share this post


Link to post
Share on other sites

did not fix the issue. so I researched further.

According to Facebook's documentation og:price and og:currency is not valid

It should have the prefix "product" instead of "og".

product_Open_Graph_Object_Type_-_2017-10-16_18.42.00.png

Edited by mk_osc
fixed typo

Share this post


Link to post
Share on other sites

Replace the file mentioned previously with the following. It should conform to their changed rules. But it is only for one price/language. If multiple prices are present, the code would have to be altered further for that.

<?php

$loc = explode(',',$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
$ogArray = array();                  
$ogArray['site_name'] = STORE_NAME; 
$ogArray['locale']  = str_replace('-', '_', $loc[0]);
$showOG = false;
$showProduct = false;
$showTwitter = false;

$twitterArray = array(); 
$db_query = tep_db_query("select groupname as storename, data as creator from headertags_social where section = 'twitter'");
$db = array();
if (tep_db_num_rows($db_query)) {
    $db = tep_db_fetch_array($db_query);
    $twitterArray[] = '<meta name="twitter:card" content="summary">';
    $twitterArray[] = '<meta name="twitter:site" content="@' . $db['storename'] . '">';
    $showTwitter = true;
}

switch (true) {
    case (basename($_SERVER['SCRIPT_FILENAME']) === 'index.php'):
        if ($category_depth == 'top') {
            $img = (file_exists('store_logo.png') ? tep_href_link('images/store_logo.png', '', $request_type, false, false) : '');
            
            if (! tep_not_null($canonical_url)) {
              $canonical_url = GetCanonicalURL();
            }

            $twitterArray[] = '<meta name="twitter:creator" content="@' . $db['creator'] . '">';
            $twitterArray[] = '<meta name="twitter:url" content="' . tep_href_link('index.php', '', $request_type, false) . '">';
            $twitterArray[] = '<meta name="twitter:title" content="' . $header_tags_array['title'] . '">';
            $twitterArray[] = '<meta name="twitter:description" content="' . $header_tags_array['desc'] . '">';
            $twitterArray[] = '<meta name="twitter:image" content="' . $img . '">';        
            
            $ogArray['type'] = 'website';
            $ogArray['image'] = $img;
            $ogArray['url'] = $canonical_url;
            $showOG = true;
        } 
    break;
    
    case (basename($_SERVER['SCRIPT_FILENAME']) === 'product_info.php'):
    case (basename($_SERVER['SCRIPT_FILENAME']) === 'product_reviews.php'):
    case (basename($_SERVER['SCRIPT_FILENAME']) === 'product_reviews_info.php'):        
        if ($_GET['products_id'] > 0) {
            $og_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_quantity, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_available from products p, products_description pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
        
            if ( tep_db_num_rows($og_query) > 0 ) {
                $og = tep_db_fetch_array($og_query);
                
                $img = (tep_not_null($og['products_image']) ? tep_href_link('images/' . $og['products_image'], '', $request_type, false, false) : '');                
                $url = tep_href_link('product_info.php', 'products_id=' . $og['products_id'], $request_type, false);

                /**** Get the price ****/
                if (($new_price = tep_get_products_special_price($og['products_id']))) {
                } else {
                    $new_price = $og['products_price'];
                }  
                $og_price = $currencies->display_price($new_price, tep_get_tax_rate($og['products_tax_class_id']));
                $og_price = substr($og_price, 1);
                
                $twitterArray[] = '<meta name="twitter:creator" content="@' . $db['creator'] . '">';
                $twitterArray[] = '<meta name="twitter:url" content="' . $url . '">';
                $twitterArray[] = '<meta name="twitter:title" content="' . htmlspecialchars($og['products_name'], ENT_QUOTES) . '">';
                $twitterArray[] = '<meta name="twitter:description" content="' . GetOGDescription($og['products_description']) . '">';
                $twitterArray[] = '<meta name="twitter:image" content="' . $img . '">';  

                $twitterArray[] = '<meta name="twitter:data1" content="' . $og_price . '">';  
                $twitterArray[] = '<meta name="twitter:label1" content="' . HTS_OG_PRICE . '">';  
                
                $twitterArray[] = '<meta name="twitter:data2" content="' . $og['products_quantity'] . '">';  
                $twitterArray[] = '<meta name="twitter:label2" content="' . HTS_OG_AVAILABLE_STOCK . '">';             
            
                $ogArray['type'] = 'product';
                $ogArray['title'] = htmlspecialchars($og['products_name'], ENT_QUOTES);
                $ogArray['description'] = GetOGDescription($og['products_description']);
                $ogArray['image'] = $img;
                $ogArray['url'] = $url;
                $ogArray['product:price:amount'] = $og_price;   
                $ogArray['product:price:currency'] = $currency;
                $ogArray['availability'] = ($og['products_date_available'] > date('Y-m-d H:i:s') ? 'pending' :
                                            $og['products_quantity'] < 1 ? 'oos' :
                                            $og['products_quantity'] > 0 ? 'instock' : 'oos');
                $showOG = true;  
                $showProduct = true;                
            }
        }
    break;

    case (defined('article_info.php') && basename($_SERVER['SCRIPT_FILENAME']) === 'article_info.php'):
        if ($_GET['articles_id'] > 0) {
            $og_query = tep_db_query("select a.articles_date_added, a.articles_last_modified, ad.articles_image, ad.articles_name, a.authors_id, ad.articles_description, ad.articles_url, au.authors_name, td.topics_name from 
              articles a left join 
              authors au on a.authors_id = au.authors_id left join 
              articles_description ad on a.articles_id = ad.articles_id left join 
              articles_to_topics a2t on a.articles_id = a2t.articles_id left join 
              topics_description td on a2t.topics_id = td.topics_id
              where a.articles_status = '1' and a.articles_id = '" . (int)$_GET['articles_id'] . "' and ad.language_id = '" . (int)$languages_id . "'");
            if ( tep_db_num_rows($og_query) > 0 ) {
                $og = tep_db_fetch_array($og_query);
 
                $img = (tep_not_null($og['articles_image']) ? tep_href_link('images/' . $og['articles_image'], '', $request_type, false, false) : '');
                $url = tep_href_link('article_info.php', 'article_id=' . $og['articles_id'], $request_type, false);
                
                $twitterArray[] = '<meta name="twitter:creator" content="@' . (tep_not_null($og['authors_name']) ? $og['authors_name'] : $db['creator']) . '">';
                $twitterArray[] = '<meta name="twitter:url" content="' . $url . '">';
                $twitterArray[] = '<meta name="twitter:title" content="' . htmlspecialchars($og['articles_name'], ENT_QUOTES) . '">';
                $twitterArray[] = '<meta name="twitter:description" content="' . GetOGDescription($og['articles_description']) . '">';
                $twitterArray[] = '<meta name="twitter:image" content="' . $img . '">';  
                
                $ogArray['type'] = 'article';
                $ogArray['url'] = $url;
                $ogArray['description'] = GetOGDescription($og['articles_description']);
                $ogArray['tag'] = $header_tags_array['keywords'];
                if (isset($og['articles_date_added'][1])) $ogArray['published_time'] = $og['articles_date_added'];
                if (isset($og['articles_last_modified'][1])) $ogArray['modified_time'] = $og['articles_last_modified'];
                if (isset($og['expiration_time'][1])) $ogArray['expiration_time'] = $og['expiration_time'];
                if (isset($og['authors_name'][1])) $ogArray['author'] = $og['authors_name'];
                if (isset($og['authors_id'][1])) $ogArray['author'] = tep_href_link('articles.php', 'authors_id=' . $og['authors_id'], $request_type, false);
                if (isset($og['topics_name'][1])) $ogArray['section'] = $og['topics_name'];
                if (isset($og['articles_image'][1])) $ogArray['image'] = $img;
 
                $showOG = true; 
            }    
        }
    break;
}  

if ($showTwitter) { 
    foreach ($twitterArray as $tag => $data) {
        echo $data . "\n";
    }    
}
 
if ($showOG) { 
    foreach ($ogArray as $tag => $data) {
        if ($showProduct && strpos($tag, 'product:price:') !== FALSE) {
            echo '<meta property="' . $tag . '" content="' . $data . '" />' . "\n";
        } else {
            echo '<meta property="og:' . $tag . '" content="' . $data . '" />' . "\n";
        }
    }    
}
 

 

Share this post


Link to post
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