<?php $contents = get_the_excerpt(); $excerpt = wp_trim_words($contents, 50, '...'); echo $excerpt; ?> </p> <div class="pricebtn"><?php $currency = get_post_meta($post->ID, 'pay_currency', true); if ($currency == 1) { echo '¥'; } else { echo '<i class="fa fa-gift"> </i>'; } ?> <strong><?php echo tin_get_product_price($post->ID); ?> </strong><a class="buy" href="<?php the_permalink(); ?> ">前往购买</a></div> </div> </div> <?php } } ?> </div> <!-- pagination --> <div class="clear">
function product_smallest_price($product_id) { $original_price = tin_get_product_price($product_id); $vip_discount = json_decode(get_post_meta($product_id, 'product_vip_discount', true), true); $vip_discount = empty($vip_discount) ? 1 : $vip_discount; $vip_discount1 = isset($vip_discount['product_vip1_discount']) ? $vip_discount['product_vip1_discount'] : 1; $vip_discount2 = isset($vip_discount['product_vip2_discount']) ? $vip_discount['product_vip2_discount'] : 1; $vip_discount3 = isset($vip_discount['product_vip3_discount']) ? $vip_discount['product_vip3_discount'] : 1; if (is_user_logged_in()) { $vip = getUserMemberType(); $discount_type = $vip ? 'vip_discount' . $vip : 'vip_discount'; $vip_discount = $vip ? ${$discount_type} : 1; } else { $vip_discount = 1; } $promote_discount = get_post_meta($product_id, 'product_promote_discount', true); if ($vip_discount < 1 && $vip_discount >= 0) { $vip_price = $original_price * $vip_discount; } else { $vip_price = $original_price; } $discount_begin_date = get_post_meta($product_id, 'product_discount_begin_date', true) ? get_post_meta($product_id, 'product_discount_begin_date', true) : 0; $discount_period = get_post_meta($product_id, 'product_discount_period', true) ? get_post_meta($product_id, 'product_discount_period', true) : 0; if ($discount_begin_date == 0 || $discount_period == 0) { $promote_price = $original_price; } elseif (strtotime($discount_begin_date) <= time() && strtotime('+' . $discount_period . ' days', strtotime($discount_begin_date)) >= time()) { $promote_price = $promote_discount * $original_price; } else { $promote_price = $original_price; } $vip_discount_arr = array($vip_discount1, $vip_discount2, $vip_discount3); sort($vip_discount_arr); $vip_price_show = $vip_discount_arr[0] < 1 && $vip_discount_arr[0] < $promote_discount ? 1 : 0; $promote_price_show = $promote_price < $original_price ? 1 : 0; $price_arr = array($original_price, $vip_price, $promote_price); sort($price_arr); $last_price = sprintf('%0.2f', $price_arr[0]); $price = array($original_price, $vip_price, $promote_price, $vip_price_show, $promote_price_show, $last_price); return $price; }