soniad Posted September 23, 2015 Share Posted September 23, 2015 Hello everyone,I am trying to fetch a product price and declare it as an item property for microdata.The following function returns a price and displays it on the page:<?php echo $this->getPriceHtml($_product, true) ?>I don't want to display the price but to insert it in the following code<meta itemprop="price" content=(price) />where (price) is the returned valueI tried this:<?php $_test = $this->getPriceHtml($_product, true) ?> <?php echo $_test ?>the variable $_test displays correctly in my diagnostics.But I cannot get it to work when inserted in the meta call:<meta itemprop="price" content=$_test />Could somebody please show me where I'm going wrong?Thanks Link to comment https://forums.phpfreaks.com/topic/298285-trying-to-implement-microdata/ Share on other sites More sharing options...
requinix Posted September 23, 2015 Share Posted September 23, 2015 What is the code you have for the that does not work? Link to comment https://forums.phpfreaks.com/topic/298285-trying-to-implement-microdata/#findComment-1521388 Share on other sites More sharing options...
QuickOldCar Posted September 23, 2015 Share Posted September 23, 2015 <meta itemprop="price" content="<?php echo $this->getPriceHtml($_product, true); ?>" /> Link to comment https://forums.phpfreaks.com/topic/298285-trying-to-implement-microdata/#findComment-1521401 Share on other sites More sharing options...
QuickOldCar Posted September 23, 2015 Share Posted September 23, 2015 You can add opengraph metadata as well. Link to comment https://forums.phpfreaks.com/topic/298285-trying-to-implement-microdata/#findComment-1521402 Share on other sites More sharing options...
rwhite35 Posted September 23, 2015 Share Posted September 23, 2015 In addition to QuickOldCar's answer, your markup is different then what Schema.org defines as a price object. Check out the http://schema.org/price Price description. Click on the Microdata tab for example markups. You may want: <span itemprop="priceCurrency" content="USD">$</span><span itemprop="price" content="1000.00">1,000.00</span> <link itemprop="availability" href="http://schema.org/InStock" />In stock Link to comment https://forums.phpfreaks.com/topic/298285-trying-to-implement-microdata/#findComment-1521403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.