Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
function um_author_products_display($showposts = 4, $author = 0, $orderby = 'date')
{
    $is_vip = getUserMemberType($author);
    if ($is_vip) {
        $author_arg = $author;
    } else {
        $author_arg = 0;
    }
    $products_query = um_query_products($showposts, $author_arg, $orderby);
    if ($products_query->have_posts()) {
        while ($products_query->have_posts()) {
            $products_query->the_post();
            if (has_post_thumbnail()) {
                $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                $imgsrc = $large_image_url[0];
            } else {
                $imgsrc = um_catch_first_image();
            }
            ?>
	<li><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
" rel="bookmark" class="fancyimg">
		<div class="thumb-img">
			<img src="<?php 
            echo um_timthumb($imgsrc, 280, 180);
            ?>
" alt="<?php 
            the_title();
            ?>
">
			<span><i class="fa fa-shopping-cart"></i></span>
		</div>
		</a>
		<p><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            the_title();
            ?>
</a></p>
	</li>
<?php 
        }
    }
    wp_reset_query();
}
Ejemplo n.º 3
0
            ?>
</strong><span><?php 
            _e('(限时特惠)', 'tinection');
            ?>
</span><?php 
        }
        ?>
</li>
							<?php 
        if ($discount_arr[3] != 0) {
            ?>
							<li class="summary-price"><span class="dt"><?php 
            _e('会员特惠', 'tinection');
            ?>
</span><?php 
            if (getUserMemberType()) {
                ?>
<strong><?php 
                if ($currency == 1) {
                    echo '<em>¥</em>' . sprintf('%0.2f', $discount_arr[1]) . '<em>(元)</em>';
                } else {
                    echo '<em><i class="fa fa-gift"></i></em>' . sprintf('%0.2f', $discount_arr[1]) . '<em>(积分)</em>';
                }
                ?>
</strong><?php 
            } else {
                if (is_user_logged_in()) {
                    echo sprintf(__('非<a href="%1$s" target="_blank" title="开通会员">会员</a>不能享受该优惠', 'tinection'), tin_get_user_url('membership'));
                } else {
                    _e('<a href="javascript:" class="user-login">登录</a> 查看优惠', 'tinection');
                }
Ejemplo n.º 4
0
function um_member_icon($uid)
{
    $uid = (int) $uid;
    $type = getUserMemberType($uid);
    //0代表已过期 1代表月费会员 2代表季费会员 3代表年费会员 FALSE代表未开通过会员
    if ($type === 3) {
        $icon = '<i class="ico annual_member"></i>';
    } elseif ($type === 2) {
        $icon = '<i class="ico quarter_member"></i>';
    } elseif ($type === 1) {
        $icon = '<i class="ico month_member"></i>';
    } elseif ($type === 0) {
        $icon = '<i class="ico expired_member"></i>';
    } else {
        $icon = '';
    }
    return $icon;
}