|
|
|
@ -997,9 +997,9 @@ class Information extends CI_Controller
|
|
|
|
|
|
|
|
|
|
public function test_price()
|
|
|
|
|
{
|
|
|
|
|
$price_rule = '#ah-8,st,2#';//'#'.$meta_product_code.',st,2#';
|
|
|
|
|
$tag_price = $this->replace_price_tag($price_rule);
|
|
|
|
|
echo 'Price: '.$tag_price;
|
|
|
|
|
$price_rule = '<div style="color: red;">#ah-8,st,2#</div>';
|
|
|
|
|
$price_tag_list = $this->parse_price_tag($price_rule);
|
|
|
|
|
var_dump($price_tag_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@ -1009,9 +1009,10 @@ class Information extends CI_Controller
|
|
|
|
|
* @param string $price_content 包含价格标签的内容
|
|
|
|
|
* @return string 可读的价格字符串
|
|
|
|
|
*/
|
|
|
|
|
public function replace_price_tag($price_content)
|
|
|
|
|
public function parse_price_tag($price_content)
|
|
|
|
|
{
|
|
|
|
|
$price_item_array = $this->price_pregmatch($price_content);
|
|
|
|
|
$price_tag_list = [];
|
|
|
|
|
if ( ! empty($price_item_array)) {
|
|
|
|
|
foreach ($price_item_array as $price_item) {
|
|
|
|
|
$price_date = !empty($price_item->price_date) ? $price_item->price_date : date('Y-m-d', time() + 86400 * 7); //当前时间7天后的价格
|
|
|
|
@ -1098,7 +1099,12 @@ class Information extends CI_Controller
|
|
|
|
|
//把金额格式化为带有逗号(,)方便阅读,如 12,345
|
|
|
|
|
$price_number = is_numeric($price_number) ? number_format($site_money) : $price_number;
|
|
|
|
|
if (!empty($price_number)) {
|
|
|
|
|
$price_content = str_replace($price_item->placeholder, $price_number, $price_content);
|
|
|
|
|
$price_tag = [
|
|
|
|
|
'placeholder' => $price_item->placeholder,
|
|
|
|
|
'price_number' => $price_item->price_number,
|
|
|
|
|
];
|
|
|
|
|
$price_tag_list[] = $price_tag;
|
|
|
|
|
//$price_content = str_replace($price_item->placeholder, $price_number, $price_content);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|