Template changes - for coen approval
This commit is contained in:
parent
c687c214e7
commit
12dc3c033f
|
@ -153,6 +153,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
= 1.xxxx - xx/xx/2012 =
|
||||
* Feature - Support for ounces
|
||||
* Feature - Restore coupon usage count after order cancellation
|
||||
* Templating - Dumped woocommerce_single_product_content(), woocommerce_archive_product_content(), woocommerce_product_taxonomy_content() and introduced a content-product.php template for ease of customisation.
|
||||
* Templating - Documented templates listing hooked in functions.
|
||||
* Tweak - Better WC_Product::get_image() function. Fixed instances where we were not echo'ing.
|
||||
* Tweak - Pass valuable object data to woocommerce_email_headers and woocommerce_email_attachments filters.
|
||||
* Tweak - Cart.php tweak: Disable hyperlinks for hidden products.
|
||||
|
|
|
@ -392,7 +392,7 @@ function woocommerce_featured_products( $atts ) {
|
|||
/**
|
||||
* Show a single product page
|
||||
**/
|
||||
function woocommerce_product_page_shortcode($atts){
|
||||
function woocommerce_product_page_shortcode( $atts ) {
|
||||
if (empty($atts)) return;
|
||||
|
||||
if (!$atts['id'] && !$atts['sku']) return;
|
||||
|
@ -416,13 +416,23 @@ function woocommerce_product_page_shortcode($atts){
|
|||
if(isset($atts['id'])){
|
||||
$args['p'] = $atts['id'];
|
||||
}
|
||||
|
||||
$single_product = new WP_Query( $args );
|
||||
|
||||
$product_query = new WP_Query($args);
|
||||
ob_start();
|
||||
echo '<div class="single-product">';
|
||||
woocommerce_single_product_content( $product_query );
|
||||
echo '</div>';
|
||||
|
||||
while ( $single_product->have_posts() ) : $single_product->the_post(); ?>
|
||||
|
||||
<div class="single-product">
|
||||
|
||||
<?php woocommerce_get_template_part( 'content', 'product' ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php endwhile; // end of the loop.
|
||||
|
||||
wp_reset_query();
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,78 @@
|
|||
<?php get_header('shop'); ?>
|
||||
<?php
|
||||
/**
|
||||
* The Template for displaying product archives, including the main shop page which is a post type archive.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/woocommerce/archive-product.php
|
||||
*
|
||||
* @package WooCommerce
|
||||
* @since WooCommerce 1.0
|
||||
* @todo replace loop-shop with a content template and include query/loop here instead.
|
||||
*/
|
||||
|
||||
get_header('shop'); ?>
|
||||
|
||||
<?php do_action('woocommerce_before_main_content'); ?>
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_before_main_content hook
|
||||
*
|
||||
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
|
||||
* @hooked woocommerce_breadcrumb - 20
|
||||
*/
|
||||
do_action('woocommerce_before_main_content');
|
||||
?>
|
||||
|
||||
<?php woocommerce_archive_product_content(); ?>
|
||||
<h1 class="page-title">
|
||||
<?php if ( is_search() ) : ?>
|
||||
<?php
|
||||
printf( __( 'Search Results: “%s”', 'woocommerce' ), get_search_query() );
|
||||
if ( get_query_var( 'paged' ) )
|
||||
printf( __( ' – Page %s', 'woocommerce' ), get_query_var( 'paged' ) );
|
||||
?>
|
||||
<?php elseif ( is_tax() ) : ?>
|
||||
<?php echo single_term_title( "", false ); ?>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
$shop_page = get_post( woocommerce_get_page_id( 'shop' ) );
|
||||
|
||||
echo apply_filters( 'the_title', ( $shop_page_title = get_option( 'woocommerce_shop_page_title' ) ) ? $shop_page_title : $shop_page->post_title );
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</h1>
|
||||
|
||||
<?php if ( is_tax() && get_query_var( 'paged' ) == 0 ) : ?>
|
||||
<?php echo '<div class="term-description">' . wpautop( wptexturize( term_description() ) ) . '</div>'; ?>
|
||||
<?php elseif ( ! is_search() && get_query_var( 'paged' ) == 0 && ! empty( $shop_page ) && is_object( $shop_page ) ) : ?>
|
||||
<?php echo '<div class="page-description">' . apply_filters( 'the_content', $shop_page->post_content ) . '</div>'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php woocommerce_get_template_part( 'loop', 'shop' ); ?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_pagination hook
|
||||
*
|
||||
* @hooked woocommerce_pagination - 10
|
||||
* @hooked woocommerce_catalog_ordering - 20
|
||||
*/
|
||||
do_action( 'woocommerce_pagination' );
|
||||
?>
|
||||
|
||||
<?php do_action('woocommerce_after_main_content'); ?>
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_after_main_content hook
|
||||
*
|
||||
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
|
||||
*/
|
||||
do_action('woocommerce_after_main_content');
|
||||
?>
|
||||
|
||||
<?php do_action('woocommerce_sidebar'); ?>
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_sidebar hook
|
||||
*
|
||||
* @hooked woocommerce_get_sidebar - 10
|
||||
*/
|
||||
do_action('woocommerce_sidebar');
|
||||
?>
|
||||
|
||||
<?php get_footer('shop'); ?>
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* The template for displaying content in the single-product.php template
|
||||
*
|
||||
* Override this template by copying it to yourtheme/woocommerce/content-product.php
|
||||
*
|
||||
* @package WooCommerce
|
||||
* @since WooCommerce 1.6
|
||||
* @todo prepend class names with wc-
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_before_single_product hook
|
||||
*
|
||||
* @hooked woocommerce_show_messages - 10
|
||||
*/
|
||||
do_action( 'woocommerce_before_single_product' );
|
||||
?>
|
||||
|
||||
<div itemscope itemtype="http://schema.org/Product" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_show_product_images hook
|
||||
*
|
||||
* @hooked woocommerce_show_product_sale_flash - 10
|
||||
* @hooked woocommerce_show_product_images - 20
|
||||
*/
|
||||
do_action( 'woocommerce_before_single_product_summary' );
|
||||
?>
|
||||
|
||||
<div class="summary">
|
||||
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_single_product_summary hook
|
||||
*
|
||||
* @hooked woocommerce_template_single_title - 5
|
||||
* @hooked woocommerce_template_single_price - 10
|
||||
* @hooked woocommerce_template_single_excerpt - 20
|
||||
* @hooked woocommerce_template_single_add_to_cart - 30
|
||||
* @hooked woocommerce_template_single_meta - 40
|
||||
* @hooked woocommerce_template_single_sharing - 50
|
||||
*/
|
||||
do_action( 'woocommerce_single_product_summary' );
|
||||
?>
|
||||
|
||||
</div><!-- .summary -->
|
||||
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_after_single_product_summary hook
|
||||
*
|
||||
* @hooked woocommerce_output_product_data_tabs - 10
|
||||
* @hooked woocommerce_output_related_products - 20
|
||||
*/
|
||||
do_action( 'woocommerce_after_single_product_summary' );
|
||||
?>
|
||||
|
||||
</div><!-- #product-<?php the_ID(); ?> -->
|
||||
|
||||
<?php do_action( 'woocommerce_after_single_product' ); ?>
|
|
@ -1,11 +1,47 @@
|
|||
<?php get_header('shop'); ?>
|
||||
|
||||
<?php do_action('woocommerce_before_main_content'); ?>
|
||||
<?php
|
||||
/**
|
||||
* The Template for displaying all single products.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/woocommerce/single-product.php
|
||||
*
|
||||
* @package WooCommerce
|
||||
* @since WooCommerce 1.0
|
||||
*/
|
||||
|
||||
<?php woocommerce_single_product_content(); ?>
|
||||
get_header('shop'); ?>
|
||||
|
||||
<?php do_action('woocommerce_after_main_content'); ?>
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_before_main_content hook
|
||||
*
|
||||
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
|
||||
* @hooked woocommerce_breadcrumb - 20
|
||||
*/
|
||||
do_action('woocommerce_before_main_content');
|
||||
?>
|
||||
|
||||
<?php do_action('woocommerce_sidebar'); ?>
|
||||
<?php while ( have_posts() ) : the_post(); ?>
|
||||
|
||||
<?php woocommerce_get_template_part( 'content', 'product' ); ?>
|
||||
|
||||
<?php endwhile; // end of the loop. ?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_after_main_content hook
|
||||
*
|
||||
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
|
||||
*/
|
||||
do_action('woocommerce_after_main_content');
|
||||
?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* woocommerce_sidebar hook
|
||||
*
|
||||
* @hooked woocommerce_get_sidebar - 10
|
||||
*/
|
||||
do_action('woocommerce_sidebar');
|
||||
?>
|
||||
|
||||
<?php get_footer('shop'); ?>
|
|
@ -1,11 +1,10 @@
|
|||
<?php get_header('shop'); ?>
|
||||
<?php
|
||||
/**
|
||||
* The Template for displaying products in a product category. Simple includes the archive template.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/woocommerce/taxonomy-product_cat.php
|
||||
*
|
||||
* @package WooCommerce
|
||||
*/
|
||||
|
||||
<?php do_action('woocommerce_before_main_content'); ?>
|
||||
|
||||
<?php woocommerce_product_taxonomy_content(); ?>
|
||||
|
||||
<?php do_action('woocommerce_after_main_content'); ?>
|
||||
|
||||
<?php do_action('woocommerce_sidebar'); ?>
|
||||
|
||||
<?php get_footer('shop'); ?>
|
||||
woocommerce_get_template( 'archive-product.php' );
|
|
@ -1,11 +1,10 @@
|
|||
<?php get_header('shop'); ?>
|
||||
<?php
|
||||
/**
|
||||
* The Template for displaying products in a product tag. Simple includes the archive template.
|
||||
*
|
||||
* Override this template by copying it to yourtheme/woocommerce/taxonomy-product_tag.php
|
||||
*
|
||||
* @package WooCommerce
|
||||
*/
|
||||
|
||||
<?php do_action('woocommerce_before_main_content'); ?>
|
||||
|
||||
<?php woocommerce_product_taxonomy_content(); ?>
|
||||
|
||||
<?php do_action('woocommerce_after_main_content'); ?>
|
||||
|
||||
<?php do_action('woocommerce_sidebar'); ?>
|
||||
|
||||
<?php get_footer('shop'); ?>
|
||||
woocommerce_get_template( 'archive-product.php' );
|
|
@ -15,19 +15,19 @@ global $woocommerce;
|
|||
if ( !is_admin() || defined('DOING_AJAX') ) {
|
||||
|
||||
/* Content Wrappers */
|
||||
add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
|
||||
add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
|
||||
add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
||||
add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
||||
|
||||
/* Sale flashes */
|
||||
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10);
|
||||
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10);
|
||||
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
|
||||
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
|
||||
|
||||
/* Breadcrumbs */
|
||||
add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
|
||||
add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
|
||||
|
||||
/* Sidebar */
|
||||
add_action( 'get_sidebar', 'woocommerce_prevent_sidebar_cache' );
|
||||
add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
|
||||
add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
|
||||
|
||||
/* Products Loop */
|
||||
add_action( 'woocommerce_before_shop_loop', 'woocommerce_show_messages', 10 );
|
||||
|
|
|
@ -13,93 +13,49 @@
|
|||
|
||||
if ( ! function_exists( 'woocommerce_content' ) ) {
|
||||
// This function is only used in the optional 'woocommerce.php' template
|
||||
// people can add to their themes to add basic woocommerce support.
|
||||
// people can add to their themes to add basic woocommerce support without
|
||||
// using hooks or modifying core templates.
|
||||
function woocommerce_content() {
|
||||
if ( is_singular( 'product' ) )
|
||||
woocommerce_single_product_content();
|
||||
elseif ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) )
|
||||
woocommerce_product_taxonomy_content();
|
||||
else
|
||||
woocommerce_archive_product_content();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'woocommerce_archive_product_content' ) ) {
|
||||
function woocommerce_archive_product_content() {
|
||||
|
||||
if ( ! is_search() ) {
|
||||
$shop_page = get_post( woocommerce_get_page_id( 'shop' ) );
|
||||
$shop_page_title = apply_filters( 'the_title', ( get_option( 'woocommerce_shop_page_title' ) ) ? get_option( 'woocommerce_shop_page_title' ) : $shop_page->post_title );
|
||||
if ( is_object( $shop_page ) )
|
||||
$shop_page_content = $shop_page->post_content;
|
||||
} else {
|
||||
$shop_page_title = __( 'Search Results:', 'woocommerce' ) . ' “' . get_search_query() . '”';
|
||||
if ( get_query_var( 'paged' ) ) $shop_page_title .= ' — ' . __( 'Page', 'woocommerce' ) . ' ' . get_query_var( 'paged' );
|
||||
$shop_page_content = '';
|
||||
}
|
||||
|
||||
?><h1 class="page-title"><?php echo $shop_page_title ?></h1>
|
||||
|
||||
<?php if ( ! empty( $shop_page_content ) ) echo apply_filters( 'the_content', $shop_page_content ); ?>
|
||||
|
||||
<?php woocommerce_get_template_part( 'loop', 'shop' ); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_pagination' );
|
||||
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'woocommerce_product_taxonomy_content' ) ) {
|
||||
function woocommerce_product_taxonomy_content() {
|
||||
|
||||
global $wp_query;
|
||||
|
||||
$term = get_term_by( 'slug', get_query_var( $wp_query->query_vars['taxonomy'] ) , $wp_query->query_vars['taxonomy'] );
|
||||
|
||||
?><h1 class="page-title"><?php echo wptexturize( $term->name ); ?></h1>
|
||||
|
||||
<?php if ( $term->description ) : ?>
|
||||
|
||||
<div class="term_description"><?php echo wpautop( wptexturize( $term->description ) ); ?></div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php woocommerce_get_template_part( 'loop', 'shop' ); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_pagination' );
|
||||
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'woocommerce_single_product_content' ) ) {
|
||||
function woocommerce_single_product_content( $wc_query = false ) {
|
||||
|
||||
// Let developers override the query used, in case they want to use this function for their own loop/wp_query
|
||||
if ( ! $wc_query ) {
|
||||
global $wp_query;
|
||||
|
||||
$wc_query = $wp_query;
|
||||
}
|
||||
|
||||
if ( $wc_query->have_posts() ) while ( $wc_query->have_posts() ) : $wc_query->the_post(); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_before_single_product' ); ?>
|
||||
|
||||
<div itemscope itemtype="http://schema.org/Product" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
|
||||
<?php do_action( 'woocommerce_before_single_product_summary' ); ?>
|
||||
|
||||
<div class="summary">
|
||||
|
||||
<?php do_action( 'woocommerce_single_product_summary' ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_after_single_product_summary' ); ?>
|
||||
if ( is_singular( 'product' ) ) {
|
||||
|
||||
while ( have_posts() ) : the_post();
|
||||
|
||||
</div>
|
||||
woocommerce_get_template_part( 'content', 'product' );
|
||||
|
||||
<?php do_action( 'woocommerce_after_single_product' ); ?>
|
||||
|
||||
<?php endwhile;
|
||||
endwhile;
|
||||
|
||||
} else {
|
||||
|
||||
?><h1 class="page-title">
|
||||
<?php if ( is_search() ) : ?>
|
||||
<?php printf( __( 'Search Results: “%s”', 'woocommerce' ), get_search_query() ); ?>
|
||||
<?php elseif ( is_tax() ) : ?>
|
||||
<?php echo single_term_title( "", false ); ?>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
$shop_page = get_post( woocommerce_get_page_id( 'shop' ) );
|
||||
|
||||
echo apply_filters( 'the_title', ( $shop_page_title = get_option( 'woocommerce_shop_page_title' ) ) ? $shop_page_title : $shop_page->post_title );
|
||||
?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( get_query_var( 'paged' ) ) : ?>
|
||||
<?php printf( __( ' – Page %s', 'woocommerce' ), get_query_var( 'paged' ) ); ?>
|
||||
<?php endif; ?>
|
||||
</h1>
|
||||
|
||||
<?php if ( is_tax() ) : ?>
|
||||
<?php echo '<div class="term-description">' . wpautop( wptexturize( term_description() ) ) . '</div>'; ?>
|
||||
<?php elseif ( ! is_search() && ! empty( $shop_page ) && is_object( $shop_page ) ) : ?>
|
||||
<?php echo '<div class="page-description">' . apply_filters( 'the_content', $shop_page->post_content ) . '</div>'; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php woocommerce_get_template_part( 'loop', 'shop' ); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_pagination' );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue