Advertisement
ikamal

price

Apr 1st, 2019
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. function get_mobile_price(){
  2.     global $post;
  3.  
  4.     $prices = get_field('prices', $post->ID);
  5.     $default_price = get_field('default_price', $post->ID);
  6.  
  7.     $i = 0;
  8.     $mobile_price = '';
  9.  
  10.     // Get server URI
  11.  
  12.     $country = explode('/', $_SERVER['REQUEST_URI']) [1];
  13.  
  14.  
  15.  
  16.     foreach ($prices as $price) {
  17.         //var_dump($price['country']->post_name);
  18.        
  19.  
  20.         if($country == $price['country']->post_name){
  21.             echo $price['price'];
  22.             break;
  23.         }else{
  24.             echo $default_price;
  25.             break;
  26.         }
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement