Example #1
0
/**
 * Related Products
 */
function get_related_products($product_id, $cats_search = true, $width, $height, $number = 20)
{
    global $wpdb;
    // Related products are found from category and tag
    $tags_array = array(0);
    $cats_array = array(0);
    $tags = '';
    $cats = '';
    // Get tags
    $terms = wp_get_post_terms($product_id, 'product_tag');
    foreach ($terms as $term) {
        $tags_array[] = $term->term_id;
    }
    $tags = implode(',', $tags_array);
    $terms = wp_get_post_terms($product_id, 'wpsc_product_category');
    foreach ($terms as $term) {
        $cats_array[] = $term->term_id;
    }
    $cats = implode(',', $cats_array);
    if ($cats_search) {
        $cats_search = "\n\t\t\t\t(\n\t\t\t\t\ttt.taxonomy ='wpsc_product_category'\n\t\t\t\t\tAND tt.term_taxonomy_id = tr.term_taxonomy_id\n\t\t\t\t\tAND tr.object_id  = p.ID\n\t\t\t\t\tAND tt.term_id IN ({$cats})\n\t\t\t\t)\n\t\t\t\tOR \n        ";
    } else {
        $cats_search = '';
    }
    $q = "\n\t\tSELECT p.ID\n\t\tFROM {$wpdb->term_taxonomy} AS tt, {$wpdb->term_relationships} AS tr, {$wpdb->posts} AS p\n\t\tWHERE \n\t\t\tp.ID != {$product_id}\n\t\t\tAND p.post_status = 'publish'\n\t\t\tAND p.post_type = 'wpsc-product'\n\t\t\tAND\n\t\t\t(\n                {$cats_search}\n\t\t\t\t(\n\t\t\t\t\ttt.taxonomy ='product_tag'\n\t\t\t\t\tAND tt.term_taxonomy_id = tr.term_taxonomy_id\n\t\t\t\t\tAND tr.object_id  = p.ID\n\t\t\t\t\tAND tt.term_id IN ({$tags})\n\t\t\t\t)\n\t\t\t)\n\t\tGROUP BY tr.object_id\n\t\tORDER BY RAND()\n\t\tLIMIT {$number};";
    $related = $wpdb->get_col($q);
    if (sizeof($related) > 0) {
        $args = array('post__in' => $related, 'post__not_in' => array($product_id), 'post_type' => 'wpsc-product', 'ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'orderby' => 'rand');
        $related_query = new WP_Query($args);
        if ($related_query->have_posts()) {
            $_i = 0;
            while ($related_query->have_posts()) {
                $related_query->the_post();
                $_i++;
                $id = get_the_ID();
                $variants_exist = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE `post_parent`={$id} AND `post_type`='wpsc-product'", 'ARRAY_A');
                $related_array[$_i]['id'] = get_the_ID();
                $related_array[$_i]['title'] = esc_attr(get_the_title());
                $related_array[$_i]['image'] = etheme_get_image(0, $width, $height, false, $id);
                $related_array[$_i]['permalink'] = get_permalink();
                if ($variants_exist) {
                    if (wpsc_product_on_special($id)) {
                        $related_array[$_i]['normal_price'] = wpsc_product_normal_price($id);
                        $related_array[$_i]['price'] = wpsc_the_product_price($id);
                    } else {
                        $related_array[$_i]['normal_price'] = 0;
                        $related_array[$_i]['price'] = wpsc_the_product_price($id);
                    }
                } else {
                    $related_array[$_i]['normal_price'] = the_product_price($id);
                    $related_array[$_i]['price'] = the_product_price($id, true);
                }
                unset($variants_exist);
            }
        }
        wp_reset_postdata();
    }
    return $related_array;
}
 /**
  * Adds product properties to analytics.track() when product is viewed.
  *
  * @since  1.0.0
  * @access public
  *
  * @uses  func_get_args() Because our abstract class doesn't know how many parameters are passed to each hook
  *                        for each different platform, we use func_get_args().
  *
  * @return array Filtered array of name and properties for analytics.track().
  */
 public function viewed_product()
 {
     $args = func_get_args();
     $track = $args[0];
     if (is_singular('wpsc-product')) {
         $track = array('event' => __('Viewed Product', 'segment'), 'properties' => array('id' => get_the_ID(), 'sku' => wpsc_product_sku(), 'name' => wpsc_the_product_title(), 'price' => wpsc_string_to_float(wpsc_the_product_price()), 'category' => implode(', ', wp_list_pluck(wpsc_get_product_terms(get_the_ID(), 'wpsc_product_category'), 'name'))));
     }
     return $track;
 }
					<td width="55%">
						<a class="wpsc_product_title" href="<?php echo wpsc_the_product_permalink(); ?>">
							<strong><?php echo wpsc_the_product_title(); ?></strong>
						</a>
					</td>
					
					<td width="10" style="text-align: center;">
						<?php if(wpsc_product_has_stock()) : ?>
							<img src="<?php echo WPSC_URL; ?>/images/yes_stock.gif" alt="Yes" title="Yes" style="margin-top: 4px;"/>
						<?php else: ?> 
							<img src="<?php echo WPSC_URL; ?>/images/no_stock.gif" title='No' alt='No' style="margin-top: 4px;"/>
						<?php endif; ?> 
					</td>
					
					<td width="10%">
						<span id="product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay"><?php echo wpsc_the_product_price(); ?></span>
					</td>
					
					<td width="20%">
						<?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
							<?php	$action =  wpsc_product_external_link(wpsc_the_product_id()); ?>
						<?php else: ?>
							<?php	$action =  wpsc_this_page_url(); ?>						
						<?php endif; ?>
						<form class='product_form'  enctype="multipart/form-data" action="<?php echo $action; ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>">

							<?php /** the variation group HTML and loop */?>
							<div class="wpsc_variation_forms">
								<?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
									<p>
										<label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label>
function wpsc_the_product_price_display($args = array())
{
    if (empty($args['id'])) {
        $id = get_the_ID();
    } else {
        $id = (int) $args['id'];
    }
    $defaults = array('id' => $id, 'old_price_text' => __('Old Price: %s', 'wp-e-commerce'), 'price_text' => __('Price: %s', 'wp-e-commerce'), 'you_save_text' => __('You save: %s', 'wp-e-commerce'), 'old_price_class' => 'pricedisplay wpsc-product-old-price ' . $id, 'old_price_before' => '<p %s>', 'old_price_after' => '</p>', 'old_price_amount_id' => 'old_product_price_' . $id, 'old_price_amount_class' => 'oldprice', 'old_price_amount_before' => '<span class="%1$s" id="%2$s">', 'old_price_amount_after' => '</span>', 'price_amount_id' => 'product_price_' . $id, 'price_class' => 'pricedisplay wpsc-product-price ' . $id, 'price_before' => '<p %s>', 'price_after' => '</p>', 'price_amount_class' => 'currentprice pricedisplay ' . $id, 'price_amount_before' => '<span class="%1$s" id="%2$s">', 'price_amount_after' => '</span>', 'you_save_class' => 'pricedisplay wpsc-product-you-save product_' . $id, 'you_save_before' => '<p %s>', 'you_save_after' => '</p>', 'you_save_amount_id' => 'yousave_' . $id, 'you_save_amount_class' => 'yousave', 'you_save_amount_before' => '<span class="%1$s" id="%2$s">', 'you_save_amount_after' => '</span>', 'output_price' => true, 'output_old_price' => true, 'output_you_save' => true);
    $r = wp_parse_args($args, $defaults);
    /**
     * wpsc_the_product_price_display_args filter args for product price display
     *
     * Paramters used to format price display can be set globally using this filter
     *
     * @since 4.0
     *
     * @type array $args array of parameters used to format product price
     * @type int $product_id WPeC Product ID for the current product
     */
    $r = apply_filters('wpsc_the_product_price_display_args', $r, $id);
    extract($r);
    // if the product has no variations, these amounts are straight forward...
    $old_price = wpsc_product_normal_price($id);
    $current_price = wpsc_the_product_price(false, false, $id);
    $you_save = wpsc_you_save(array('type' => 'amount', 'product_id' => $id));
    $show_old_price = $show_you_save = wpsc_product_on_special($id);
    // Don't output old price HTML if not on sale.
    if (!wpsc_product_on_special($id)) {
        $output_old_price = $output_you_save = false;
    }
    // but if the product has variations and at least one of the variations is on special, we have
    // a few edge cases...
    if (wpsc_product_has_variations($id) && wpsc_product_on_special($id)) {
        // generally it doesn't make sense to display "you save" amount unless the user has selected
        // a specific variation
        $show_you_save = false;
        $old_price_number = wpsc_product_variation_price_from($id, array('only_normal_price' => true));
        $current_price_number = wpsc_product_variation_price_from($id);
        // if coincidentally, one of the variations are not on special, but its price is equal to
        // or lower than the lowest variation sale price, old price should be hidden, and current
        // price should reflect the "normal" price, not the sales price, to avoid confusion
        if ($old_price_number == $current_price_number) {
            $show_old_price = false;
            $current_price = wpsc_product_normal_price($id);
        }
    }
    // replace placeholders in arguments with correct values
    $old_price_class = apply_filters('wpsc_the_product_price_display_old_price_class', $old_price_class, $id);
    $old_price_amount_class = apply_filters('wpsc_the_product_price_display_old_price_amount_class', $old_price_amount_class, $id);
    $attributes = 'class="' . esc_attr($old_price_class) . '"';
    if (!$show_old_price) {
        $attributes .= ' style="display:none;"';
    }
    $old_price_before = sprintf($old_price_before, $attributes);
    $old_price_amount_before = sprintf($old_price_amount_before, esc_attr($old_price_amount_class), esc_attr($old_price_amount_id));
    $price_class = 'class="' . esc_attr(apply_filters('wpsc_the_product_price_display_price_class', esc_attr($price_class), $id)) . '"';
    $price_amount_class = apply_filters('wpsc_the_product_price_display_price_amount_class', esc_attr($price_amount_class), $id);
    $price_before = sprintf($price_before, $price_class);
    $price_amount_before = sprintf($price_amount_before, esc_attr($price_amount_class), esc_attr($price_amount_id));
    $you_save_class = apply_filters('wpsc_the_product_price_display_you_save_class', $you_save_class, $id);
    $you_save_amount_class = apply_filters('wpsc_the_product_price_display_you_save_amount_class', $you_save_amount_class, $id);
    $attributes = 'class="' . esc_attr($you_save_class) . '"';
    if (!$show_you_save) {
        $attributes .= ' style="display:none;"';
    }
    $you_save_before = sprintf($you_save_before, $attributes);
    $you_save_amount_before = sprintf($you_save_amount_before, esc_attr($you_save_amount_class), esc_attr($you_save_amount_id));
    $you_save = wpsc_currency_display($you_save);
    $old_price = $old_price_amount_before . $old_price . $old_price_amount_after;
    $current_price = $price_amount_before . $current_price . $price_amount_after;
    $you_save = $you_save_amount_before . $you_save . $you_save_amount_after;
    $old_price_text = sprintf($old_price_text, $old_price);
    $price_text = sprintf($price_text, $current_price);
    $you_save_text = sprintf($you_save_text, $you_save);
    if ($output_old_price) {
        echo $old_price_before . $old_price_text . $old_price_after . "\n";
    }
    if ($output_price) {
        echo $price_before . $price_text . $price_after . "\n";
    }
    if ($output_you_save) {
        echo $you_save_before . $you_save_text . $you_save_after . "\n";
    }
}
						<input type="hidden" name="wpsc_update_quantity" value="true"/>
						</fieldset>
					<?php endif ;?>
					
						<div class="wpsc_product_price">
							<?php if(wpsc_product_is_donation()) : ?>
								<label for='donation_price_<?php echo wpsc_the_product_id(); ?>'><?php echo __('Donation', 'wpsc'); ?>:</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', 'wpsc'); ?>: <?php echo wpsc_product_normal_price(); ?></span><br />
								<?php endif; ?>
								<span id="product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay"><?php echo wpsc_the_product_price(); ?></span><?php echo __('Price', 'wpsc'); ?>:  <br/>
								<!-- multi currency code -->
								<?php if(wpsc_product_has_multicurrency()) : ?>
								<?php echo wpsc_display_product_multicurrency(); ?>
								<?php endif; ?>
								<!-- end multi currency code -->
								<?php if(get_option('display_pnp') == 1) : ?>
									<span class="pricedisplay"><?php echo wpsc_product_postage_and_packaging(); ?></span><?php echo __('P&amp;P', 'wpsc'); ?>:  <br />
								<?php endif; ?>							
							<?php endif; ?>
						</div>
					<?php if(function_exists('wpsc_akst_share_link') && (get_option('wpsc_share_this') == 1)) {
						echo wpsc_akst_share_link('return');
					} ?>
						
					<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
/**
 * wpsc normal product price function
 * TODO determine why this function is here
 * @return string - returns some form of product price
 */
function wpsc_product_normal_price()
{
    return wpsc_the_product_price(false, true);
}
						</a>
					</div>
				<?php endif; ?> 
				
					
				<?php if(get_option('show_images_only') != 1): ?>
					<div class="grid_product_info">
						<div class="product_text">
							<strong><?php echo wpsc_the_product_title(); ?></strong>
							
						<?php if((wpsc_the_product_description() != '') && (get_option('display_description') == 1)): ?>
							<p class='griddescription'><?php echo wpsc_the_product_description(); ?></p>
						<?php endif; ?>
							
							<br/>
							<span class="pricedisplay"><?php echo wpsc_the_product_price(); ?></span>Price: 
							
						<?php if(get_option('display_moredetails') == 1) : ?>
							<br />
							<a href='<?php echo wpsc_the_product_permalink(); ?>'>More Details</a>
						<?php endif; ?> 
						</div>
					</div>
					<div class="grid_more_info">
						<form class='product_form'  enctype="multipart/form-data" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_<?php echo wpsc_the_product_id(); ?>" >
							<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
							<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
							
							
							<?php if(get_option('display_variations') == 1) : ?>
								<?php /** the variation group HTML and loop */ ?>
/**
 ***************************** 
 *** FOR WPEC VERSION 3.9+ ***
 *****************************  
 COPIED FROM WPSC-INCLUDES/PRODUCT-TEMPLATE.PHP  WPEC VERSION 3.8.10  
* WPSC The Product Price Display
*
* @param  $args  (array)   Array of args.
* @return        (string)  HTML formatted prices
*
* @uses   apply_filters()                      Calls 'wpsc_the_product_price_display_old_price_class' passing class and product ID
* @uses   apply_filters()                      Calls 'wpsc_the_product_price_display_old_price_amount_class' passing class and product ID
* @uses   apply_filters()                      Calls 'wpsc_the_product_price_display_price_class' passing class and product ID
* @uses   apply_filters()                      Calls 'wpsc_the_product_price_display_price_amount_class' passing class and product ID
* @uses   apply_filters()                      Calls 'wpsc_the_product_price_display_you_save_class' passing class and product ID
* @uses   apply_filters()                      Calls 'wpsc_the_product_price_display_you_save_amount_class' passing class and product ID
* @uses   wpsc_product_normal_price()          Get the normal price
* @uses   wpsc_the_product_price()             Get the current price
* @uses   wpsc_you_save()                      Get pricing saving
* @uses   wpsc_product_on_special()            Is product on sale?
* @uses   wpsc_product_has_variations()        Checks if product has variations
* @uses   wpsc_product_variation_price_from()  Gets the lowest variation price
* @uses   wpsc_currency_display()              Display price as currency
*/
function vtprd_the_product_price_display($args = array())
{
    global $vtprd_info, $vtprd_setup_options;
    if (empty($args['id'])) {
        $id = get_the_ID();
    } else {
        $id = (int) $args['id'];
    }
    //-+--+-+-+-+-+-+-+-+-+-+-++--+-+-+-+-+-+-+-+-+-+-++--+-+-+-+-+-+-+-+-+-+-+
    //  if $id is a variation and has a parent, sent the PARENT!!!
    //gets all of the info we need and puts it into 'product_session_info'
    vtprd_get_product_session_info($id);
    //-+--+-+-+-+-+-+-+-+-+-+-++--+-+-+-+-+-+-+-+-+-+-++--+-+-+-+-+-+-+-+-+-+-+
    //  if $id is a variation, refigure product_yousave_total_amt!!
    //refigure yousave amts for WPEC
    if (VTPRD_PARENT_PLUGIN_NAME == 'WP E-Commerce') {
        vtprd_WPEC_recompute_theme_amts();
    }
    //if we have no yousave amt, do the default routine and exit
    if ($vtprd_info['product_session_info']['product_yousave_total_amt'] == 0) {
        wpsc_the_product_price_display($args);
        return;
    }
    $defaults = array('id' => $id, 'old_price_text' => __('Old Price: %s', 'wpsc'), 'price_text' => __('Price: %s', 'wpsc'), 'you_save_text' => __('You save: %s', 'wpsc'), 'old_price_class' => 'pricedisplay wpsc-product-old-price ' . $id, 'old_price_before' => '<p %s>', 'old_price_after' => '</p>', 'old_price_amount_id' => 'old_product_price_' . $id, 'old_price_amount_class' => 'oldprice', 'old_price_amount_before' => '<span class="%1$s" id="%2$s">', 'old_price_amount_after' => '</span>', 'price_amount_id' => 'product_price_' . $id, 'price_class' => 'pricedisplay wpsc-product-price ' . $id, 'price_before' => '<p %s>', 'price_after' => '</p>', 'price_amount_class' => 'currentprice pricedisplay ' . $id, 'price_amount_before' => '<span class="%1$s" id="%2$s">', 'price_amount_after' => '</span>', 'you_save_class' => 'pricedisplay wpsc-product-you-save product_' . $id, 'you_save_before' => '<p %s>', 'you_save_after' => '</p>', 'you_save_amount_id' => 'yousave_' . $id, 'you_save_amount_class' => 'yousave', 'you_save_amount_before' => '<span class="%1$s" id="%2$s">', 'you_save_amount_after' => '</span>', 'output_price' => true, 'output_old_price' => true, 'output_you_save' => true);
    $r = wp_parse_args($args, $defaults);
    extract($r);
    $amt = $vtprd_info['product_session_info']['product_list_price'];
    $amt = vtprd_format_money_element($amt);
    $old_price = $amt;
    $amt = $vtprd_info['product_session_info']['product_yousave_total_amt'];
    $amt = vtprd_format_money_element($amt);
    $you_save = $amt . '! (' . $vtprd_info['product_session_info']['product_yousave_total_pct'] . '%)';
    $you_save_percentage = $vtprd_info['product_session_info']['product_yousave_total_pct'];
    // if the product has no variations, these amounts are straight forward...
    //	$old_price           = wpsc_product_normal_price( $id );
    $current_price = wpsc_the_product_price(false, false, $id);
    //	$you_save            = wpsc_you_save( 'type=amount' ) . '! (' . wpsc_you_save() . '%)';
    //	$you_save_percentage = wpsc_you_save();
    //	$show_old_price = $show_you_save = wpsc_product_on_special( $id );
    /*
    	// but if the product has variations and at least one of the variations is on special, we have
    	// a few edge cases...
    	if ( wpsc_product_has_variations( $id ) && wpsc_product_on_special( $id ) ) {
    		// generally it doesn't make sense to display "you save" amount unless the user has selected
    		// a specific variation
    		$show_you_save = false;
    
    		$old_price_number = wpsc_product_variation_price_from( $id, array( 'only_normal_price' => true ) );
    		$current_price_number = wpsc_product_variation_price_from( $id );
    
    		// if coincidentally, one of the variations are not on special, but its price is equal to
    		// or lower than the lowest variation sale price, old price should be hidden, and current
    		// price should reflect the "normal" price, not the sales price, to avoid confusion
    		if ( $old_price_number == $current_price_number ) {
    			$show_old_price = false;
    			$current_price = wpsc_product_normal_price( $id );
    		}
    	}
    */
    // replace placeholders in arguments with correct values
    $old_price_class = apply_filters('wpsc_the_product_price_display_old_price_class', $old_price_class, $id);
    $old_price_amount_class = apply_filters('wpsc_the_product_price_display_old_price_amount_class', $old_price_amount_class, $id);
    $attributes = 'class="' . esc_attr($old_price_class) . '"';
    //	if ( ! $show_old_price )
    //		$attributes .= ' style="display:none;"';
    $old_price_before = sprintf($old_price_before, $attributes);
    $old_price_amount_before = sprintf($old_price_amount_before, esc_attr($old_price_amount_class), esc_attr($old_price_amount_id));
    $price_class = 'class="' . esc_attr(apply_filters('wpsc_the_product_price_display_price_class', esc_attr($price_class), $id)) . '"';
    $price_amount_class = apply_filters('wpsc_the_product_price_display_price_amount_class', esc_attr($price_amount_class), $id);
    $price_before = sprintf($price_before, $price_class);
    $price_amount_before = sprintf($price_amount_before, esc_attr($price_amount_class), esc_attr($price_amount_id));
    $you_save_class = apply_filters('wpsc_the_product_price_display_you_save_class', $you_save_class, $id);
    $you_save_amount_class = apply_filters('wpsc_the_product_price_display_you_save_amount_class', $you_save_amount_class, $id);
    $attributes = 'class="' . esc_attr($you_save_class) . '"';
    //	if ( ! $show_you_save )
    //		$attributes .= ' style="display:none;"';
    $you_save_before = sprintf($you_save_before, $attributes);
    $you_save_amount_before = sprintf($you_save_amount_before, esc_attr($you_save_amount_class), esc_attr($you_save_amount_id));
    //	$you_save = wpsc_currency_display ( $you_save );
    $old_price = $old_price_amount_before . $old_price . $old_price_amount_after;
    $current_price = $price_amount_before . $current_price . $price_amount_after;
    $you_save = $you_save_amount_before . $you_save . $you_save_amount_after;
    $old_price_text = sprintf($old_price_text, $old_price);
    $price_text = sprintf($price_text, $current_price);
    $you_save_text = sprintf($you_save_text, $you_save);
    // if ( $vtprd_setup_options['show_old_price'] == 'yes' ) {
    if ($output_old_price && $old_price_text > ' ') {
        echo $old_price_before . $old_price_text . $old_price_after . "\n";
    }
    if ($output_price) {
        echo $price_before . $price_text . $price_after . "\n";
    }
    // if ( $vtprd_setup_options['show_you_save'] == 'yes' ) {
    if ($output_you_save) {
        if ($you_save_text > ' ') {
            echo $you_save_before . $you_save_text . $you_save_after . "\n";
        } else {
            if ($vtprd_info['product_session_info']['show_yousave_one_some_msg'] > ' ') {
                echo $vtprd_info['product_session_info']['show_yousave_one_some_msg'] . "\n";
            }
        }
    }
    return;
}
					<td width="55%">
						<a class="wpsc_product_title" href="<?php echo wpsc_the_product_permalink(); ?>">
							<strong><?php echo wpsc_the_product_title(); ?></strong>
						</a>
					</td>
					
					<td width="10" style="text-align: center;">
						<?php if(wpsc_product_has_stock()) : ?>
							<img src="<?php echo WPSC_URL; ?>/images/yes_stock.gif" alt="Yes" title="Yes" style="margin-top: 4px;"/>
						<?php else: ?> 
							<img src="<?php echo WPSC_URL; ?>/images/no_stock.gif" title='No' alt='No' style="margin-top: 4px;"/>
						<?php endif; ?> 
					</td>
					
					<td width="10%">
						<span id="product_price_<?php echo wpsc_the_product_id(); ?>" class="pricedisplay"><?php echo wpsc_the_product_price(get_option('wpsc_hide_decimals')); ?></span>
					</td>
					
					<td width="20%">
						<?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
							<?php	$action =  wpsc_product_external_link(wpsc_the_product_id()); ?>
						<?php else: ?>
							<?php	$action =  wpsc_this_page_url(); ?>						
						<?php endif; ?>
						<form id="product_<?php echo wpsc_the_product_id(); ?>" class='product_form'  enctype="multipart/form-data" action="<?php echo $action; ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>">

							<?php /** the variation group HTML and loop */?>
							<div class="wpsc_variation_forms">
								<?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
									<p>
										<label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label>
     }
     $html_content .= '</div>';
 } elseif ($item_key == 'WPeC_old_price') {
     $html_content .= '<div class="element element_' . $item_id . ' ' . $item_key . '"  >';
     $is_product = get_post_type(get_the_ID());
     $active_plugins = get_option('active_plugins');
     if (in_array('wp-e-commerce/wp-shopping-cart.php', (array) $active_plugins) && $is_product == 'wpsc-product') {
         $html_content .= wpsc_product_normal_price();
     }
     $html_content .= '</div>';
 } elseif ($item_key == 'WPeC_sale_price') {
     $html_content .= '<div class="element element_' . $item_id . ' ' . $item_key . '"  >';
     $is_product = get_post_type(get_the_ID());
     $active_plugins = get_option('active_plugins');
     if (in_array('wp-e-commerce/wp-shopping-cart.php', (array) $active_plugins) && $is_product == 'wpsc-product') {
         $html_content .= wpsc_the_product_price();
     }
     $html_content .= '</div>';
 } elseif ($item_key == 'WPeC_rating_star') {
     $html_content .= '<div class="element element_' . $item_id . ' ' . $item_key . '"  >';
     $is_product = get_post_type(get_the_ID());
     $active_plugins = get_option('active_plugins');
     if (in_array('wp-e-commerce/wp-shopping-cart.php', (array) $active_plugins) && $is_product == 'wpsc-product') {
         $html_content .= wpsc_product_rater();
     }
     $html_content .= '</div>';
 } elseif ($item_key == 'WPeC_categories') {
     $html_content .= '<div class="element element_' . $item_id . ' ' . $item_key . '"  >';
     $is_product = get_post_type(get_the_ID());
     $active_plugins = get_option('active_plugins');
     if (in_array('wp-e-commerce/wp-shopping-cart.php', (array) $active_plugins) && $is_product == 'wpsc-product') {
         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);
     if (!empty($post_image_id)) {
         $thumbnail = wp_get_attachment_image_src($post_image_id, false);
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 
        }
    }
}
Example #13
0
/**
 * Product Specials Widget content function
 *
 * Displays the latest products.
 *
 * @todo Remove marketplace theme specific code and maybe replce with a filter for the image output? (not required if themeable as above)
 *
 * Changes made in 3.8 that may affect users:
 *
 * 1. The product title link text does now not have a bold tag, it should be styled via css.
 * 2. <br /> tags have been ommitted. Padding and margins should be applied via css.
 * 3. Each product is enclosed in a <div> with a 'wpec-special-product' class.
 * 4. The product list is enclosed in a <div> with a 'wpec-special-products' class.
 * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output).
 */
function wpsc_specials($args = null, $instance)
{
    global $wpdb;
    $args = wp_parse_args((array) $args, array('number' => 5));
    $siteurl = get_option('siteurl');
    if (!($number = (int) $instance['number'])) {
        $number = 5;
    }
    $show_thumbnails = isset($instance['show_thumbnails']) ? (bool) $instance['show_thumbnails'] : FALSE;
    $show_description = isset($instance['show_description']) ? (bool) $instance['show_description'] : FALSE;
    $excludes = wpsc_specials_excludes();
    $args = array('post_type' => 'wpsc-product', 'caller_get_posts' => 1, 'post_status' => 'publish', 'post_parent' => 0, 'post__not_in' => $excludes, 'posts_per_page' => $number);
    $special_products = query_posts($args);
    $output = '';
    $product_ids[] = array();
    if (count($special_products) > 0) {
        list($wp_query, $special_products) = array($special_products, $wp_query);
        // swap the wpsc_query object
        while (wpsc_have_products()) {
            wpsc_the_product();
            if (!in_array(wpsc_the_product_id(), $product_ids)) {
                $product_ids[] = wpsc_the_product_id();
                if ($show_thumbnails) {
                    if (wpsc_the_product_thumbnail()) {
                        ?>
						<a rel="<?php 
                        echo str_replace(array(" ", '"', "'", '&quot;', '&#039;'), array("_", "", "", "", ''), wpsc_the_product_title());
                        ?>
" href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<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 {
                        ?>
							<a href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<img class="no-image" id="product_image_<?php 
                        echo wpsc_the_product_id();
                        ?>
" alt="No Image" title="<?php 
                        echo wpsc_the_product_title();
                        ?>
" src="<?php 
                        echo WPSC_URL;
                        ?>
/wpsc-theme/wpsc-images/noimage.png" width="<?php 
                        esc_attr_e(get_option('product_image_width'));
                        ?>
" height="<?php 
                        esc_attr_e(get_option('product_image_height'));
                        ?>
" />
							</a>
				<?php 
                    }
                    ?>
				<?php 
                }
                // close show thumbnails
                ?>
 
				<br />
				<span id="special_product_price_<?php 
                echo wpsc_the_product_id();
                ?>
">
				<!-- price display -->
				<?php 
                echo wpsc_the_product_price();
                ?>
				</span><br />			
				<strong><a class="wpsc_product_title" href="<?php 
                echo wpsc_product_url(wpsc_the_product_id(), false);
                ?>
"><?php 
                echo wpsc_the_product_title();
                ?>
</a></strong><br /> 
				
				<?php 
                if ($show_description) {
                    ?>
					<div class="wpsc-special-description">
						<?php 
                    echo wpsc_the_product_description();
                    ?>
					</div>									
				<?php 
                }
                // close show description
                ?>
 
			
				<?php 
            }
        }
        list($wp_query, $special_products) = array($special_products, $wp_query);
        // swap the wpsc_query object
        wp_reset_query();
    }
}
Example #14
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;
 }
                ?>
										<span class='oldprice'><?php 
                echo __('Price', 'wpsc');
                ?>
: <?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 
            echo wpsc_the_product_price(get_option('wpsc_hide_decimals'));
            ?>
</span><?php 
            echo __('Price', 'wpsc');
            ?>
:  <br/>
									<?php 
            if (get_option('display_pnp') == 1) {
                ?>
										<span class="pricedisplay"><?php 
                echo wpsc_product_postage_and_packaging(get_option('wpsc_hide_decimals'));
                ?>
</span><?php 
                echo __('P&amp;P', 'wpsc');
                ?>
:  <br />
            ?>
									<span class='oldprice'><?php 
            echo __('Price', 'wpsc');
            ?>
: <?php 
            echo wpsc_product_normal_price();
            ?>
</span><br />
								<?php 
        }
        ?>
								  <span id="product_price_<?php 
        echo wpsc_the_product_id();
        ?>
" class="pricedisplay"><?php 
        echo wpsc_the_product_price();
        ?>
</span><?php 
        echo __('Price', 'wpsc');
        ?>
:<br/>
								<?php 
        if (wpsc_product_has_multicurrency()) {
            ?>
									<?php 
            echo wpsc_display_product_multicurrency();
            ?>
								<?php 
        }
        ?>
								<?php 
						</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; ?> 
				
					
				<?php if(get_option('show_images_only') != 1): ?>
					<div class="grid_product_info">
						<div class="product_text">

							<div id="product_price_<?php echo wpsc_the_product_id(); ?>"  class="pricedisplay"><?php echo wpsc_the_product_price(true); ?></div> 
							<strong><?php echo wpsc_the_product_title(); ?></strong>
							
							<?php if(get_option('display_moredetails') == 1) : ?>
								<br />
								<a href='<?php echo wpsc_the_product_permalink(); ?>'>More Details</a>
							<?php endif; ?> 
						</div>
					</div>
					<div class="grid_more_info">
						<form class='product_form'  enctype="multipart/form-data" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_<?php echo wpsc_the_product_id(); ?>" >
							<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
							<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
							
							
							<?php if(get_option('display_variations') == 1) : ?>