Ejemplo n.º 1
0
function flexmarket_load_single_product_in_box($span = 'span4', $post_id = NULL, $imagesize = 'tb-360', $btnclass = '', $iconclass = '', $tagcolor = '', $class = '', $style = '', $echo = true)
{
    if (is_multisite()) {
        $blog_id = get_current_blog_id();
    } else {
        $blog_id = 1;
    }
    if ($class == 'thetermsclass') {
        $class = '';
        $terms = get_the_terms($post_id, 'product_category');
        if (!empty($terms)) {
            foreach ($terms as $thesingleterm) {
                $class .= ' ' . $thesingleterm->slug;
            }
        }
    }
    switch ($span) {
        case 'span6':
            $maxwidth = '560';
            $imagesize = 'tb-860';
            $btnsize = '';
            break;
        case 'span3':
            $maxwidth = '360';
            $btnsize = ' btn-small';
            break;
        case 'span4':
            $maxwidth = '360';
            $btnsize = '';
            break;
    }
    $output = '';
    $output .= '<div class="' . $span . ' well well-small' . $class . '"' . $style . '>';
    if (has_post_thumbnail($post_id)) {
        $fullimage = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full');
        $output = apply_filters('flexmarket_product_box_before_image', $output, $post_id, $blog_id);
        $output .= '<div class="image-box" style="max-width: ' . $maxwidth . 'px;">';
        $output .= get_the_post_thumbnail($post_id, $imagesize);
        $output .= '<div class="hover-block hidden-phone">';
        $output .= '<div class="btn-group">';
        $button = '<a href="' . get_permalink($post_id) . '" class="btn' . $btnclass . '">' . get_the_title($post_id) . '</a>';
        $button .= '<a href="' . $fullimage[0] . '" rel="prettyPhoto[mp-product-' . $post_id . '" class="btn' . $btnclass . '"><i class="icon-zoom-in' . $iconclass . '"></i></a>';
        $output .= apply_filters('flexmarket_product_box_btn_group', $button, $post_id, $blog_id, $btnclass, $iconclass, $fullimage[0]);
        $output .= '</div>';
        $output .= '</div>';
        $output .= '</div>';
        $output = apply_filters('flexmarket_product_box_after_image', $output, $post_id, $blog_id);
    }
    $output .= '<div class="clear padding5"></div>';
    $output .= '<div class="hidden-phone">';
    $output .= '<div class="product-meta row-fluid">';
    $output .= '<div class="span6">';
    $output .= '<p>';
    $output .= $span == 'span3' ? '<small>' : '';
    $output .= flexmarket_product_price(false, $post_id, '', $tagcolor);
    $output .= $span == 'span3' ? '</small>' : '';
    $output .= '</p>';
    $output .= '</div>';
    $output .= '<div class="span6 atc">';
    $output .= flexmarket_buy_button(false, 'list', $post_id, $btnclass . $btnsize, $iconclass);
    $output .= '</div>';
    $output .= '</div>';
    $output .= '</div>';
    $output .= '<div class="visible-phone align-center">';
    $output .= '<p>';
    $output .= apply_filters('flexmarket_product_box_title_mobile', get_the_title($post_id) . '<br />', $post_id, $blog_id);
    $output .= flexmarket_product_price(false, $post_id, '', $tagcolor);
    $output .= '</p>';
    $output .= flexmarket_buy_button(false, 'list', $post_id, $btnclass, $iconclass);
    $output .= '</div>';
    $output .= '</div>';
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
Ejemplo n.º 2
0
    function widget($args, $instance)
    {
        global $mp;
        if ($instance['only_store_pages'] && !mp_is_shop_page()) {
            return;
        }
        extract($args);
        echo $before_widget;
        $title = $instance['title'];
        if (!empty($title)) {
            echo $before_title . apply_filters('widget_title', $title) . $after_title;
        }
        if (!empty($instance['custom_text'])) {
            echo '<div id="custom_text">' . $instance['custom_text'] . '</div>';
        }
        /* setup our custom query */
        //setup taxonomy if applicable
        if ($instance['taxonomy_type'] == 'category') {
            $taxonomy_query = '&product_category=' . $instance['taxonomy'];
        } else {
            if ($instance['taxonomy_type'] == 'tag') {
                $taxonomy_query = '&product_tag=' . $instance['taxonomy'];
            } else {
                $taxonomy_query = '';
            }
        }
        //figure out perpage
        if (isset($instance['num_products']) && intval($instance['num_products']) > 0) {
            $paginate_query = '&posts_per_page=' . intval($instance['num_products']) . '&paged=1';
        } else {
            $paginate_query = '&posts_per_page=10&paged=1';
        }
        //get order by
        if ($instance['order_by']) {
            if ($instance['order_by'] == 'price') {
                $order_by_query = '&meta_key=mp_price&orderby=meta_value_num';
            } else {
                if ($instance['order_by'] == 'sales') {
                    $order_by_query = '&meta_key=mp_sales_count&orderby=meta_value_num';
                } else {
                    $order_by_query = '&orderby=' . $instance['order_by'];
                }
            }
        } else {
            $order_by_query = '&orderby=title';
        }
        //get order direction
        if ($instance['order']) {
            $order_query = '&order=' . $instance['order'];
        } else {
            $order_query = '&orderby=DESC';
        }
        //The Query
        $custom_query = new WP_Query('post_type=product' . $taxonomy_query . $paginate_query . $order_by_query . $order_query);
        //do we have products?
        if (count($custom_query->posts)) {
            echo '<ul id="mp_product_list" class="">';
            foreach ($custom_query->posts as $post) {
                $btnclass = mpt_load_mp_btn_color();
                echo '<li ' . mp_product_class(false, 'mp_product', $post->ID) . '>';
                echo '<div class="row-fluid">';
                if ($instance['show_thumbnail']) {
                    echo '<div class="span4">';
                    mp_product_image(true, 'widget', $post->ID, $instance['size']);
                    echo '</div>';
                    echo '<div class="span8">';
                } else {
                    echo '<div class="span12">';
                }
                echo '<p class="mp_product_name"><a href="' . get_permalink($post->ID) . '">' . esc_attr($post->post_title) . '</a></p>';
                if ($instance['show_excerpt']) {
                    echo '<div class="mp_product_content">' . $mp->product_excerpt($post->post_excerpt, $post->post_content, $post->ID) . '</div>';
                }
                if ($instance['show_price'] || $instance['show_button']) {
                    echo '<div class="mp_product_meta' . ($instance['show_excerpt'] ? ' align-right' : '') . '">';
                    if ($instance['show_price']) {
                        echo flexmarket_product_price(false, $post->ID, '', '', 'widget');
                    }
                    if ($instance['show_button']) {
                        echo flexmarket_buy_button(false, 'list', $post->ID, $btnclass . ' btn-small');
                    }
                    echo '</div>';
                }
                echo '</div>';
                //End span
                echo '</div>';
                // End Row-fluid
                echo '</li>';
            }
            echo '</ul>';
        } else {
            ?>
	      <div class="widget-error">
	  			<?php 
            _e('No Products', 'mp');
            ?>
	  		</div>
	  		<?php 
        }
        echo $after_widget;
    }
Ejemplo n.º 3
0
                mpt_load_featured_image($id, 'tb-860', true, $btnclass, $iconclass);
            }
            ?>

									<?php 
        }
        ?>
	

								<div class="clear padding25"></div>

								  	<div class="row-fluid">

								  		<div class="span3">
								  			<?php 
        flexmarket_product_price(true, NULL, true, $tagcolor);
        ?>
								  		</div>

								  		<div class="span9 align-right">
								  			<?php 
        flexmarket_buy_button(true, 'single', NULL, $btnclass);
        ?>
								  		</div>

								  	</div>

								<div class="clear"></div>

								<?php 
        the_content();