【发布时间】:2019-07-09 07:40:16
【问题描述】:
我正在开发电子商务网站。几乎我已经做到了。但是我在以美元显示产品价格方面存在一个问题。如果用户在印度打开网站以卢比显示产品价格,如果在国外访问网站以美元显示产品价格。
我创建了产品详细信息页面,下面提供我的代码:
public function getProductDetail($pro_code,$error_msg){
$showProDetail='';
$result =$this->connect()->query("SELECT * FROM wm_products WHERE pro_code='$pro_code'");
if($result->num_rows>0){
$row = $result->fetch_assoc();
$cate_id = $row['cate_id'];
$image = json_decode($row['pro_img']);
$showProDetail.='
<div class="page product_detail_wrapper">
<div class="panel-body">
<div class="row">
<div class="col-lg-4 col-mg-4 col-sm-4 col-xs-12">
<figure class="thumbnail">
<img src="../uploads/product_images/' .$image[0].'" alt="">
</figure>
</div>
<div class="col-lg-8 col-mg-8 col-sm-8 col-xs-12">
<div class="responsive-table">
<table class="table table-striped">
<tr>
<td><strong>Product Code</strong></td>
<td>:'.$row["pro_code"].'</td>
</tr>
<tr>
<td><strong>Name</strong></td>
<td>:'.ucfirst(str_replace("_", " ", $row["pro_name"])).'</td>
</tr>
<tr>
<td><strong>Price</strong></td>
<td>: Rs.'.$row["pro_price"].'</td>
</tr>
<tr>
<td><strong>Discount</strong></td>
<td>:'.$row["pro_discount"].'</td>
</tr>
<tr>
<td><strong>Available In</strong></td>
<td>:'.$row["pro_weight"].'</td>
</tr>
<tr>
<td><strong>Quantity</strong></td>
<td>:'.$row["pro_quantity"].'</td>
</tr>
<tr>
<td><strong>Short Description</strong></td>
<td>:'.$row["short_disc"].'</td>
</tr>
</table>
</div>
</div>
</div><br>
</div>
</div>';
}
else{
$showProDetail = '<div class="alert alert-danger">Product Detail Not Found</div>';
}
return $showProDetail;
}
那么,如何以卢比为印度的产品价格和以美元为印度的产品价格?
【问题讨论】:
-
您可以使用 ip 来跟踪网络用户所在的国家/地区。这个问题在这里已经有了答案。 stackoverflow.com/a/13600004/8913606