Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Georgia, USA
    Posts
    1,948
    Plugin Contributions
    0

    Default Open Graph Meta Tags

    I am currently using the code below to generate the product price as part of the Open Graph meta tag on our site:
    PHP Code:
    <?php if (isset($_GET['products_id'])) {
    $cs_price $product_info_metatags->fields['products_price_sorter'];
    ?>
    <meta property="og:price:amount" content="<?php echo $cs_price?>" />
    <?php 
      
    }
    ?>
    The above code generates the price just fine and you can see it by viewing the source on our site from my signature below. However, the price that is generated shows 4 decimal place instead of two. Something like 10.9900 or 10.4900 (or whatever the 4 decimal place resulted in). I am looking for assistance to rewrite this to format it so it only shows 2 decimal place.

    Thanks!

  2. #2
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: Open Graph Meta Tags

    Zen Cart normally outputs prices using the $currency class formatter.
    What you're doing is something that desires to do only half of the work the formatter normally does.
    So, you'll probably simply want to set $cs_price = number_format($cs_price, 2);
    or something similar. You can lookup number_format on php.net if you want to adjust formatting further.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Feb 2004
    Location
    Georgia, USA
    Posts
    1,948
    Plugin Contributions
    0

    Default Re: Open Graph Meta Tags

    Thanks DrByte! this what I ended up with and it worked.
    PHP Code:
    <?php if (isset($_GET['products_id'])) {
    $cs_price = (round(zen_get_products_actual_price($product_info_metatags->fields['products_id']),2));
    ?>
    <meta property="og:price:amount" content="<?php echo $cs_price?>" />
    <?php 
      
    }
    ?>

 

 

Similar Threads

  1. v154 Open Graph error w3c can not solve
    By diamond1 in forum General Questions
    Replies: 7
    Last Post: 11 May 2015, 08:02 PM
  2. I want to add Facebook open graph tags
    By stevemax in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 18 Jul 2011, 07:07 PM
  3. Where do I add facebook open graph tags?
    By surlybroad in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 25 May 2011, 04:12 PM
  4. Open Graph DOCTYPE -- can't validate W3C
    By damiantaylor in forum General Questions
    Replies: 2
    Last Post: 29 Apr 2011, 04:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR