Guest User

Untitled

a guest
Feb 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <?php
  2. $session = Mage::getSingleton('customer/session');
  3. if ($session->isLoggedIn()) {
  4. $countryCode = $session->getCustomer()->getDefaultBillingAddress()->getCountry();
  5. $usdPrice = Mage::helper('core')->currency($_product->getFinalPrice(),false);
  6.  
  7.  
  8. if($countryCode == "GB") {
  9.  
  10. if(!function_exists(convertCurrencyGb)) {
  11.  
  12. function convertCurrencyGb($amount, $from, $to){
  13. $data = file_get_contents("https://finance.google.com/finance/converter?a=$amount&from=$from&to=$to");
  14. preg_match("/<span class=bld>(.*)</span>/",$data, $converted);
  15. $converted = preg_replace("/[^0-9.]/", "", $converted[1]);
  16. return number_format(round($converted, 3),2);
  17. }
  18. $newprice = convertCurrencyGb($usdPrice, "USD", "GBP");
  19. }
  20.  
  21. echo ' <div class="test" style="display: none;">';
  22. echo $newprice;
  23. echo '</div>';
  24. }
  25. }
  26. ?>
Add Comment
Please, Sign In to add comment