public function column_product($item) { ?> <div class="wpsc-thumbnail wpsc-product-thumbnail"> <?php if (wpsc_has_product_thumbnail($item->ID)) { ?> <?php echo wpsc_get_product_thumbnail($item->ID, 'cart'); ?> <?php } else { ?> <?php wpsc_product_no_thumbnail_image('cart'); ?> <?php } ?> </div> <div class="wpsc-digital-product-title"> <strong><a href="<?php wpsc_product_permalink($item->ID); ?> "><?php wpsc_product_title('', '', $item->ID); ?> </a></strong> </div> <?php }
<?php wpsc_edit_product_link(); ?> </div><!-- .entry-meta --> </div><!-- .wpsc-product-summary --> <div class="wpsc-thumbnail-wrapper"> <a class="wpsc-thumbnail wpsc-product-thumbnail" href="<?php wpsc_product_permalink(); ?> " > <?php if (wpsc_has_product_thumbnail()) { ?> <?php wpsc_product_thumbnail(); ?> <?php } else { ?> <?php wpsc_product_no_thumbnail_image(); ?> <?php } ?> </a> </div>
/** * Determine whether a product has an associated featured thumbnail or not. * * @since 0.1 * @uses has_post_thumbnail() * * @param null|int $id Optional. The product ID. Defaults to the current product ID in the loop. * @return bool */ function wpsc_has_product_thumbnail($id = null) { $parent = get_post_field('post_parent', $id); if ($parent) { return wpsc_has_product_thumbnail($parent); } return has_post_thumbnail($id); }
/** * Return the HTML of a product's featured thumbnail. * * Note that the $size argument of this function is different from that of get_the_post_thumbnail(). * * This function works similarly to get_the_post_thumbnail(), except the $size argument takes the * following shortcut values corresponding to the options in Settings->Store->Presentation: * 'single' - corresponds to "Single Product Image Size" option. * 'archive' - corresponds to "Default Product Thumbnail Size" option. * 'taxonomy' - corresponds to "Default Product Group Thumbnail Size" option. * 'cart' - corresponds to the cart product thumbnail size option. * * @see wpsc_check_thumbnail_support() Where the thumbnail sizes are registered. * @since 4.0 * * @uses $_wp_additional_image_sizes The array holding registered thumbnail sizes. * @uses get_attached_file() * @uses get_post_meta() * @uses get_the_post_thumbnail() * @uses wp_get_attachment_metadata() * @uses wp_update_attachment_metadata() * @uses wpsc_get_product_thumbnail_id() * @uses wpsc_has_product_thumbnail() * @uses update_post_meta() * * @param null|int $id Optional. The product ID. Defaults to the current product in the loop. * @param string $size Optional. Size of the product thumbnail. Defaults to 'single'. * @param string $attr Optional. Query string or array of attributes. Defaults to ''. * @return string */ function wpsc_get_product_thumbnail($id = null, $size = false, $attr = '') { global $_wp_additional_image_sizes; $parent = get_post_field('post_parent', $id); if ($parent) { return wpsc_get_product_thumbnail($parent, $size, $attr); } if (!$size || !in_array($size, array('archive', 'taxonomy', 'single', 'cart', 'widget'))) { if (is_tax('wpsc_product_category') || is_tax('product_tag')) { $size = 'taxonomy'; } elseif (wpsc_is_cart() || wpsc_is_checkout() || wpsc_is_customer_account()) { $size = 'cart'; } elseif (is_singular('wpsc-product')) { $size = 'single'; } elseif (is_post_type_archive('wpsc-product')) { $size = 'archive'; } else { $size = 'full'; } } $wpec_sizes = array('cart', 'single', 'archive', 'taxonomy'); $wp_size = $size; if (in_array($size, $wpec_sizes)) { $wp_size = 'wpsc_product_' . $size . '_thumbnail'; if (wpsc_has_product_thumbnail($id)) { $thumb_id = wpsc_get_product_thumbnail_id($id); // Get the size metadata registered in wpsc_check_thumbnail_support() $size_metadata = $_wp_additional_image_sizes[$wp_size]; // Get the current size metadata that has been generated for this product // This metadata is generated in {@link _wpsc_filter_generate_attachment_metadata()} $current_size_metadata = get_post_meta($thumb_id, '_wpsc_generated_sizes', true); if (empty($current_size_metadata)) { $current_size_metadata = array(); } // If this thumbnail for the current size was not generated yet, or generated with different // parameters (crop, for example), we need to regenerate the thumbnail if (!array_key_exists($size, $current_size_metadata) || $current_size_metadata[$size] != $size_metadata) { _wpsc_regenerate_thumbnail_size($thumb_id, $wp_size); } } } return get_the_post_thumbnail($id, $wp_size, $attr); }
protected function column_items($item, $key) { $product = get_post($item->product_id); $product_name = $item->product_name; if ($product->post_parent) { $permalink = wpsc_get_product_permalink($product->post_parent); $product_name = get_post_field('post_title', $product->post_parent); } else { $permalink = wpsc_get_product_permalink($item->product_id); } $variations = array(); if (is_array($item->variation_values)) { foreach ($item->variation_values as $variation_set => $variation) { $set_name = get_term_field('name', $variation_set, 'wpsc-variation'); $variation_name = get_term_field('name', $variation, 'wpsc-variation'); if (!is_wp_error($set_name) && !is_wp_error($variation_name)) { $variations[] = '<span>' . esc_html($set_name) . ':</span> ' . esc_html($variation_name); } } } $variations = implode(', ', $variations); $separator = ''; if (!empty($variations) && !empty($item->sku)) { $separator = ' | '; } ?> <?php if ($this->show_thumbnails) { ?> <div class="wpsc-thumbnail wpsc-product-thumbnail"> <?php if (wpsc_has_product_thumbnail($item->product_id)) { ?> <?php echo wpsc_get_product_thumbnail($item->product_id, 'cart'); ?> <?php } else { ?> <?php wpsc_product_no_thumbnail_image('cart'); ?> <?php } ?> </div> <?php } ?> <div class="wpsc-cart-item-description"> <div class="wpsc-cart-item-title"> <strong><a href="<?php echo $permalink; ?> "><?php echo esc_html($product_name); ?> </a></strong> </div> <div class="wpsc-cart-item-details"> <?php if (!empty($item->sku)) { ?> <span class="wpsc-cart-item-sku"><span><?php esc_html_e('SKU', 'wpsc'); ?> :</span> <?php echo esc_html($item->sku); ?> </span> <?php } ?> <?php if ($separator) { ?> <span class="separator"><?php echo $separator; ?> </span> <?php } ?> <?php if (!empty($variations)) { ?> <span class="wpsc-cart-item-variations"><?php echo $variations; ?> </span> <?php } ?> </div> <?php $this->cart_item_description($item, $key); ?> </div> <?php }
<?php if ($this->show_thumbnails) { ?> <div class="wpsc-thumbnail wpsc-product-thumbnail"> <?php if (wpsc_has_product_thumbnail($item->product_id)) { echo wpsc_get_product_thumbnail($item->product_id, 'cart'); } else { wpsc_product_no_thumbnail_image('cart'); } ?> </div><!-- .wpsc-product-thumbnail --> <?php } ?> <div class="wpsc-cart-item-description"> <div class="wpsc-cart-item-title"> <strong> <a href="<?php echo $permalink; ?> "><?php echo esc_html($product_name); ?> </a> </strong> </div> <div class="wpsc-cart-item-details"> <?php if (!empty($item->sku)) {
protected function column_image($item) { if ($this->show_thumbnails) { ?> <div class="wpsc-thumbnail wpsc-product-thumbnail"> <?php if (wpsc_has_product_thumbnail($item->product_id)) { ?> <?php echo wpsc_get_product_thumbnail($item->product_id, 'cart'); ?> <?php } else { ?> <?php wpsc_product_no_thumbnail_image('cart'); ?> <?php } ?> </div> <?php } }