Woocommerce 3.1.0 Compatability

This commit is contained in:
Jason King 2017-06-29 22:09:46 +09:30 committed by GitHub
parent a43eabee36
commit 870e184c7b
1 changed files with 70 additions and 66 deletions

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', 'woocommerce' ) . '</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 );
?> ?>
@ -128,9 +128,9 @@ 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' ); ?>