zencart 输出产品特价折扣百分比

通过调用zen_get_products_base_price($products_id)获取原价,zen_get_products_special_price($products_id)获取特价,进而计算百分比。

$display_normal_price = zen_get_products_base_price($specials_index->fields['products_id']);
$display_special_price = zen_get_products_special_price($specials_index->fields['products_id'], true);
$display_sale_price = zen_get_products_special_price($specials_index->fields['products_id'], false);
if ($display_normal_price != 0 &&  $display_sale_price) {
    $show_discount_amount = number_format(100 - (($display_sale_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS);
}
if($display_normal_price != 0 &&  $display_special_price ){
    $show_discount_amount = number_format(100 - (($display_special_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS);
}

 

转载于:https://www.cnblogs.com/afish/p/3967256.html

你可能感兴趣的:(zencart 输出产品特价折扣百分比)