cupidare Posted June 1, 2016 Share Posted June 1, 2016 Hello, Sorry for this silly question, but I struggle with this: in product_listing.php $prod_list_contents .= ' <div class="col-xs-6" itemprop="offers" itemscope itemtype="http://schema.org/Offer"><meta itemprop="priceCurrency" content="' . tep_output_string($currency) . '" /><div class="btn-group" role="group"><button type="button" class="btn btn-default"><span itemprop="price" content="' . preg_replace('/[^0-9.]*/', '', $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']))) . '">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></button></div></div>'; How can I convert a different price-separation (in my case "," instead of "." e.g. 2,70€) to a 2.70 for the microdata? At the moment the preg_replace gives for this example content="270.." thank you in advance ... Link to comment Share on other sites More sharing options...
MrPhil Posted June 1, 2016 Share Posted June 1, 2016 What string does $currencies->display_price(...) give you? Is it 2,70€ (German-style , decimal separator) and you want 2.70 or 2.70€? If you want the latter, and you know there will be (at most) one comma, how about something like preg_replace('/,/', '.', $currencies->... If you want to get rid of the Euro, too, the substitutions require arrays: preg_replace(array('/,/', '/€/'), array('.', ''), $currencies->... (or something like that) might work. preg_replace() may be overkill for something like this, and you could use str_replace(). Link to comment Share on other sites More sharing options...
cupidare Posted June 2, 2016 Author Share Posted June 2, 2016 thank you for your reply. I changed it to preg_replace(array('/[^0-9,0-9]/','/[,]/'),array('','.') which works for me. I don't know, if this is overkill... The problem is that google wants the price in the format 2.70 without comma or currency... Link to comment Share on other sites More sharing options...
MrPhil Posted June 2, 2016 Share Posted June 2, 2016 My suggestion was that the use of preg_replace() was overkill, and that str_replace() would be much faster and easier to understand. All you're doing is substituting . for , and <null> for €, neither of which require regular expression pattern matching. By the way, your pattern [^0-9,0-9] doesn't do what you think it does. It matches anything not digit or comma (in your case, the Euro sign), not a pattern digit,digit. And a single character to match shouldn't be [,], but just , . You need to study up on regular expression pattern matching before you get yourself in trouble. Link to comment Share on other sites More sharing options...
burt Posted June 3, 2016 Share Posted June 3, 2016 Please change your code to this: https://github.com/gburton/Responsive-osCommerce/pull/387/files Please report back (eg after implementing and running thru Googles Microdata Tool) @ https://github.com/gburton/Responsive-osCommerce/issues/386 Link to comment Share on other sites More sharing options...
cupidare Posted June 5, 2016 Author Share Posted June 5, 2016 Hello Gary, I implemented this and it works very well. Although I omitted the index_nested stuff (not in my version) I got no errors in the product_listing from the structured data test (product: no error, breadcrumb: no error) thank you a lot. Am I right in applying this to product_info and all the other sites? Thank you a lot! Link to comment Share on other sites More sharing options...
burt Posted June 6, 2016 Share Posted June 6, 2016 @@cupidare https://github.com/gburton/Responsive-osCommerce/pull/387/commits/d2f0fa68681a9210db750a1c26a80b16acec64a6 Link to comment Share on other sites More sharing options...
cupidare Posted June 17, 2016 Author Share Posted June 17, 2016 Hello Burt, I installed this last week and don't find any issues yet thank you a lot Link to comment Share on other sites More sharing options...
burt Posted June 19, 2016 Share Posted June 19, 2016 @@cupidare thanks for reporting that it all works :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.