';
}
woocommerce_related_products( array(
'columns' => 4,
'posts_per_page' => 12,
) );
if ( ! class_exists( 'Vamtam_Columns' ) || Vamtam_Columns::had_limit_wrapper() ) {
echo '
';
}
}
}
// move related products after the content + sidebars
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
add_action( 'woocommerce_after_main_content', 'woocommerce_output_related_products', 999 );
function vamtam_woocommerce_upsell_display() {
if ( ! class_exists( 'Vamtam_Columns' ) || Vamtam_Columns::had_limit_wrapper() ) {
echo '
';
}
woocommerce_upsell_display();
if ( ! class_exists( 'Vamtam_Columns' ) || Vamtam_Columns::had_limit_wrapper() ) {
echo '';
}
}
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_main_content', 'vamtam_woocommerce_upsell_display', 990 );
add_filter( 'woocommerce_upsells_columns', 'vamtam_woocommerce_columns' );
/**
* Set the number of gallery thumbnails per row
*/
add_filter( 'woocommerce_product_thumbnails_columns', 'vamtam_woocommerce_columns' );
/**
* star rating used in the single product template
*/
function vamtam_woocommerce_rating() {
global $product;
if ( ! isset( $product ) || get_option( 'woocommerce_enable_review_rating' ) != 'yes' ) return;
$count = $product->get_rating_count();
if ( $count > 0 ) {
$average = $product->get_average_rating();
echo '
';
echo '
' . esc_html( $average ) . ' ' . esc_html__( 'out of 5', 'vamtam-consulting' ) . '
';
echo '
';
}
}
add_action( 'woocommerce_single_product_summary', 'vamtam_woocommerce_rating', 15, 0 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
/**
* Move .onsale inside the images div
*/
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
add_action( 'vamtam_woocommerce_before_single_product_images', 'woocommerce_show_product_sale_flash', 10 );
/**
* star rating for the shop loop, related product, etc.
*/
function woocommerce_template_loop_rating() {
vamtam_woocommerce_rating();
}
/**
* wrap the product thumbnails in div.product-thumbnail
*/
function woocommerce_template_loop_product_thumbnail() {
echo '
' . wp_kses_post( woocommerce_get_product_thumbnail() ) . '
';
}
/**
* Show the product title in the product loop. By default this is an H3.
*/
function woocommerce_template_loop_product_title() {
echo '
' . get_the_title() . ' ';
}
/**
* WooCommerce catalog/related products excerpt
*/
function vamtam_woocommerce_catalog_excerpt() {
global $post;
if ( ! $post->post_excerpt ) return;
$excerpt_length = apply_filters( 'vamtam_woocommerce_catalog_excerpt_length', 60 );
$excerpt = explode( "\n", wordwrap( $post->post_excerpt, $excerpt_length ) );
if (count( $excerpt ) > 1)
$excerpt[0] .= '...';
$excerpt = $excerpt[0];
?>
' . esc_html__( 'Your Rating', 'vamtam-consulting' ) . '
' . esc_html__( 'Rate…', 'vamtam-consulting' ) . '
' . esc_html__( 'Perfect', 'vamtam-consulting' ) . '
' . esc_html__( 'Good', 'vamtam-consulting' ) . '
' . esc_html__( 'Average', 'vamtam-consulting' ) . '
' . esc_html__( 'Not that bad', 'vamtam-consulting' ) . '
' . esc_html__( 'Very Poor', 'vamtam-consulting' ) . '
'; }
$comment_form['comment_field'] .= '';
return $comment_form;
}
add_filter( 'woocommerce_product_review_comment_form_args', 'vamtam_woocommerce_product_review_comment_form_args' );
add_filter( 'woocommerce_get_stock_html', 'vamtam_wc_get_stock_html', 10, 3 );
function vamtam_wc_get_stock_html( $availability_html, $product ) {
$availability = $product->get_availability();
return empty( $availability['availability'] ) ? '' : '
' . wp_kses_post( $availability['availability'] ) . '
';
}
// before_shop_loop_item_title
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
if ( ! class_exists( 'WC_pac' ) || get_option( 'wc_pac_rating' ) !== 'no' ) {
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_rating', 45 );
}
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 40 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
if ( ! class_exists( 'WC_pac' ) || get_option( 'wc_pac_add_to_cart' ) !== 'no' ) {
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 50 );
}
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', 65 );
// reorder wC PAC categories
function vamtam_reorder_wc_pac() {
if ( isset( $GLOBALS['wp_filter']['woocommerce_after_shop_loop_item']->callbacks[30] ) ) {
foreach ( $GLOBALS['wp_filter']['woocommerce_after_shop_loop_item']->callbacks[30] as $key => $callback ) {
if ( is_array( $callback['function'] ) && $callback['function'][1] === 'woocommerce_pac_show_product_categories' ) {
remove_action( 'woocommerce_after_shop_loop_item', $callback['function'], 30 );
add_action( 'woocommerce_before_shop_loop_item_title', $callback['function'], 60 );
}
}
}
}
add_action( 'wp', 'vamtam_reorder_wc_pac', 100 );
// after_shop_loop_item
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
if ( ! class_exists( 'WC_pac' ) || get_option( 'wc_pac_rating' ) !== 'no' ) {
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_rating', 45 );
}
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
if ( ! class_exists( 'WC_pac' ) || get_option( 'wc_pac_price' ) !== 'no' ) {
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_price', 50 );
}
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
function vamtam_before_single_product_summary() {
// check vamtam_after_single_product_summary() if modifying this line
echo '
';
}
add_action( 'woocommerce_before_single_product_summary', 'vamtam_before_single_product_summary', 1 );
function vamtam_after_single_product_summary() {
// check vamtam_before_single_product_summary() if modifying this line
echo '
';
}
add_action( 'woocommerce_after_single_product_summary', 'vamtam_after_single_product_summary', 1 );
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
add_action( 'woocommerce_after_cart_table', 'woocommerce_cross_sell_display' );
add_filter( 'woocommerce_cross_sells_columns', 'vamtam_woocommerce_columns' );
add_filter( 'woocommerce_product_description_heading', '__return_false' );
/**
* Show a shop page description on product archives
*
* @access public
* @subpackage Archives
* @return void
*/
function woocommerce_product_archive_description() {
if ( is_post_type_archive( 'product' ) && get_query_var( 'paged' ) == 0 && ! is_search() ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
// this IS content, why not apply the filters anyway?
echo apply_filters( 'the_content', wp_kses_post( $shop_page->post_content ) ); // xss ok
}
}
}
}