Exemple #1
0
 function post_object($id, $term_id = false, $matches = false)
 {
     $unset_array = array('post_date_gmt', 'post_status', 'comment_status', 'ping_status', 'post_password', 'post_content_filtered', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'guid', 'menu_order', 'post_mime_type', 'comment_count', 'ancestors', 'filter');
     global $post;
     $date_format = get_option('date_format');
     $post = get_post($id);
     if ($term_id) {
         if (!in_category($term_id, $post->ID)) {
             return false;
         }
     }
     $size = array('height' => 50, 'width' => 50);
     if ($post != null) {
         $post_object = new stdclass();
         $post_link = get_permalink($post->ID);
         if (in_array('{post_image}', $matches) || in_array('{post_image_html}', $matches)) {
             $post_thumbnail_id = get_post_thumbnail_id($post->ID);
             if ($post_thumbnail_id > 0) {
                 $thumb = wp_get_attachment_image_src($post_thumbnail_id, array($size['height'], $size['width']));
                 $post_object->post_image = trim($thumb[0]) == "" ? WEBNUS_SEARCH_NO_IMAGE : $thumb[0];
                 if (in_array('{post_image_html}', $matches)) {
                     $post_object->post_image_html = '<img src="' . $post_object->post_image . '" width="' . $size['width'] . '" height="' . $size['height'] . '"/>';
                 }
             } else {
                 if ($src = $this->get_image_from_content($post->post_content, $size['height'], $size['width'])) {
                     $post_object->post_image = $src['src'] ? $src['src'] : WEBNUS_SEARCH_NO_IMAGE;
                     if (in_array('{post_image_html}', $matches)) {
                         $post_object->post_image_html = '<img src="' . $post_object->post_image . '" width="' . $src['width'] . '" height="' . $src['height'] . '" />';
                     }
                 } else {
                     $post_object->post_image = WEBNUS_SEARCH_NO_IMAGE;
                     if (in_array('{post_image_html}', $matches)) {
                         $post_object->post_image_html = '';
                     }
                 }
             }
         }
         if ($post->post_type == "wpsc-product") {
             if (function_exists('wpsc_calculate_price')) {
                 if (in_array('{wpsc_price}', $matches)) {
                     $post_object->wpsc_price = wpsc_the_product_price();
                 }
                 if (in_array('{wpsc_shipping}', $matches)) {
                     $post_object->wpsc_shipping = strip_tags(wpsc_product_postage_and_packaging());
                 }
                 if (in_array('{wpsc_image}', $matches)) {
                     $post_object->wpsc_image = wpsc_the_product_image($size['height'], $size['width']);
                 }
             }
         }
         if ($post->post_type == 'product' && class_exists('WC_Product_Factory')) {
             $product_factory = new WC_Product_Factory();
             global $product;
             $product = $product_factory->get_product($post);
             if ($product->is_visible()) {
                 foreach ($matches as $match) {
                     $match = str_replace(array('{', '}'), '', $match);
                     if (in_array($match, array('categories', 'tags'))) {
                         $method = "get_" . $match;
                         if (method_exists($product, $method)) {
                             $term_list = call_user_func(array($product, $method), '');
                             if ($term_list) {
                                 $post_object->{$match} = '<span class="sf_list sf_' . $match . '">' . $term_list . '</span>';
                             } else {
                                 $post_object->{$match} = "";
                             }
                         }
                     } elseif ($match == 'add_to_cart_button') {
                         ob_start();
                         do_action('woocommerce_' . $product->product_type . '_add_to_cart');
                         $post_object->{$match} = '<div class="product">' . ob_get_contents() . '</div>';
                         ob_end_clean();
                     } else {
                         $method = "get_" . $match;
                         if (method_exists($product, $method)) {
                             $post_object->{$match} = call_user_func(array($product, $method));
                         } elseif (method_exists($product, $match)) {
                             $post_object->{$match} = call_user_func(array($product, $match));
                         }
                     }
                 }
             }
             /*
             $post->sku = $product->get_sku();
             $post->sale_price = $product->get_sale_price();
             $post->regular_price = $product->get_regular_price();
             $post->price = $product->get_price();
             $post->price_including_tax = $product->get_price_including_tax();
             $post->price_excluding_tax = $product->get_price_excluding_tax();
             $post->price_suffix = $product->get_price_suffix();
             $post->price_html = $product->get_price_html();
             $post->price_html_from_text = $product->get_price_html_from_text();
             $post->average_rating = $product->get_average_rating();
             $post->rating_count = $product->get_rating_count();
             $post->rating_html = $product->get_rating_html();
             $post->dimensions = $product->get_dimensions();
             $post->shipping_class = $product->get_shipping_class();
             $post->add_to_cart_text = $product->add_to_cart_text();
             $post->single_add_to_cart_text = $product->single_add_to_cart_text();
             $post->add_to_cart_url = $product->add_to_cart_url();
             $post->title = $product->get_title();
             */
         }
         $post_object->ID = $post->ID;
         $post_object->post_title = get_the_title($post->ID);
         if (in_array('{post_excerpt}', $matches)) {
             $post_object->post_excerpt = $post->post_excerpt;
         }
         if (in_array('{post_author}', $matches)) {
             $post_object->post_author = get_the_author_meta('display_name', $post->post_author);
         }
         if (in_array('{post_link}', $matches)) {
             $post_object->post_link = $post_link;
         }
         if (in_array('{post_content}', $matches)) {
             $post_object->post_content = $this->get_text_words(apply_filters('the_content', $post->post_content), (int) $this->get_excerpt_count());
         }
         if (in_array('{post_date_formatted}', $matches)) {
             $post_object->post_date_formatted = date($date_format, strtotime($post->post_date));
         }
         foreach ($matches as $match) {
             $match = str_replace(array('{', '}'), '', $match);
             if (strpos($match, 'custom_field_') !== false) {
                 $key = str_replace('custom_field_', '', $match);
                 $custom_field = get_post_meta($post->ID, $key, true);
                 if (is_array($custom_field)) {
                     $cf_name = 'custom_field_' . $key;
                     $post_object->{$cf_name} = apply_filters('sf_post_custom_field', $custom_field[0], $key, $post);
                 } else {
                     $cf_name = 'custom_field_' . $key;
                     $post_object->{$cf_name} = apply_filters('sf_post_custom_field', $custom_field, $key, $post);
                 }
             }
         }
         $post_object = apply_filters('sf_post', $post_object);
         return $post_object;
     }
     return false;
 }
            ?>
" class="thickbox preview_link" href="<?php 
            echo wpsc_the_product_image();
            ?>
">
									<img class="product_image" id="product_image_<?php 
            echo wpsc_the_product_id();
            ?>
" alt="<?php 
            echo wpsc_the_product_title();
            ?>
" title="<?php 
            echo wpsc_the_product_title();
            ?>
" src="<?php 
            echo wpsc_the_product_image($image_width, $image_height);
            ?>
"/>
								</a>
						<?php 
        } else {
            ?>
 
							<div class="item_no_image">
								<a href="<?php 
            echo wpsc_the_product_permalink();
            ?>
">
								<span>No Image Available</span>
								</a>
							</div>
Exemple #3
0
        ?>
">      
				<div class="textcol">
				
					<?php 
        if (get_option('show_thumbnails')) {
            ?>
						<div class="imagecol">
							<?php 
            if (wpsc_the_product_thumbnail()) {
                ?>
								<a rel="<?php 
                echo str_replace(array(" ", '"', "'", '&quot;', '&#039;'), array("_", "", "", "", ''), wpsc_the_product_title());
                ?>
" class="thickbox preview_link" href="<?php 
                echo wpsc_the_product_image();
                ?>
">
									<img class="product_image" id="product_image_<?php 
                echo wpsc_the_product_id();
                ?>
" alt="<?php 
                echo wpsc_the_product_title();
                ?>
" title="<?php 
                echo wpsc_the_product_title();
                ?>
" src="<?php 
                echo wpsc_the_product_thumbnail();
                ?>
"/>
			<?php endwhile; ?>
		</div>
	<?php endif; ?>
	
	<?php do_action('wpsc_top_of_products_page'); // Plugin hook for adding things to the top of the products page, like the live search ?>
	
	<div class="productdisplay">
	<?php /** start the product loop here, this is single products view, so there should be only one */?>
		<?php while (wpsc_have_products()) :  wpsc_the_product(); ?>
			<div class="single_product_display product_view_<?php echo wpsc_the_product_id(); ?>">
				<div class="textcol">
					<?php if(get_option('show_thumbnails')) :?>
					<div class="imagecol">
						<?php if(wpsc_the_product_thumbnail()) :?>
								<a rel="<?php echo str_replace(array(" ", '"',"'", '&quot;','&#039;'), array("_", "", "", "",''), wpsc_the_product_title()); ?>" class="thickbox preview_link" href="<?php echo wpsc_the_product_image(); ?>">
									<img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_image($image_width, $image_height); ?>" />
								</a>
						<?php else: ?> 
							<div class="item_no_image">
								<a href="<?php echo wpsc_the_product_permalink(); ?>">
								<span>No Image Available</span>
								</a>
							</div>
						<?php endif; ?> 
					</div>
					<?php endif; ?> 
		
					<div class="producttext">
						<h2 class="prodtitles"><span><?php echo wpsc_the_product_title(); ?></span><?php echo wpsc_edit_the_product_link(); ?></h2>
							<?php				
								do_action('wpsc_product_before_description', wpsc_the_product_id(), $wpsc_query->product);
 */
while (wpsc_have_products()) {
    wpsc_the_product();
    ?>
					<div class="imagecol">
						<?php 
    if (wpsc_the_product_thumbnail()) {
        ?>
								<a rel="<?php 
        echo wpsc_the_product_title();
        ?>
" class="<?php 
        echo wpsc_the_product_image_link_classes();
        ?>
" href="<?php 
        echo esc_url(wpsc_the_product_image());
        ?>
">
									<img class="product_image" id="product_image_<?php 
        echo wpsc_the_product_id();
        ?>
" alt="<?php 
        echo wpsc_the_product_title();
        ?>
" title="<?php 
        echo wpsc_the_product_title();
        ?>
" src="<?php 
        echo wpsc_the_product_thumbnail();
        ?>
"/>
					Showing all <?php echo wpsc_total_product_count(); ?> products
				<?php endif; ?>
			</div>
		<?php endif; ?>
		<!-- End Pagination -->
		
		
	<?php /** start the product loop here */?>
	<?php while (wpsc_have_products()) :  wpsc_the_product(); ?>
		<div class="productdisplay default_product_display product_view_<?php echo wpsc_the_product_id(); ?> <?php echo wpsc_category_class(); ?>">      
			<div class="textcol">
			
				<?php if(get_option('show_thumbnails')) :?>
					<div class="imagecol">
						<?php if(wpsc_the_product_thumbnail()) :?>
							<a rel="<?php echo str_replace(array(" ", '"',"'", '&quot;','&#039;'), array("_", "", "", "",''), wpsc_the_product_title()); ?>" class="thickbox preview_link" href="<?php echo wpsc_the_product_image(); ?>">
									<img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>" />
							</a>
						<?php else: ?>
							<div class="item_no_image">
								<a href="<?php echo wpsc_the_product_permalink(); ?>">
									<span>No Image Available</span>
								</a>
							</div>
						<?php endif; ?>
					</div>
				<?php endif; ?>
			
				<div class="producttext">
					<h2 class="prodtitles">
					  <?php if(get_option('hide_name_link') == 1) : ?>
" title="<?php 
        echo str_replace(array(" ", '"', "'", '&quot;', '&#039;'), array("_", "", "", "", ''), wpsc_the_product_title());
        ?>
"><img src="<?php 
        echo wpsc_the_product_image($new_width, $new_height);
        ?>
" alt="" /></a><br class="clear" />
						</div>
						<div class="image_thumb">
						    <ul>
						    	<li>
						            <a href="<?php 
        echo wpsc_the_product_image($new_width, $new_height);
        ?>
" rel="main image"><img src="<?php 
        echo wpsc_the_product_image(120, 109);
        ?>
" alt="<?php 
        echo wpsc_the_product_title();
        ?>
" /></a>
						        </li> 
						      	<?php 
        $count = 1;
        if (count($images) > 0) {
            if ($images != null) {
                foreach ($images as $image) {
                    $extra_imagepath = WPSC_IMAGE_DIR . $image['image'] . "";
                    $extra_image_size = @getimagesize($extra_imagepath);
                    $thickbox_link = WPSC_IMAGE_URL . $image['image'] . "";
                    $image_link = "index.php?image_id=" . $image['id'] . "&amp;width=" . $new_width . "&amp;height=" . $new_height . "";
 if ($NV_datasource == 'data-5') {
     if (class_exists('Woocommerce')) {
         global $product, $woocommerce;
         $thumbnail_id = get_post_thumbnail_id($post->ID);
         $size = "large";
         $image_src = wp_get_attachment_image_src($thumbnail_id, $size, false);
         // Get attached image URL
         $NV_previewimgurl = $image_src[0];
         if (empty($NV_previewimgurl)) {
             $NV_previewimgurl = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
         }
         $NV_productprice = $product->get_price_html();
         // Product Price
     }
     if (class_exists('WPSC_Query')) {
         $NV_previewimgurl = wpsc_the_product_image();
         // Product Image
         $NV_productprice = wpsc_the_product_price();
         // Product Price
     }
     $NV_previewimgurl = parse_url($NV_previewimgurl, PHP_URL_PATH);
     // make relative Image URL
 } else {
     $NV_previewimgurl = get_post_meta($post->ID, '_cmb_previewimgurl', true);
     // Preview Image URL
 }
 $image = catch_image();
 // Check for images within post
 // check what image to use, custom, featured, image within post.
 if (empty($NV_previewimgurl)) {
     $post_image_id = get_post_thumbnail_id($post->ID);
function getSliderProducts($products)
{
    $products = explode(",", $products);
    global $wpsc_query, $wpdb;
    foreach ($products as $product) {
        $image_width = get_option('single_view_image_width');
        $image_height = get_option('single_view_image_height');
        $options = get_option('site_basic_options');
        $wpsc_query = new WPSC_Query(array('product_id' => $product));
        while (wpsc_have_products()) {
            wpsc_the_product();
            ?>
			<li class="feature-product">
			<?php 
            if (wpsc_the_product_thumbnail()) {
                ?>
			<div class="product-image">
				<a rel="<?php 
                echo str_replace(array(" ", '"', "'", '&quot;', '&#039;'), array("_", "", "", "", ''), wpsc_the_product_title());
                ?>
" class="thickbox preview_link" href="<?php 
                echo wpsc_the_product_image();
                ?>
">
					<img class="product_image" id="product_image_<?php 
                echo wpsc_the_product_id();
                ?>
" alt="<?php 
                echo wpsc_the_product_title();
                ?>
" title="<?php 
                echo wpsc_the_product_title();
                ?>
" src="<?php 
                if ($options['themelayout'] == 'boxed') {
                    bloginfo('template_url');
                    ?>
/timthumb.php?src=<?php 
                    echo wpsc_the_product_image($image_width, $image_height);
                    ?>
&w=457<?php 
                } else {
                    echo wpsc_the_product_image($image_width, $image_height);
                }
                ?>
" />
				</a>
			</div>
			<?php 
            } else {
                ?>
				<div class="product-image product-thumb item_no_image">
					<a href="<?php 
                echo wpsc_the_product_permalink();
                ?>
">
					<span><?php 
                _e('No Image Available', 'flexishop');
                ?>
</span>
					</a>
				</div>
			<?php 
            }
            ?>
			<div class="product-content">
			<h2 class="prodtitles">
				<?php 
            if (get_option('hide_name_link') == 1) {
                ?>
					<span><?php 
                echo wpsc_the_product_title();
                ?>
</span>
				<?php 
            } else {
                ?>
 
					<a class="wpsc_product_title" href="<?php 
                echo wpsc_the_product_permalink();
                ?>
"><?php 
                echo wpsc_the_product_title();
                ?>
</a>
				<?php 
            }
            ?>
 				
			</h2>
			<!-- <div class="wpsc_product_price">
			<?php 
            if (wpsc_product_is_donation()) {
                ?>
				<label for='donation_price_<?php 
                echo wpsc_the_product_id();
                ?>
'><?php 
                echo __('Donation', 'flexishop');
                ?>
:</label>
				<input type='text' id='donation_price_<?php 
                echo wpsc_the_product_id();
                ?>
' name='donation_price' value='<?php 
                echo $wpsc_query->product['price'];
                ?>
' size='6' />
				<br />
			
			
			<?php 
            } else {
                ?>
				<?php 
                if (wpsc_product_on_special()) {
                    ?>
					<span class='oldprice'><?php 
                    echo __('Price', 'flexishop');
                    ?>
: <?php 
                    echo wpsc_product_normal_price(get_option('wpsc_hide_decimals'));
                    ?>
</span><br />
				<?php 
                }
                ?>
				<span id="product_price_<?php 
                echo wpsc_the_product_id();
                ?>
" class="pricedisplay <?php 
                if (wpsc_product_on_special()) {
                    echo "sale-price";
                }
                ?>
"><?php 
                if (wpsc_product_on_special()) {
                    echo __("Sale Price: ", 'flexishop');
                }
                echo wpsc_the_product_price(get_option('wpsc_hide_decimals'));
                ?>
</span>					
			<?php 
            }
            ?>
			</div> -->
			<?php 
            if (wpsc_the_product_additional_description()) {
                ?>
			<div class="description">
			<?php 
                $value = '';
                $the_addl_desc = wpsc_the_product_additional_description();
                if (is_serialized($the_addl_desc)) {
                    $addl_descriptions = @unserialize($the_addl_desc);
                } else {
                    $addl_descriptions = array('addl_desc', $the_addl_desc);
                }
                if (isset($addl_descriptions['addl_desc'])) {
                    $value = $addl_descriptions['addl_desc'];
                }
                if (function_exists('wpsc_addl_desc_show')) {
                    echo wpsc_addl_desc_show($addl_descriptions);
                } else {
                    echo stripslashes(wpautop($the_addl_desc, $br = 1));
                }
                ?>
			</div>
			<?php 
            }
            ?>
			<a href="<?php 
            echo wpsc_the_product_permalink();
            ?>
" class="buy-now"><?php 
            _e('Buy Now', 'flexishop');
            ?>
</a>
			</div>
		</li>
		<?php 
        }
    }
}
Exemple #10
0
			<div id="thickbox_<?php 
        echo wpsc_the_product_id();
        ?>
" style="display:none">
			    <div class="left_panel" style="display:block;float:left;width:434px;">
                    <img class="product_image" id="product_image_<?php 
        echo wpsc_the_product_id();
        ?>
" alt="<?php 
        echo wpsc_the_product_title();
        ?>
" title="<?php 
        echo wpsc_the_product_title();
        ?>
" src="<?php 
        echo wpsc_the_product_image(400, 400);
        ?>
"/><br>
                </div>
                <div class="right_panel" style="display:block;float:left;">
                    <h1><?php 
        echo wpsc_the_product_title();
        ?>
</h1>
                    
					<?php 
        do_action('wpsc_product_before_description', wpsc_the_product_id(), $wpsc_query->product);
        do_action('wpsc_product_addons', wpsc_the_product_id());
        ?>
					
                    <div class='wpsc_description'>
 public function send_product()
 {
     if (wpsc_is_single_product()) {
         $product = array();
         while (wpsc_have_products()) {
             wpsc_the_product();
             $product_id = (int) wpsc_the_product_id();
             $product['url'] = (string) wpsc_the_product_permalink();
             $product['product_id'] = $product_id;
             $product['name'] = (string) wpsc_the_product_title();
             $product['image_url'] = (string) wpsc_the_product_image('', '', $product_id);
             if (wpsc_product_has_variations($product_id)) {
                 $price = $this->get_lowest_product_variation_price($product_id);
             } else {
                 $price = wpsc_calculate_price($product_id, false, true);
             }
             $product['price'] = $this->format_price($price);
             if (wpsc_product_has_stock($product_id)) {
                 $product['stock'] = 1;
             } else {
                 $product['stock'] = 0;
             }
             $product['categories'] = array();
             $category_terms = wp_get_product_categories($product_id);
             foreach ($category_terms as $category_term) {
                 $category_path = $category_term;
                 if (!empty($category_path)) {
                     $product['category_name'] = $category_term->name;
                     $product['category_id'] = $category_term->term_id;
                 }
             }
             if (wpsc_product_has_variations($product_id)) {
                 $list_price = $this->get_lowest_product_variation_price($product_id);
             } else {
                 $list_price = wpsc_calculate_price($product_id, false, false);
             }
             $product['list_price'] = $this->format_price($list_price);
         }
         if (!empty($product)) {
             $this->render('sendProduct', array('product' => $product));
         }
     }
 }