cart->is_empty() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ) {
// When on the checkout with an empty cart, redirect to cart page.
wc_add_notice( __( 'Checkout is not available whilst your cart is empty.', 'woocommerce' ), 'notice' );
wp_safe_redirect( wc_get_page_permalink( 'cart' ) );
exit;
} elseif ( isset( $wp->query_vars['customer-logout'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'customer-logout' ) ) { // WPCS: input var ok, CSRF ok.
// Logout.
wp_safe_redirect( str_replace( '&', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );
exit;
} elseif ( isset( $wp->query_vars['customer-logout'] ) && 'true' === $wp->query_vars['customer-logout'] ) {
// Redirect to the correct logout endpoint.
wp_safe_redirect( esc_url_raw( wc_get_account_endpoint_url( 'customer-logout' ) ) );
exit;
} elseif ( is_search() && is_post_type_archive( 'product' ) && apply_filters( 'woocommerce_redirect_single_search_result', true ) && 1 === absint( $wp_query->found_posts ) ) {
// Redirect to the product page if we have a single product.
$product = wc_get_product( $wp_query->post );
if ( $product && $product->is_visible() ) {
wp_safe_redirect( get_permalink( $product->get_id() ), 302 );
exit;
}
} elseif ( is_add_payment_method_page() ) {
// Ensure payment gateways are loaded early.
WC()->payment_gateways();
} elseif ( is_checkout() ) {
// Checkout pages handling
// Buffer the checkout page.
ob_start();
// Ensure gateways and shipping methods are loaded early.
WC()->payment_gateways();
WC()->shipping();
}
}
add_action( 'template_redirect', 'wc_template_redirect' );
/**
* When loading sensitive checkout or account pages, send a HTTP header to limit rendering of pages to same origin iframes for security reasons.
*
* Can be disabled with: remove_action( 'template_redirect', 'wc_send_frame_options_header' );
*
* @since 2.3.10
*/
function wc_send_frame_options_header() {
if ( is_checkout() || is_account_page() ) {
send_frame_options_header();
}
}
add_action( 'template_redirect', 'wc_send_frame_options_header' );
/**
* No index our endpoints.
* Prevent indexing pages like order-received.
*
* @since 2.5.3
*/
function wc_prevent_endpoint_indexing() {
if ( is_wc_endpoint_url() || isset( $_GET['download_file'] ) ) { // WPCS: input var ok, CSRF ok.
@header( 'X-Robots-Tag: noindex' ); // @codingStandardsIgnoreLine
}
}
add_action( 'template_redirect', 'wc_prevent_endpoint_indexing' );
/**
* Remove adjacent_posts_rel_link_wp_head - pointless for products.
*
* @since 3.0.0
*/
function wc_prevent_adjacent_posts_rel_link_wp_head() {
if ( is_singular( 'product' ) ) {
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
}
}
add_action( 'template_redirect', 'wc_prevent_adjacent_posts_rel_link_wp_head' );
/**
* Show the gallery if JS is disabled.
*
* @since 3.0.6
*/
function wc_gallery_noscript() {
?>
post_type ) || ! in_array( $the_post->post_type, array( 'product', 'product_variation' ), true ) ) {
return;
}
$GLOBALS['product'] = wc_get_product( $the_post );
return $GLOBALS['product'];
}
add_action( 'the_post', 'wc_setup_product_data' );
/**
* Sets up the woocommerce_loop global from the passed args or from the main query.
*
* @since 3.3.0
* @param array $args Args to pass into the global.
*/
function wc_setup_loop( $args = array() ) {
$default_args = array(
'loop' => 0,
'columns' => wc_get_default_products_per_row(),
'name' => '',
'is_shortcode' => false,
'is_paginated' => true,
'is_search' => false,
'is_filtered' => false,
'total' => 0,
'total_pages' => 0,
'per_page' => 0,
'current_page' => 1,
);
// If this is a main WC query, use global args as defaults.
if ( $GLOBALS['wp_query']->get( 'wc_query' ) ) {
$default_args = array_merge( $default_args, array(
'is_search' => $GLOBALS['wp_query']->is_search(),
'is_filtered' => is_filtered(),
'total' => $GLOBALS['wp_query']->found_posts,
'total_pages' => $GLOBALS['wp_query']->max_num_pages,
'per_page' => $GLOBALS['wp_query']->get( 'posts_per_page' ),
'current_page' => max( 1, $GLOBALS['wp_query']->get( 'paged', 1 ) ),
) );
}
// Merge any existing values.
if ( isset( $GLOBALS['woocommerce_loop'] ) ) {
$default_args = array_merge( $default_args, $GLOBALS['woocommerce_loop'] );
}
$GLOBALS['woocommerce_loop'] = wp_parse_args( $args, $default_args );
}
add_action( 'woocommerce_before_shop_loop', 'wc_setup_loop' );
/**
* Resets the woocommerce_loop global.
*
* @since 3.3.0
*/
function wc_reset_loop() {
unset( $GLOBALS['woocommerce_loop'] );
}
add_action( 'woocommerce_after_shop_loop', 'woocommerce_reset_loop', 999 );
/**
* Gets a property from the woocommerce_loop global.
*
* @since 3.3.0
* @param string $prop Prop to get.
* @param string $default Default if the prop does not exist.
* @return mixed
*/
function wc_get_loop_prop( $prop, $default = '' ) {
wc_setup_loop(); // Ensure shop loop is setup.
return isset( $GLOBALS['woocommerce_loop'], $GLOBALS['woocommerce_loop'][ $prop ] ) ? $GLOBALS['woocommerce_loop'][ $prop ] : $default;
}
/**
* Sets a property in the woocommerce_loop global.
*
* @since 3.3.0
* @param string $prop Prop to set.
* @param string $value Value to set.
*/
function wc_set_loop_prop( $prop, $value = '' ) {
if ( ! isset( $GLOBALS['woocommerce_loop'] ) ) {
wc_setup_loop();
}
$GLOBALS['woocommerce_loop'][ $prop ] = $value;
}
/**
* Should the WooCommerce loop be displayed?
*
* This will return true if we have posts (products) or if we have subcats to display.
*
* @since 3.4.0
* @return bool
*/
function woocommerce_product_loop() {
return have_posts() || 'products' !== woocommerce_get_loop_display_mode();
}
/**
* Output generator tag to aid debugging.
*
* @access public
*
* @param string $gen Generator.
* @param string $type Type.
*
* @return string
*/
function wc_generator_tag( $gen, $type ) {
switch ( $type ) {
case 'html':
$gen .= "\n" . '';
break;
case 'xhtml':
$gen .= "\n" . '';
break;
}
return $gen;
}
/**
* Add body classes for WC pages.
*
* @param array $classes Body Classes.
* @return array
*/
function wc_body_class( $classes ) {
$classes = (array) $classes;
if ( is_woocommerce() ) {
$classes[] = 'woocommerce';
$classes[] = 'woocommerce-page';
} elseif ( is_checkout() ) {
$classes[] = 'woocommerce-checkout';
$classes[] = 'woocommerce-page';
} elseif ( is_cart() ) {
$classes[] = 'woocommerce-cart';
$classes[] = 'woocommerce-page';
} elseif ( is_account_page() ) {
$classes[] = 'woocommerce-account';
$classes[] = 'woocommerce-page';
}
if ( is_store_notice_showing() ) {
$classes[] = 'woocommerce-demo-store';
}
foreach ( WC()->query->get_query_vars() as $key => $value ) {
if ( is_wc_endpoint_url( $key ) ) {
$classes[] = 'woocommerce-' . sanitize_html_class( $key );
}
}
$classes[] = 'woocommerce-no-js';
add_action( 'wp_footer', 'wc_no_js' );
return array_unique( $classes );
}
/**
* NO JS handling.
*
* @since 3.4.0
*/
function wc_no_js() {
?>
$max_columns ) {
$columns = $max_columns;
update_option( 'woocommerce_catalog_columns', $columns );
}
if ( has_filter( 'loop_shop_columns' ) ) { // Legacy filter handling.
$columns = apply_filters( 'loop_shop_columns', $columns );
}
$columns = absint( $columns );
return max( 1, $columns );
}
/**
* Get the default rows setting - this is how many product rows will be shown in loops.
*
* @since 3.3.0
* @return int
*/
function wc_get_default_product_rows_per_page() {
$rows = absint( get_option( 'woocommerce_catalog_rows', 4 ) );
$product_grid = wc_get_theme_support( 'product_grid' );
$min_rows = isset( $product_grid['min_rows'] ) ? absint( $product_grid['min_rows'] ) : 0;
$max_rows = isset( $product_grid['max_rows'] ) ? absint( $product_grid['max_rows'] ) : 0;
if ( $min_rows && $rows < $min_rows ) {
$rows = $min_rows;
update_option( 'woocommerce_catalog_rows', $rows );
} elseif ( $max_rows && $rows > $max_rows ) {
$rows = $max_rows;
update_option( 'woocommerce_catalog_rows', $rows );
}
return $rows;
}
/**
* Reset the product grid settings when a new theme is activated.
*
* @since 3.3.0
*/
function wc_reset_product_grid_settings() {
$product_grid = wc_get_theme_support( 'product_grid' );
if ( ! empty( $product_grid['default_rows'] ) ) {
update_option( 'woocommerce_catalog_rows', absint( $product_grid['default_rows'] ) );
}
if ( ! empty( $product_grid['default_columns'] ) ) {
update_option( 'woocommerce_catalog_columns', absint( $product_grid['default_columns'] ) );
}
}
add_action( 'after_switch_theme', 'wc_reset_product_grid_settings' );
/**
* Get classname for woocommerce loops.
*
* @since 2.6.0
* @return string
*/
function wc_get_loop_class() {
$loop_index = wc_get_loop_prop( 'loop', 0 );
$columns = absint( max( 1, wc_get_loop_prop( 'columns', wc_get_default_products_per_row() ) ) );
$loop_index ++;
wc_set_loop_prop( 'loop', $loop_index );
if ( 0 === ( $loop_index - 1 ) % $columns || 1 === $columns ) {
return 'first';
} elseif ( 0 === $loop_index % $columns ) {
return 'last';
} else {
return '';
}
}
/**
* Get the classes for the product cat div.
*
* @since 2.4.0
*
* @param string|array $class One or more classes to add to the class list.
* @param object $category object Optional.
*
* @return array
*/
function wc_get_product_cat_class( $class = '', $category = null ) {
$classes = is_array( $class ) ? $class : array_map( 'trim', explode( ' ', $class ) );
$classes[] = 'product-category';
$classes[] = 'product';
$classes[] = wc_get_loop_class();
$classes = apply_filters( 'product_cat_class', $classes, $class, $category );
return array_unique( array_filter( $classes ) );
}
/**
* Adds extra post classes for products.
*
* @since 2.1.0
* @param array $classes Current classes.
* @param string|array $class Additional class.
* @param int $post_id Post ID.
* @return array
*/
function wc_product_post_class( $classes, $class = '', $post_id = '' ) {
if ( ! $post_id || ! in_array( get_post_type( $post_id ), array( 'product', 'product_variation' ), true ) ) {
return $classes;
}
$product = wc_get_product( $post_id );
if ( $product ) {
$classes[] = 'product';
$classes[] = wc_get_loop_class();
$classes[] = $product->get_stock_status();
if ( $product->is_on_sale() ) {
$classes[] = 'sale';
}
if ( $product->is_featured() ) {
$classes[] = 'featured';
}
if ( $product->is_downloadable() ) {
$classes[] = 'downloadable';
}
if ( $product->is_virtual() ) {
$classes[] = 'virtual';
}
if ( $product->is_sold_individually() ) {
$classes[] = 'sold-individually';
}
if ( $product->is_taxable() ) {
$classes[] = 'taxable';
}
if ( $product->is_shipping_taxable() ) {
$classes[] = 'shipping-taxable';
}
if ( $product->is_purchasable() ) {
$classes[] = 'purchasable';
}
if ( $product->get_type() ) {
$classes[] = 'product-type-' . $product->get_type();
}
if ( $product->is_type( 'variable' ) ) {
if ( ! $product->get_default_attributes() ) {
$classes[] = 'has-default-attributes';
}
if ( $product->has_child() ) {
$classes[] = 'has-children';
}
}
}
$key = array_search( 'hentry', $classes, true );
if ( false !== $key ) {
unset( $classes[ $key ] );
}
return $classes;
}
/**
* Outputs hidden form inputs for each query string variable.
*
* @since 3.0.0
* @param array $values Name value pairs.
* @param array $exclude Keys to exclude.
* @param string $current_key Current key we are outputting.
* @param bool $return Whether to return.
* @return string
*/
function wc_query_string_form_fields( $values = null, $exclude = array(), $current_key = '', $return = false ) {
if ( is_null( $values ) ) {
$values = $_GET; // WPCS: input var ok, CSRF ok.
}
$html = '';
foreach ( $values as $key => $value ) {
if ( in_array( $key, $exclude, true ) ) {
continue;
}
if ( $current_key ) {
$key = $current_key . '[' . $key . ']';
}
if ( is_array( $value ) ) {
$html .= wc_query_string_form_fields( $value, $exclude, $key, true );
} else {
$html .= '';
}
}
if ( $return ) {
return $html;
} else {
echo $html; // WPCS: XSS ok.
}
}
/**
* Template pages
*/
if ( ! function_exists( 'woocommerce_content' ) ) {
/**
* Output WooCommerce content.
*
* This function is only used in the optional 'woocommerce.php' template.
* which people can add to their themes to add basic woocommerce support.
* without hooks or modifying core templates.
*/
function woocommerce_content() {
if ( is_singular( 'product' ) ) {
while ( have_posts() ) :
the_post();
wc_get_template_part( 'content', 'single-product' );
endwhile;
} else {
?>
' . wp_kses_post( $notice ) . ' ' . esc_html__( 'Dismiss', 'woocommerce' ) . '', $notice ); // WPCS: XSS ok.
}
}
/**
* Loop
*/
if ( ! function_exists( 'woocommerce_page_title' ) ) {
/**
* Page Title function.
*
* @param bool $echo Should echo title.
* @return string
*/
function woocommerce_page_title( $echo = true ) {
if ( is_search() ) {
/* translators: %s: search query */
$page_title = sprintf( __( 'Search results: “%s”', 'woocommerce' ), get_search_query() );
if ( get_query_var( 'paged' ) ) {
/* translators: %s: page number */
$page_title .= sprintf( __( ' – Page %s', 'woocommerce' ), get_query_var( 'paged' ) );
}
} elseif ( is_tax() ) {
$page_title = single_term_title( '', false );
} else {
$shop_page_id = wc_get_page_id( 'shop' );
$page_title = get_the_title( $shop_page_id );
}
$page_title = apply_filters( 'woocommerce_page_title', $page_title );
if ( $echo ) {
echo $page_title; // WPCS: XSS ok.
} else {
return $page_title;
}
}
}
if ( ! function_exists( 'woocommerce_product_loop_start' ) ) {
/**
* Output the start of a product loop. By default this is a UL.
*
* @param bool $echo Should echo?.
* @return string
*/
function woocommerce_product_loop_start( $echo = true ) {
ob_start();
wc_set_loop_prop( 'loop', 0 );
wc_get_template( 'loop/loop-start.php' );
$loop_start = apply_filters( 'woocommerce_product_loop_start', ob_get_clean() );
if ( $echo ) {
echo $loop_start; // WPCS: XSS ok.
} else {
return $loop_start;
}
}
}
if ( ! function_exists( 'woocommerce_product_loop_end' ) ) {
/**
* Output the end of a product loop. By default this is a UL.
*
* @param bool $echo Should echo?.
* @return string
*/
function woocommerce_product_loop_end( $echo = true ) {
ob_start();
wc_get_template( 'loop/loop-end.php' );
$loop_end = apply_filters( 'woocommerce_product_loop_end', ob_get_clean() );
if ( $echo ) {
echo $loop_end; // WPCS: XSS ok.
} else {
return $loop_end;
}
}
}
if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) {
/**
* Show the product title in the product loop. By default this is an H2.
*/
function woocommerce_template_loop_product_title() {
echo '
' . get_the_title() . '
';
}
}
if ( ! function_exists( 'woocommerce_template_loop_category_title' ) ) {
/**
* Show the subcategory title in the product loop.
*
* @param object $category Category object.
*/
function woocommerce_template_loop_category_title( $category ) {
?>
name );
if ( $category->count > 0 ) {
echo apply_filters( 'woocommerce_subcategory_count_html', ' (' . esc_html( $category->count ) . ')', $category ); // WPCS: XSS ok.
}
?>
';
}
}
if ( ! function_exists( 'woocommerce_template_loop_product_link_close' ) ) {
/**
* Insert the opening anchor tag for products in the loop.
*/
function woocommerce_template_loop_product_link_close() {
echo '';
}
}
if ( ! function_exists( 'woocommerce_template_loop_category_link_open' ) ) {
/**
* Insert the opening anchor tag for categories in the loop.
*
* @param int|object|string $category Category ID, Object or String.
*/
function woocommerce_template_loop_category_link_open( $category ) {
echo '';
}
}
if ( ! function_exists( 'woocommerce_template_loop_category_link_close' ) ) {
/**
* Insert the closing anchor tag for categories in the loop.
*/
function woocommerce_template_loop_category_link_close() {
echo '';
}
}
if ( ! function_exists( 'woocommerce_taxonomy_archive_description' ) ) {
/**
* Show an archive description on taxonomy archives.
*/
function woocommerce_taxonomy_archive_description() {
if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) {
$term = get_queried_object();
if ( $term && ! empty( $term->description ) ) {
echo '
' . wc_format_content( $term->description ) . '
'; // WPCS: XSS ok.
}
}
}
}
if ( ! function_exists( 'woocommerce_product_archive_description' ) ) {
/**
* Show a shop page description on product archives.
*/
function woocommerce_product_archive_description() {
// Don't display the description on search results page.
if ( is_search() ) {
return;
}
if ( is_post_type_archive( 'product' ) && in_array( absint( get_query_var( 'paged' ) ), array( 0, 1 ), true ) ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
$description = wc_format_content( $shop_page->post_content );
if ( $description ) {
echo '
' . $description . '
'; // WPCS: XSS ok.
}
}
}
}
}
if ( ! function_exists( 'woocommerce_template_loop_add_to_cart' ) ) {
/**
* Get the add to cart template for the loop.
*
* @param array $args Arguments.
*/
function woocommerce_template_loop_add_to_cart( $args = array() ) {
global $product;
if ( $product ) {
$defaults = array(
'quantity' => 1,
'class' => implode( ' ', array_filter( array(
'button',
'product_type_' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
$product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '',
) ) ),
'attributes' => array(
'data-product_id' => $product->get_id(),
'data-product_sku' => $product->get_sku(),
'aria-label' => $product->add_to_cart_description(),
'rel' => 'nofollow',
),
);
$args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product );
if ( isset( $args['attributes']['aria-label'] ) ) {
$args['attributes']['aria-label'] = strip_tags( $args['attributes']['aria-label'] );
}
wc_get_template( 'loop/add-to-cart.php', $args );
}
}
}
if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {
/**
* Get the product thumbnail for the loop.
*/
function woocommerce_template_loop_product_thumbnail() {
echo woocommerce_get_product_thumbnail(); // WPCS: XSS ok.
}
}
if ( ! function_exists( 'woocommerce_template_loop_price' ) ) {
/**
* Get the product price for the loop.
*/
function woocommerce_template_loop_price() {
wc_get_template( 'loop/price.php' );
}
}
if ( ! function_exists( 'woocommerce_template_loop_rating' ) ) {
/**
* Display the average rating in the loop.
*/
function woocommerce_template_loop_rating() {
wc_get_template( 'loop/rating.php' );
}
}
if ( ! function_exists( 'woocommerce_show_product_loop_sale_flash' ) ) {
/**
* Get the sale flash for the loop.
*/
function woocommerce_show_product_loop_sale_flash() {
wc_get_template( 'loop/sale-flash.php' );
}
}
if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) {
/**
* Get the product thumbnail, or the placeholder if not set.
*
* @param string $size (default: 'woocommerce_thumbnail').
* @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0).
* @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0).
* @return string
*/
function woocommerce_get_product_thumbnail( $size = 'woocommerce_thumbnail', $deprecated1 = 0, $deprecated2 = 0 ) {
global $product;
$image_size = apply_filters( 'single_product_archive_thumbnail_size', $size );
return $product ? $product->get_image( $image_size ) : '';
}
}
if ( ! function_exists( 'woocommerce_result_count' ) ) {
/**
* Output the result count text (Showing x - x of x results).
*/
function woocommerce_result_count() {
if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) {
return;
}
$args = array(
'total' => wc_get_loop_prop( 'total' ),
'per_page' => wc_get_loop_prop( 'per_page' ),
'current' => wc_get_loop_prop( 'current_page' ),
);
wc_get_template( 'loop/result-count.php', $args );
}
}
if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
/**
* Output the product sorting options.
*/
function woocommerce_catalog_ordering() {
if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) {
return;
}
$show_default_orderby = 'menu_order' === apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
$catalog_orderby_options = apply_filters( 'woocommerce_catalog_orderby', array(
'menu_order' => __( 'Default sorting', 'woocommerce' ),
'popularity' => __( 'Sort by popularity', 'woocommerce' ),
'rating' => __( 'Sort by average rating', 'woocommerce' ),
'date' => __( 'Sort by newness', 'woocommerce' ),
'price' => __( 'Sort by price: low to high', 'woocommerce' ),
'price-desc' => __( 'Sort by price: high to low', 'woocommerce' ),
) );
$default_orderby = wc_get_loop_prop( 'is_search' ) ? 'relevance' : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', '' ) );
$orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : $default_orderby; // WPCS: sanitization ok, input var ok, CSRF ok.
if ( wc_get_loop_prop( 'is_search' ) ) {
$catalog_orderby_options = array_merge( array( 'relevance' => __( 'Relevance', 'woocommerce' ) ), $catalog_orderby_options );
unset( $catalog_orderby_options['menu_order'] );
}
if ( ! $show_default_orderby ) {
unset( $catalog_orderby_options['menu_order'] );
}
if ( 'no' === get_option( 'woocommerce_enable_review_rating' ) ) {
unset( $catalog_orderby_options['rating'] );
}
if ( ! array_key_exists( $orderby, $catalog_orderby_options ) ) {
$orderby = current( array_keys( $catalog_orderby_options ) );
}
wc_get_template( 'loop/orderby.php', array(
'catalog_orderby_options' => $catalog_orderby_options,
'orderby' => $orderby,
'show_default_orderby' => $show_default_orderby,
) );
}
}
if ( ! function_exists( 'woocommerce_pagination' ) ) {
/**
* Output the pagination.
*/
function woocommerce_pagination() {
if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) {
return;
}
$args = array(
'total' => wc_get_loop_prop( 'total_pages' ),
'current' => wc_get_loop_prop( 'current_page' ),
);
if ( wc_get_loop_prop( 'is_shortcode' ) ) {
$args['base'] = esc_url_raw( add_query_arg( 'product-page', '%#%', false ) );
$args['format'] = '?product-page = %#%';
} else {
$args['base'] = esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) );
$args['format'] = '';
}
wc_get_template( 'loop/pagination.php', $args );
}
}
/**
* Single Product
*/
if ( ! function_exists( 'woocommerce_show_product_images' ) ) {
/**
* Output the product image before the single product summary.
*/
function woocommerce_show_product_images() {
wc_get_template( 'single-product/product-image.php' );
}
}
if ( ! function_exists( 'woocommerce_show_product_thumbnails' ) ) {
/**
* Output the product thumbnails.
*/
function woocommerce_show_product_thumbnails() {
wc_get_template( 'single-product/product-thumbnails.php' );
}
}
/**
* Get HTML for a gallery image.
*
* Woocommerce_gallery_thumbnail_size, woocommerce_gallery_image_size and woocommerce_gallery_full_size accept name based image sizes, or an array of width/height values.
*
* @since 3.3.2
* @param int $attachment_id Attachment ID.
* @param bool $main_image Is this the main image or a thumbnail?.
* @return string
*/
function wc_get_gallery_image_html( $attachment_id, $main_image = false ) {
$flexslider = (bool) apply_filters( 'woocommerce_single_product_flexslider_enabled', get_theme_support( 'wc-product-gallery-slider' ) );
$gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' );
$thumbnail_size = apply_filters( 'woocommerce_gallery_thumbnail_size', array( $gallery_thumbnail['width'], $gallery_thumbnail['height'] ) );
$image_size = apply_filters( 'woocommerce_gallery_image_size', $flexslider || $main_image ? 'woocommerce_single' : $thumbnail_size );
$full_size = apply_filters( 'woocommerce_gallery_full_size', apply_filters( 'woocommerce_product_thumbnails_large_size', 'full' ) );
$thumbnail_src = wp_get_attachment_image_src( $attachment_id, $thumbnail_size );
$full_src = wp_get_attachment_image_src( $attachment_id, $full_size );
$image = wp_get_attachment_image( $attachment_id, $image_size, false, array(
'title' => get_post_field( 'post_title', $attachment_id ),
'data-caption' => get_post_field( 'post_excerpt', $attachment_id ),
'data-src' => $full_src[0],
'data-large_image' => $full_src[0],
'data-large_image_width' => $full_src[1],
'data-large_image_height' => $full_src[2],
'class' => $main_image ? 'wp-post-image' : '',
) );
return '