/**
 * Categories column in Manage Products page
 *
 * @since  3.8.9
 * @access private
 * @param  object $post    Post object
 * @param  int    $post_id Post ID
 */
function _wpsc_manage_products_column_cats($post, $post_id)
{
    $categories = get_the_product_category($post->ID);
    if (!empty($categories)) {
        $out = array();
        foreach ($categories as $c) {
            $out[] = "<a href='?post_type=wpsc-product&amp;wpsc_product_category={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
        }
        echo join(', ', $out);
    } else {
        _e('Uncategorized', 'wpsc');
    }
}
/**
 * Spits out the current products details in a table row for manage products page and variations on edit product page.
 * @access public
 *
 * @deprecated since 3.8.9
 * @since 3.8
 * @param $product (Object), $parent_product (Int) Note: I believe parent_product is unused
 */
function wpsc_product_row(&$product, $parent_product = null)
{
    _wpsc_deprecated_function(__FUNCTION__, '3.8.9');
    global $mode, $current_user, $wpsc_products;
    //is this good practice? <*****@*****.**>
    static $rowclass, $object_terms_cache = array();
    // store terms associated with variants inside a cache array. This only requires 1 DB query.
    if (empty($object_terms_cache)) {
        $ids = wp_list_pluck($wpsc_products, 'ID');
        $object_terms = wp_get_object_terms($ids, 'wpsc-variation', array('fields' => 'all_with_object_id'));
        foreach ($object_terms as $term) {
            if (!array_key_exists($term->object_id, $object_terms_cache)) {
                $object_terms_cache[$term->object_id] = array();
            }
            $object_terms_cache[$term->object_id][$term->parent] = $term->name;
        }
    }
    $global_product = $product;
    setup_postdata($product);
    $product_post_type_object = get_post_type_object('wpsc-product');
    $current_user_can_edit_this_product = current_user_can($product_post_type_object->cap->edit_post, $product->ID);
    $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
    $post_owner = $current_user->ID == $product->post_author ? 'self' : 'other';
    $edit_link = get_edit_post_link($product->ID);
    if (isset($object_terms_cache[$product->ID])) {
        ksort($object_terms_cache[$product->ID]);
        $title = implode(', ', $object_terms_cache[$product->ID]);
    } else {
        $title = get_the_title($product->ID);
    }
    if (empty($title)) {
        $title = __('(no title)', 'wp-e-commerce');
    }
    ?>

	<tr id='post-<?php 
    echo $product->ID;
    ?>
' class='<?php 
    echo trim($rowclass . ' author-' . $post_owner . ' status-' . $product->post_status);
    ?>
 iedit <?php 
    if (get_option('wpsc_sort_by') == 'dragndrop') {
        echo 'product-edit';
    }
    ?>
' valign="top">
	<?php 
    $posts_columns = get_column_headers('wpsc-product_variants');
    if (empty($posts_columns)) {
        $posts_columns = array('image' => '', 'title' => __('Name', 'wp-e-commerce'), 'weight' => __('Weight', 'wp-e-commerce'), 'stock' => __('Stock', 'wp-e-commerce'), 'price' => __('Price', 'wp-e-commerce'), 'sale_price' => __('Sale Price', 'wp-e-commerce'), 'SKU' => __('SKU', 'wp-e-commerce'), 'hidden_alerts' => '');
    }
    foreach ($posts_columns as $column_name => $column_display_name) {
        $attributes = "class=\"{$column_name} column-{$column_name}\"";
        switch ($column_name) {
            case 'date':
                /* !date case */
                if ('0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name) {
                    $t_time = $h_time = __('Unpublished', 'wp-e-commerce');
                    $time_diff = 0;
                } else {
                    $t_time = get_the_time(__('Y/m/d g:i:s A', 'wp-e-commerce'));
                    $m_time = $product->post_date;
                    $time = get_post_time('G', true, $post);
                    $time_diff = time() - $time;
                    if ($time_diff > 0 && $time_diff < 24 * 60 * 60) {
                        $h_time = sprintf(__('%s ago', 'wp-e-commerce'), human_time_diff($time));
                    } else {
                        $h_time = mysql2date(__('Y/m/d', 'wp-e-commerce'), $m_time);
                    }
                }
                echo '<td ' . $attributes . '>';
                if ('excerpt' == $mode) {
                    echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
                } else {
                    echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
                }
                echo '<br />';
                if ('publish' == $product->post_status) {
                    _e('Published', 'wp-e-commerce');
                } elseif ('future' == $product->post_status) {
                    if ($time_diff > 0) {
                        echo '<strong class="attention">' . __('Missed schedule', 'wp-e-commerce') . '</strong>';
                    } else {
                        _e('Scheduled', 'wp-e-commerce');
                    }
                } else {
                    _e('Last Modified', 'wp-e-commerce');
                }
                echo '</td>';
                break;
            case 'title':
                /* !title case */
                $attributes = 'class="post-title column-title"';
                $edit_link = wp_nonce_url($edit_link, 'edit-product_' . $product->ID);
                ?>
		<td <?php 
                echo $attributes;
                ?>
>
			<strong>
			<?php 
                if ($current_user_can_edit_this_product && $product->post_status != 'trash') {
                    ?>
				<span><a class="row-title" href="<?php 
                    echo esc_url($edit_link);
                    ?>
" title="<?php 
                    echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;', 'wp-e-commerce'), $title));
                    ?>
"><?php 
                    echo esc_html($title);
                    ?>
</a></span>
				<?php 
                    if ($parent_product) {
                        ?>
					<a href="<?php 
                        echo esc_url($edit_link);
                        ?>
" title="<?php 
                        echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;', 'wp-e-commerce'), $title));
                        ?>
"><?php 
                        echo esc_html($title);
                        ?>
</a>

				<?php 
                    }
                    ?>
			<?php 
                } else {
                    echo esc_html($title);
                }
                _post_states($product);
                $product_alert = apply_filters('wpsc_product_alert', array(false, ''), $product);
                if (!empty($product_alert['messages'])) {
                    $product_alert['messages'] = implode("\n", (array) $product_alert['messages']);
                }
                if ($product_alert['state'] === true) {
                    ?>
				<img alt='<?php 
                    echo $product_alert['messages'];
                    ?>
' title='<?php 
                    echo $product_alert['messages'];
                    ?>
' class='product-alert-image' src='<?php 
                    echo WPSC_CORE_IMAGES_URL;
                    ?>
/product-alert.jpg' alt='' />
				<?php 
                }
                // If a product alert has stuff to display, show it.
                // Can be used to add extra icons etc
                if (!empty($product_alert['display'])) {
                    echo $product_alert['display'];
                }
                ?>
			</strong>
			<?php 
                $has_var = '';
                if (!$parent_product && wpsc_product_has_children($product->ID)) {
                    $has_var = 'wpsc_has_variation';
                }
                $actions = array();
                if ($current_user_can_edit_this_product && 'trash' != $product->post_status) {
                    $actions['edit'] = '<a class="edit-product" href="' . $edit_link . '" title="' . esc_attr__('Edit this product', 'wp-e-commerce') . '">' . __('Edit', 'wp-e-commerce') . '</a>';
                    //commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link.
                    //$actions['quick_edit'] = "<a class='wpsc_editinline ".$has_var."' title='".esc_attr(__('Quick Edit', 'wp-e-commerce'))."' href='#'>".__('Quick Edit', 'wp-e-commerce')."</a>";
                }
                $actions = apply_filters('post_row_actions', $actions, $product);
                $action_count = count($actions);
                $i = 0;
                echo '<div class="row-actions">';
                foreach ($actions as $action => $link) {
                    ++$i;
                    $i == $action_count ? $sep = '' : ($sep = ' | ');
                    echo "<span class='{$action}'>{$link}{$sep}</span>";
                }
                echo '</div>';
                ?>
		</td>
		<?php 
                break;
            case 'image':
                /* !image case */
                ?>
			<td class="product-image ">
			<?php 
                $attachment_args = array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $product->ID, 'orderby' => 'menu_order', 'order' => 'ASC');
                if (isset($product->ID) && has_post_thumbnail($product->ID)) {
                    echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails');
                } else {
                    $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif";
                    ?>
					<img title='<?php 
                    esc_attr_e('Drag to a new position', 'wp-e-commerce');
                    ?>
' src='<?php 
                    echo esc_url($image_url);
                    ?>
' alt='<?php 
                    echo esc_attr($title);
                    ?>
' width='38' height='38' />
			<?php 
                }
                ?>
			</td>
			<?php 
                break;
            case 'price':
                /* !price case */
                $price = get_product_meta($product->ID, 'price', true);
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<?php 
                echo wpsc_currency_display($price);
                ?>
					<input type="text" class="wpsc_ie_field wpsc_ie_price" value="<?php 
                echo esc_attr($price);
                ?>
">
					<a href="<?php 
                echo $edit_link;
                ?>
/#wpsc_downloads"><?php 
                esc_html_e('Variant Download Files', 'wp-e-commerce');
                ?>
</a>
				</td>
			<?php 
                break;
            case 'weight':
                $product_data['meta'] = array();
                $product_data['meta'] = get_post_meta($product->ID, '');
                foreach ($product_data['meta'] as $meta_name => $meta_value) {
                    $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
                }
                $product_data['transformed'] = array();
                if (!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) {
                    $product_data['meta']['_wpsc_product_metadata']['weight'] = "";
                }
                if (!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) {
                    $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
                }
                $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit'], false);
                $weight = $product_data['transformed']['weight'];
                if ($weight == '') {
                    $weight = '0';
                }
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<span><?php 
                echo esc_html($weight);
                ?>
</span>
					<input type="text" class="wpsc_ie_field wpsc_ie_weight" value="<?php 
                echo esc_attr($weight);
                ?>
">
					<a href="<?php 
                echo $edit_link;
                ?>
/#wpsc_tax"><?php 
                esc_html_e('Set Variant Tax', 'wp-e-commerce');
                ?>
</a>
				</td>
			<?php 
                break;
            case 'stock':
                $stock = get_post_meta($product->ID, '_wpsc_stock', true);
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<span><?php 
                echo $stock ? $stock : __('N/A', 'wp-e-commerce');
                ?>
</span>
					<input type="text" class="wpsc_ie_field wpsc_ie_stock" value="<?php 
                echo esc_attr($stock);
                ?>
">
					<a href="<?php 
                echo $edit_link;
                ?>
/#wpsc_shipping"><?php 
                esc_html_e('Set Variant Shipping', 'wp-e-commerce');
                ?>
</a>
				</td>
	<?php 
                break;
            case 'categories':
                /* !categories case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><?php 
                $categories = get_the_product_category($product->ID);
                if (!empty($categories)) {
                    $out = array();
                    foreach ($categories as $c) {
                        $out[] = "<a href='admin.php?page=wpsc-edit-products&amp;category={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
                    }
                    echo join(', ', $out);
                } else {
                    esc_html_e('Uncategorized', 'wp-e-commerce');
                }
                ?>
</td>
		<?php 
                break;
            case 'tags':
                /* !tags case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><?php 
                $tags = get_the_tags($product->ID);
                if (!empty($tags)) {
                    $out = array();
                    foreach ($tags as $c) {
                        $out[] = "<a href='edit.php?tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
                    }
                    echo join(', ', $out);
                } else {
                    esc_html_e('No Tags', 'wp-e-commerce');
                }
                ?>
</td>
		<?php 
                break;
            case 'SKU':
                $sku = get_post_meta($product->ID, '_wpsc_sku', true);
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<span><?php 
                echo $sku ? $sku : esc_html__('N/A', 'wp-e-commerce');
                ?>
</span>
					<input type="text" class="wpsc_ie_field wpsc_ie_sku" value="<?php 
                echo esc_attr($sku);
                ?>
">
										<input type="hidden" class="wpsc_ie_id wpsc_ie_field" value="<?php 
                echo $product->ID;
                ?>
">
					<div class="wpsc_inline_actions"><input type="button" class="button-primary wpsc_ie_save" value="Save"><img src="<?php 
                echo admin_url('images/wpspin_light.gif');
                ?>
" class="loading_indicator"><br/></div>
				</td>
			<?php 
                break;
            case 'sale_price':
                $sale_price = get_post_meta($product->ID, '_wpsc_special_price', true);
                ?>
				<td  <?php 
                echo $attributes;
                ?>
>
					<span><?php 
                echo wpsc_currency_display($sale_price);
                ?>
</span>
					<input type="text" class="wpsc_ie_field wpsc_ie_special_price" value="<?php 
                echo esc_attr($sale_price);
                ?>
">
				</td>
			<?php 
                break;
            case 'comments':
                /* !comments case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><div class="post-com-count-wrapper">
		<?php 
                $pending_phrase = sprintf(__('%s pending', 'wp-e-commerce'), number_format($pending_comments));
                if ($pending_comments) {
                    echo '<strong>';
                }
                comments_number("<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('0', 'comment count', 'wp-e-commerce') . '</span></a>', "<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('1', 'comment count', 'wp-e-commerce') . '</span></a>', "<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('%', 'comment count', 'wp-e-commerce') . '</span></a>');
                if ($pending_comments) {
                    echo '</strong>';
                }
                ?>
		</div></td>
		<?php 
                break;
            case 'author':
                /* !author case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><a href="edit.php?author=<?php 
                the_author_meta('ID');
                ?>
"><?php 
                the_author();
                ?>
</a></td>
		<?php 
                break;
            case 'control_view':
                /* !control view case */
                ?>
		<td><a href="<?php 
                the_permalink();
                ?>
" rel="permalink" class="view"><?php 
                esc_html_e('View', 'wp-e-commerce');
                ?>
</a></td>
		<?php 
                break;
            case 'control_edit':
                /* !control edit case */
                ?>
		<td><?php 
                if ($current_user_can_edit_this_product) {
                    echo "<a href='{$edit_link}' class='edit'>" . esc_html__('Edit', 'wp-e-commerce') . "</a>";
                }
                ?>
</td>
		<?php 
                break;
            case 'control_delete':
                /* !control delete case */
                ?>
		<td><?php 
                if ($current_user_can_edit_this_product) {
                    echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post={$id}", 'delete-post_' . $product->ID) . "' class='delete'>" . __('Delete', 'wp-e-commerce') . "</a>";
                }
                ?>
</td>
		<?php 
                break;
            case 'featured':
                /* !control featured case */
                ?>
			<td><?php 
                do_action('manage_posts_featured_column', $product->ID);
                ?>
</td>
		<?php 
                break;
            default:
                /* !default case */
                ?>
		<td <?php 
                echo $attributes;
                ?>
><?php 
                do_action('manage_posts_custom_column', $column_name, $product->ID);
                ?>
</td>
		<?php 
                break;
        }
    }
    ?>
	</tr>
<?php 
    $product = $global_product;
}
         $product_categories = get_the_terms($post->ID, 'product_cat');
         if (!empty($product_categories)) {
             foreach ($product_categories as $product_category) {
                 $categories .= str_replace(" ", "_", $product_category->slug) . $NV_shortcode_id . ' ';
             }
         }
         $product_tags = get_the_terms($post->ID, 'product_tag');
         if ($product_tags) {
             foreach ($product_tags as $product_tag) {
                 $categories .= str_replace(" ", "_", $product_tag->slug) . $NV_shortcode_id . ' ';
             }
         }
         $categories = preg_replace("/&#?[a-z0-9]+;/i", "", $categories);
     }
     if (class_exists('WPSC_Query')) {
         $wpsc_product_categories = get_the_product_category(wpsc_the_product_id());
         if ($wpsc_product_categories) {
             foreach ($wpsc_product_categories as $wpsc_product_category) {
                 $categories .= str_replace(" ", "_", $wpsc_product_category->slug) . $NV_shortcode_id . ' ';
             }
         }
         $wpsc_product_tags = wp_get_product_tags(wpsc_the_product_id());
         if ($wpsc_product_tags) {
             foreach ($wpsc_product_tags as $wpsc_product_tag) {
                 $categories .= str_replace(" ", "_", $wpsc_product_tag->slug) . $NV_shortcode_id . ' ';
             }
         }
         $categories = preg_replace("/&#?[a-z0-9]+;/i", "", $categories);
     }
 }
 /* ------------------------------------
Example #4
0
 /**
  * refresh_item method, refreshes the item, calculates the prices, gets the name
  * @access public
  *
  * @return array array of monetary and other values
  */
 function refresh_item()
 {
     global $wpdb, $wpsc_shipping_modules, $wpsc_cart;
     $product_id = $this->product_id;
     $product = get_post($this->product_id);
     $product_meta = get_metadata('post', $this->product_id);
     $this->sku = get_post_meta($product_id, '_wpsc_sku', true);
     $price = get_post_meta($product_id, '_wpsc_price', true);
     $special_price = get_post_meta($product_id, '_wpsc_special_price', true);
     $product_meta = get_post_meta($product_id, '_wpsc_product_metadata');
     $this->stock = get_post_meta($product_id, '_wpsc_stock', true);
     $this->is_donation = get_post_meta($product_id, '_wpsc_is_donation', true);
     if (isset($special_price) && $special_price > 0 && $special_price < $price) {
         $price = $special_price;
     }
     $priceandstock_id = 0;
     $this->weight = isset($product_meta[0]['weight']) ? $product_meta[0]["weight"] : 0;
     // if we are using table rate price
     if (isset($product_meta[0]['table_rate_price'])) {
         $levels = $product_meta[0]['table_rate_price'];
         if (!empty($levels['quantity'])) {
             foreach ((array) $levels['quantity'] as $key => $qty) {
                 if ($this->quantity >= $qty) {
                     $unit_price = $levels['table_price'][$key];
                     if ($unit_price != '') {
                         $price = $unit_price;
                     }
                 }
             }
         }
     }
     $price = apply_filters('wpsc_price', $price, $product_id);
     // create the string containing the product name.
     $this->product_name = $this->get_title('raw');
     $this->priceandstock_id = $priceandstock_id;
     $this->meta = $product_meta;
     // change no_shipping to boolean and invert it
     if (isset($product_meta[0]['no_shipping']) && $product_meta[0]['no_shipping'] == 1) {
         $this->uses_shipping = 0;
     } else {
         $this->uses_shipping = 1;
     }
     $quantity_limited = get_product_meta($product_id, 'stock', true);
     $this->has_limited_stock = (bool) $quantity_limited;
     if ($this->is_donation == 1) {
         $this->unit_price = (double) $this->provided_price;
     } else {
         $this->unit_price = (double) $price;
     }
     $this->total_price = $this->unit_price * $this->quantity;
     if ($product->post_parent) {
         $category_data = get_the_product_category($product->post_parent);
     } else {
         $category_data = get_the_product_category($product_id);
     }
     $this->category_list = array();
     $this->category_id_list = array();
     foreach ((array) $category_data as $category_row) {
         $this->category_list[] = $category_row->slug;
         $this->category_id_list[] = $category_row->term_id;
     }
     //wpec_taxes - calculate product tax and add to total price
     $wpec_taxes_controller = new wpec_taxes_controller();
     if ($wpec_taxes_controller->wpec_taxes_isincluded() && $wpec_taxes_controller->wpec_taxes_isenabled()) {
         $taxes = $wpec_taxes_controller->wpec_taxes_calculate_included_tax($this);
         $this->tax_rate = $taxes['rate'];
         $this->tax = $taxes['tax'];
     }
     $this->product_url = wpsc_product_url($product_id);
     if (!is_array($this->variation_values)) {
         $attach_parent = $product_id;
     } else {
         $attach_parent = $wpdb->get_var($wpdb->prepare("SELECT post_parent FROM {$wpdb->posts} WHERE ID = %d", $product_id));
     }
     $att_img_args = array('post_type' => 'attachment', 'numberposts' => 1, 'post_parent' => $attach_parent, 'orderby' => 'menu_order', 'order' => 'DESC');
     $attached_image = get_posts($att_img_args);
     if ($attached_image != null) {
         $this->thumbnail_image = array_shift($attached_image);
     }
     $product_files = (array) get_posts(array('post_type' => 'wpsc-product-file', 'post_parent' => $this->product_id, 'numberposts' => -1, 'post_status' => 'inherit'));
     if (count($product_files) > 0) {
         $this->file_id = null;
         $this->is_downloadable = true;
     } else {
         $this->file_id = null;
         $this->is_downloadable = false;
     }
     if (isset($this->cart->selected_shipping_method) && isset($wpsc_shipping_modules[$this->cart->selected_shipping_method]) && is_callable(array($wpsc_shipping_modules[$this->cart->selected_shipping_method], "get_item_shipping"))) {
         $this->shipping = $wpsc_shipping_modules[$this->cart->selected_shipping_method]->get_item_shipping($this);
     }
     // update the claimed stock here
     $this->update_claimed_stock();
     do_action_ref_array('wpsc_refresh_item', array(&$this));
 }
/**
 * wpsc_additional_column_data.
 *
 * @access public
 * @param (array) $column
 * @return void
 * @todo Need to check titles / alt tags ( I don't think thumbnails have any in this code )
 * @desc Switch function to generate columns the right way...no more UI hacking!
 *
 */
function wpsc_additional_column_data($column)
{
    global $post;
    $is_parent = (bool) wpsc_product_has_children($post->ID);
    switch ($column) {
        case 'image':
            $attached_images = get_posts(array('post_type' => 'attachment', 'numberposts' => 1, 'post_parent' => $post->ID, 'orderby' => 'menu_order', 'order' => 'ASC'));
            if (isset($post->ID) && has_post_thumbnail($post->ID)) {
                echo get_the_post_thumbnail($post->ID, 'admin-product-thumbnails');
            } else {
                if (!empty($attached_images)) {
                    $attached_image = $attached_images[0];
                    $src = wp_get_attachment_url($attached_image->ID);
                    ?>
                    <div style='width:38px; height:38px; overflow:hidden;'>
                        <img src='<?php 
                    echo $src;
                    ?>
' alt='<?php 
                    _e('Drag to a new position', 'wpsc');
                    ?>
' width='38' height='38' />
                    </div>
                <?php 
                } else {
                    $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif";
                    ?>
                      <img src='<?php 
                    echo $image_url;
                    ?>
' alt='<?php 
                    _e('Drag to a new position', 'wpsc');
                    ?>
' width='38' height='38' />
                <?php 
                }
            }
            break;
        case 'weight':
            if ($is_parent) {
                _e('N/A', 'wpsc');
            } else {
                $product_data['meta'] = array();
                $product_data['meta'] = get_post_meta($post->ID, '');
                foreach ($product_data['meta'] as $meta_name => $meta_value) {
                    $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
                }
                $product_data['transformed'] = array();
                if (!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) {
                    $product_data['meta']['_wpsc_product_metadata']['weight'] = "";
                }
                if (!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) {
                    $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
                }
                $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit']);
                $weight = $product_data['transformed']['weight'];
                if ($weight == '') {
                    $weight = '0';
                }
                $unit = $product_data['meta']['_wpsc_product_metadata']['weight_unit'];
                switch ($unit) {
                    case "pound":
                        $unit = __(" lbs.", "wpsc");
                        break;
                    case "ounce":
                        $unit = __(" oz.", "wpsc");
                        break;
                    case "gram":
                        $unit = __(" g", "wpsc");
                        break;
                    case "kilograms":
                    case "kilogram":
                        $unit = __(" kgs.", "wpsc");
                        break;
                }
                echo $weight . $unit;
                echo '<div id="inline_' . $post->ID . '_weight" class="hidden">' . $weight . '</div>';
            }
            break;
        case 'stock':
            $stock = get_post_meta($post->ID, '_wpsc_stock', true);
            if ($stock == '') {
                $stock = __('N/A', 'wpsc');
            }
            if (!$is_parent) {
                echo $stock;
                echo '<div id="inline_' . $post->ID . '_stock" class="hidden">' . $stock . '</div>';
            } else {
                echo '~' . wpsc_variations_stock_remaining($post->ID);
            }
            break;
        case 'price':
            $price = get_post_meta($post->ID, '_wpsc_price', true);
            $has_var = '1';
            if (!$is_parent) {
                echo wpsc_currency_display($price);
                echo '<div id="inline_' . $post->ID . '_price" class="hidden">' . trim($price) . '</div>';
                $has_var = '0';
            } else {
                echo wpsc_product_variation_price_available($post->ID) . '+';
            }
            echo '<input type="hidden" value="' . $has_var . '" id="inline_' . $post->ID . '_has_var" />';
            break;
        case 'sale_price':
            $price = get_post_meta($post->ID, '_wpsc_special_price', true);
            if (!$is_parent) {
                echo wpsc_currency_display($price);
                echo '<div id="inline_' . $post->ID . '_sale_price" class="hidden">' . $price . '</div>';
            } else {
                echo wpsc_product_variation_price_available($post->ID) . '+';
            }
            break;
        case 'SKU':
            $sku = get_post_meta($post->ID, '_wpsc_sku', true);
            if ($sku == '') {
                $sku = __('N/A', 'wpsc');
            }
            echo $sku;
            echo '<div id="inline_' . $post->ID . '_sku" class="hidden">' . $sku . '</div>';
            break;
        case 'cats':
            $categories = get_the_product_category($post->ID);
            if (!empty($categories)) {
                $out = array();
                foreach ($categories as $c) {
                    $out[] = "<a href='?post_type=wpsc-product&amp;wpsc_product_category={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
                }
                echo join(', ', $out);
            } else {
                _e('Uncategorized', 'wpsc');
            }
            break;
        case 'featured':
            $featured_product_url = wp_nonce_url("index.php?wpsc_admin_action=update_featured_product&amp;product_id={$post->ID}", 'feature_product_' . $post->ID);
            ?>
	<a class="wpsc_featured_product_toggle featured_toggle_<?php 
            echo $post->ID;
            ?>
" href='<?php 
            echo $featured_product_url;
            ?>
' >
            <?php 
            if (in_array($post->ID, (array) get_option('sticky_products'))) {
                ?>
                <img class='gold-star' src='<?php 
                echo WPSC_CORE_IMAGES_URL;
                ?>
/gold-star.gif' alt='<?php 
                _e('Unmark as Featured', 'wpsc');
                ?>
' title='<?php 
                _e('Unmark as Featured', 'wpsc');
                ?>
' />
            <?php 
            } else {
                ?>
                <img class='grey-star' src='<?php 
                echo WPSC_CORE_IMAGES_URL;
                ?>
/grey-star.gif' alt='<?php 
                _e('Mark as Featured', 'wpsc');
                ?>
' title='<?php 
                _e('Mark as Featured', 'wpsc');
                ?>
' />
            <?php 
            }
            ?>
	</a>
        <?php 
            break;
        case 'hidden_alerts':
            $product_alert = apply_filters('wpsc_product_alert', array(false, ''), $post);
            if (!empty($product_alert['messages'])) {
                $product_alert['messages'] = implode("\n", (array) $product_alert['messages']);
            }
            if ($product_alert['state'] === true) {
                ?>
                            <img alt='<?php 
                echo $product_alert['messages'];
                ?>
' title='<?php 
                echo $product_alert['messages'];
                ?>
' class='product-alert-image' src='<?php 
                echo WPSC_CORE_IMAGES_URL;
                ?>
/product-alert.jpg' alt='' />
                        <?php 
            }
            // If a product alert has stuff to display, show it.
            // Can be used to add extra icons etc
            if (!empty($product_alert['display'])) {
                echo $product_alert['display'];
            }
            break;
    }
}