Merge pull request #359 from typeplus/master

Woocommerce 3.1.0 Template Compatability
This commit is contained in:
Holger 2017-06-30 12:40:00 +02:00 committed by GitHub
commit 447a985a04
6 changed files with 115 additions and 135 deletions

View File

@ -13,24 +13,21 @@
* @see https://docs.woocommerce.com/document/template-structure/ * @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes * @author WooThemes
* @package WooCommerce/Templates * @package WooCommerce/Templates
* @version 2.0.0 * @version 3.1.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly. exit; // Exit if accessed directly
} }
wc_print_notices(); wc_print_notices();
?> /**
* @hooked wc_empty_cart_message - 10
*/
do_action( 'woocommerce_cart_is_empty' );
<p class="cart-empty"> if ( wc_get_page_id( 'shop' ) > 0 ) : ?>
<?php esc_html_e( 'Your cart is currently empty.', 'understrap' ) ?>
</p>
<?php do_action( 'woocommerce_cart_is_empty' ); ?>
<?php if ( wc_get_page_id( 'shop' ) > 0 ) : ?>
<p class="return-to-shop"> <p class="return-to-shop">
<a class="btn btn-outline-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"> <a class="btn btn-outline-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
<?php _e( 'Return To Shop', 'understrap' ) ?> <?php _e( 'Return To Shop', 'understrap' ) ?>

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Cart Page * Cart Page
* Updated for Understrap to maintain Woocommerce 3.0.3 compatability. *
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.php. * This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.php.
* *
* HOWEVER, on occasion WooCommerce will need to update template files and you * HOWEVER, on occasion WooCommerce will need to update template files and you
@ -13,11 +13,11 @@
* @see https://docs.woocommerce.com/document/template-structure/ * @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes * @author WooThemes
* @package WooCommerce/Templates * @package WooCommerce/Templates
* @version 3.0.3 * @version 3.1.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit;
} }
wc_print_notices(); wc_print_notices();
@ -38,7 +38,7 @@ do_action( 'woocommerce_before_cart' ); ?>
<th class="product-subtotal"><?php _e( 'Total', 'understrap' ); ?></th> <th class="product-subtotal"><?php _e( 'Total', 'understrap' ); ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php do_action( 'woocommerce_before_cart_contents' ); ?> <?php do_action( 'woocommerce_before_cart_contents' ); ?>
<?php <?php
@ -63,60 +63,60 @@ do_action( 'woocommerce_before_cart' ); ?>
?> ?>
</td> </td>
<td class="product-thumbnail"> <td class="product-thumbnail">
<?php <?php
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
if ( ! $product_permalink ) { if ( ! $product_permalink ) {
echo $thumbnail; echo $thumbnail;
} else { } else {
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail );
} }
?> ?>
</td> </td>
<td class="product-name" data-title="<?php _e( 'Product', 'understrap' ); ?>"> <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'understrap' ); ?>">
<?php <?php
if ( ! $product_permalink ) { if ( ! $product_permalink ) {
echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ) . '&nbsp;'; echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;';
} else { } else {
echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_title() ), $cart_item, $cart_item_key ); echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key );
} }
// Meta data // Meta data
echo WC()->cart->get_item_data( $cart_item ); echo WC()->cart->get_item_data( $cart_item );
// Backorder notification // Backorder notification
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) { if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
echo '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'understrap' ) . '</p>'; echo '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'understrap' ) . '</p>';
} }
?> ?>
</td> </td>
<td class="product-price" data-title="<?php _e( 'Price', 'understrap' ); ?>"> <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'understrap' ); ?>">
<?php <?php
echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
?> ?>
</td> </td>
<td class="product-quantity" data-title="<?php _e( 'Quantity', 'understrap' ); ?>"> <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'understrap' ); ?>">
<?php <?php
if ( $_product->is_sold_individually() ) { if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key ); $product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
} else { } else {
$product_quantity = woocommerce_quantity_input( array( $product_quantity = woocommerce_quantity_input( array(
'input_name' => "cart[{$cart_item_key}][qty]", 'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'], 'input_value' => $cart_item['quantity'],
'max_value' => $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(), 'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0' 'min_value' => '0',
), $_product, false ); ), $_product, false );
} }
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item );
?> ?>
</td> </td>
<td class="product-subtotal" data-title="<?php esc_attr_e( 'Total', 'understrap' ); ?>"> <td class="product-subtotal" data-title="<?php esc_attr_e( 'Total', 'understrap' ); ?>">
<?php <?php
echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key );
?> ?>
@ -129,8 +129,8 @@ do_action( 'woocommerce_before_cart' ); ?>
<?php do_action( 'woocommerce_cart_contents' ); ?> <?php do_action( 'woocommerce_cart_contents' ); ?>
<tr> <tr>
<td colspan="6" class="actions"> <td colspan="6" class="actions">
<?php if ( wc_coupons_enabled() ) { ?> <?php if ( wc_coupons_enabled() ) { ?>
<div class="coupon"> <div class="coupon">
@ -141,24 +141,28 @@ do_action( 'woocommerce_before_cart' ); ?>
<input type="submit" class="btn btn-outline-primary" name="update_cart" value="<?php esc_attr_e( 'Update Cart', 'understrap' ); ?>" /> <input type="submit" class="btn btn-outline-primary" name="update_cart" value="<?php esc_attr_e( 'Update Cart', 'understrap' ); ?>" />
<?php do_action( 'woocommerce_cart_actions' ); ?> <?php do_action( 'woocommerce_cart_actions' ); ?>
<?php wp_nonce_field( 'woocommerce-cart' ); ?> <?php wp_nonce_field( 'woocommerce-cart' ); ?>
</td> </td>
</tr> </tr>
<?php do_action( 'woocommerce_after_cart_contents' ); ?>
</tbody>
</table>
<?php do_action( 'woocommerce_after_cart_table' ); ?>
<?php do_action( 'woocommerce_after_cart_contents' ); ?>
</tbody>
</table>
<?php do_action( 'woocommerce_after_cart_table' ); ?>
</form> </form>
<div class="cart-collaterals"> <div class="cart-collaterals">
<?php
<?php do_action( 'woocommerce_cart_collaterals' ); ?> /**
* woocommerce_cart_collaterals hook.
*
* @hooked woocommerce_cross_sell_display
* @hooked woocommerce_cart_totals - 10
*/
do_action( 'woocommerce_cart_collaterals' );
?>
</div> </div>
<?php do_action( 'woocommerce_after_cart' ); ?> <?php do_action( 'woocommerce_after_cart' ); ?>

View File

@ -15,36 +15,34 @@
* @see https://docs.woocommerce.com/document/template-structure/ * @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes * @author WooThemes
* @package WooCommerce/Templates * @package WooCommerce/Templates
* @version 2.5.0 * @version 3.1.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit;
} }
?> do_action( 'woocommerce_before_mini_cart' ); ?>
<?php do_action( 'woocommerce_before_mini_cart' ); ?> <?php if ( ! WC()->cart->is_empty() ) : ?>
<ul class="cart_list product_list_widget <?php echo $args['list_class']; ?>">
<?php if ( ! WC()->cart->is_empty() ) : ?>
<ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">
<?php <?php
do_action( 'woocommerce_before_mini_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) { if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
$product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ); $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
$product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); $product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
?> ?>
<li class="<?php echo esc_attr( apply_filters( 'woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key ) ); ?>"> <li class="woocommerce-mini-cart-item <?php echo esc_attr( apply_filters( 'woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key ) ); ?>">
<?php <?php
echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf( echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf(
'<a href="%s" class="remove" title="%s" data-product_id="%s" data-product_sku="%s">&times;</a>', '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
esc_url( WC()->cart->get_remove_url( $cart_item_key ) ), esc_url( WC()->cart->get_remove_url( $cart_item_key ) ),
esc_attr__( 'Remove this item', 'understrap' ), esc_attr__( 'Remove this item', 'understrap' ),
esc_attr( $product_id ), esc_attr( $product_id ),
@ -65,26 +63,20 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php <?php
} }
} }
do_action( 'woocommerce_mini_cart_contents' );
?> ?>
</ul>
<?php else : ?> <p class="woocommerce-mini-cart__total total"><strong><?php _e( 'Subtotal', 'understrap' ); ?>:</strong> <?php echo WC()->cart->get_cart_subtotal(); ?></p>
<li class="empty"><?php _e( 'No products in the cart.', 'understrap' ); ?></li>
<?php endif; ?>
</ul><!-- end product list -->
<?php if ( ! WC()->cart->is_empty() ) : ?>
<p class="total"><strong><?php _e( 'Subtotal', 'understrap' ); ?>:</strong> <?php echo WC()->cart->get_cart_subtotal(); ?></p>
<?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?> <?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?>
<p class="buttons"> <p class="woocommerce-mini-cart__buttons buttons"><?php do_action( 'woocommerce_widget_shopping_cart_buttons' ); ?></p>
<a href="<?php echo esc_url( wc_get_cart_url() ); ?>" class="btn btn-outline-primary"><?php _e( 'View Cart', 'understrap' ); ?></a>
<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="btn btn-primary"><?php _e( 'Checkout', 'understrap' ); ?></a> <?php else : ?>
</p>
<p class="woocommerce-mini-cart__empty-message"><?php _e( 'No products in the cart.', 'understrap' ); ?></p>
<?php endif; ?> <?php endif; ?>

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Single Product Thumbnails * Single Product Thumbnails
* Updated for Understrap to maintain Woocommerce 3.0.3 compatability. *
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-thumbnails.php. * This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-thumbnails.php.
* *
* HOWEVER, on occasion WooCommerce will need to update template files and you * HOWEVER, on occasion WooCommerce will need to update template files and you
@ -13,7 +13,7 @@
* @see https://docs.woocommerce.com/document/template-structure/ * @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes * @author WooThemes
* @package WooCommerce/Templates * @package WooCommerce/Templates
* @version 3.0.2 * @version 3.1.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
@ -28,10 +28,9 @@ if ( $attachment_ids && has_post_thumbnail() ) {
foreach ( $attachment_ids as $attachment_id ) { foreach ( $attachment_ids as $attachment_id ) {
$full_size_image = wp_get_attachment_image_src( $attachment_id, 'full' ); $full_size_image = wp_get_attachment_image_src( $attachment_id, 'full' );
$thumbnail = wp_get_attachment_image_src( $attachment_id, 'shop_thumbnail' ); $thumbnail = wp_get_attachment_image_src( $attachment_id, 'shop_thumbnail' );
$image_title = get_post_field( 'post_excerpt', $attachment_id ); $attributes = array(
'title' => get_post_field( 'post_title', $attachment_id ),
$attributes = array( 'data-caption' => get_post_field( 'post_excerpt', $attachment_id ),
'title' => $image_title,
'data-src' => $full_size_image[0], 'data-src' => $full_size_image[0],
'data-large_image' => $full_size_image[0], 'data-large_image' => $full_size_image[0],
'data-large_image_width' => $full_size_image[1], 'data-large_image_width' => $full_size_image[1],

View File

@ -10,10 +10,10 @@
* happen. When this occurs the version of the template file will be bumped and * happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes. * the readme will list any important changes.
* *
* @see https://docs.woocommerce.com/document/template-structure/ * @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes * @author WooThemes
* @package WooCommerce/Templates * @package WooCommerce/Templates
* @version 2.3.2 * @version 3.1.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
global $product; global $product;
if ( get_option( 'woocommerce_enable_review_rating' ) === 'no' ) { if ( 'no' === get_option( 'woocommerce_enable_review_rating' ) ) {
return; return;
} }
@ -32,14 +32,9 @@ $average = $product->get_average_rating();
if ( $rating_count > 0 ) : ?> if ( $rating_count > 0 ) : ?>
<div class="woocommerce-product-rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> <div class="woocommerce-product-rating">
<div class="star-rating text-primary" title="<?php printf( __( 'Rated %s out of 5', 'understrap' ), $average ); ?>"> <?php echo wc_get_rating_html( $average, $rating_count ); ?>
<span style="width:<?php echo ( ( $average / 5 ) * 100 ); ?>%"> <?php if ( comments_open() ) : ?><a href="#reviews" class="woocommerce-review-link" rel="nofollow">(<?php printf( _n( '%s customer review', '%s customer reviews', $review_count, 'understrap' ), '<span class="count">' . esc_html( $review_count ) . '</span>' ); ?>)</a><?php endif ?>
<strong itemprop="ratingValue" class="rating"><?php echo esc_html( $average ); ?></strong> <?php printf( __( 'out of %s5%s', 'understrap' ), '<span itemprop="bestRating">', '</span>' ); ?>
<?php printf( _n( 'based on %s customer rating', 'based on %s customer ratings', $rating_count, 'understrap' ), '<span itemprop="ratingCount" class="rating">' . $rating_count . '</span>' ); ?>
</span>
</div>
<?php if ( comments_open() ) : ?><a href="#reviews" class="woocommerce-review-link" rel="nofollow">(<?php printf( _n( '%s customer review', '%s customer reviews', $review_count, 'understrap' ), '<span itemprop="reviewCount" class="count">' . $review_count . '</span>' ); ?>)</a><?php endif ?>
</div> </div>
<?php endif; ?> <?php endif; ?>

View File

@ -1,8 +1,8 @@
<?php <?php
/** /**
* The template to display the reviewers star rating in reviews * The template to display the reviewers star rating in reviews
* Updated for Understrap to maintain Woocommerce 3.0.3 compatability. *
* This template can be overridden by copying it to yourtheme/woocommerce/content-product.php. * This template can be overridden by copying it to yourtheme/woocommerce/review-rating.php.
* *
* HOWEVER, on occasion WooCommerce will need to update template files and you * HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to * (the theme developer) will need to copy the new files to your theme to
@ -13,7 +13,7 @@
* @see https://docs.woocommerce.com/document/template-structure/ * @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes * @author WooThemes
* @package WooCommerce/Templates * @package WooCommerce/Templates
* @version 3.0.0 * @version 3.1.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
@ -23,13 +23,6 @@ if ( ! defined( 'ABSPATH' ) ) {
global $comment; global $comment;
$rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) ); $rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
if ( $rating && get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) { ?> if ( $rating && 'yes' === get_option( 'woocommerce_enable_review_rating' ) ) {
echo wc_get_rating_html( $rating );
<div class="star-rating"> }
<span style="width:<?php echo ( esc_attr( $rating ) / 5 ) * 100; ?>%"><?php
/* translators: %s: rating */
printf( esc_html__( '%s out of 5', 'understrap' ), '<strong>' . $rating . '</strong>' );
?></span>
</div>
<?php }