Merge pull request #1904 from IanDelMar/woo-templates

Update WooCommerce templates
This commit is contained in:
Brian Coords 2022-09-29 13:03:26 -07:00 committed by GitHub
commit 849ff36586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 124 additions and 92 deletions

View File

@ -24,6 +24,13 @@ if ( ! function_exists( 'understrap_woocommerce_support' ) ) {
// Add Bootstrap classes to form fields.
add_filter( 'woocommerce_form_field_args', 'understrap_wc_form_field_args', 10, 3 );
add_filter( 'woocommerce_quantity_input_classes', 'understrap_quantity_input_classes' );
add_filter( 'woocommerce_loop_add_to_cart_args', 'understrap_loop_add_to_cart_args' );
// Wrap the add-to-cart link in `div.add-to-cart-container`.
add_filter( 'woocommerce_loop_add_to_cart_link', 'understrap_loop_add_to_cart_link' );
// Add Bootstrap classes to account navigation.
add_filter( 'woocommerce_account_menu_item_classes', 'understrap_account_menu_item_classes' );
}
}
@ -177,3 +184,65 @@ if ( ! function_exists( 'understrap_quantity_input_classes' ) ) {
return $classes;
}
}
if ( ! function_exists( 'understrap_loop_add_to_cart_link' ) ) {
/**
* Wrap add to cart link in container.
*
* @param string $html Add to cart link HTML.
* @return string Add to cart link HTML.
*/
function understrap_loop_add_to_cart_link( $html ) {
return '<div class="add-to-cart-container">' . $html . '</div>';
}
}
if ( ! function_exists( 'understrap_loop_add_to_cart_args' ) ) {
/**
* Add Bootstrap button classes to add to cart link.
*
* @param array<string,mixed> $args Array of add to cart link arguments.
* @return array<string,mixed> Array of add to cart link arguments.
*/
function understrap_loop_add_to_cart_args( $args ) {
if ( isset( $args['class'] ) && ! empty( $args['class'] ) ) {
if ( ! is_string( $args['class'] ) ) {
return $args;
}
// Remove the `button` class if it exists.
if ( false !== strpos( $args['class'], 'button' ) ) {
$args['class'] = explode( ' ', $args['class'] );
$args['class'] = array_diff( $args['class'], array( 'button' ) );
$args['class'] = implode( ' ', $args['class'] );
}
$args['class'] .= ' btn btn-outline-primary';
} else {
$args['class'] = 'btn btn-outline-primary';
}
if ( 'bootstrap4' === get_theme_mod( 'understrap_bootstrap_version', 'bootstrap4' ) ) {
$args['class'] .= ' btn-block';
}
return $args;
}
}
if ( ! function_exists( 'understrap_account_menu_item_classes' ) ) {
/**
* Add Bootstrap classes to the
*
* @param string[] $classes Array of classes added to the account menu items.
* @return string[] Array of classes added to the account menu items.
*/
function understrap_account_menu_item_classes( $classes ) {
$classes[] = 'list-group-item';
$classes[] = 'list-group-item-action';
if ( in_array( 'is-active', $classes, true ) ) {
$classes[] = 'active';
}
return $classes;
}
}

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.5.0
*/

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.8.0
*/
@ -25,8 +25,8 @@ do_action( 'woocommerce_before_cart' ); ?>
<table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">
<thead>
<tr>
<th class="product-remove">&nbsp;</th>
<th class="product-thumbnail">&nbsp;</th>
<th class="product-remove"><span class="screen-reader-text"><?php esc_html_e( 'Remove item', 'woocommerce' ); ?></span></th>
<th class="product-thumbnail"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail image', 'woocommerce' ); ?></span></th>
<th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
<th class="product-price"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
<th class="product-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>

View File

@ -13,7 +13,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 2.4.0
*/

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.5.0
*/

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.4.4
*/
@ -31,6 +31,7 @@ if ( ! wc_coupons_enabled() ) { // @codingStandardsIgnoreLine.
<p><?php esc_html_e( 'If you have a coupon code, please apply it below.', 'woocommerce' ); ?></p>
<p class="form-row form-row-first">
<label for="coupon_code" class="screen-reader-text"><?php esc_html_e( 'Coupon:', 'woocommerce' ); ?></label>
<input type="text" name="coupon_code" class="form-control" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" id="coupon_code" value="" />
</p>

View File

@ -11,13 +11,13 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 5.2.0
*/
defined( 'ABSPATH' ) || exit;
$item_totals = $order->get_order_item_totals(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$totals = $order->get_order_item_totals(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
?>
<form id="order_review" method="post">
@ -40,7 +40,7 @@ $item_totals = $order->get_order_item_totals(); // phpcs:ignore WordPress.WP.Glo
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
<td class="product-name">
<?php
echo wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) ); // @codingStandardsIgnoreLine
echo wp_kses_post( apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ) );
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, false );
@ -56,8 +56,8 @@ $item_totals = $order->get_order_item_totals(); // phpcs:ignore WordPress.WP.Glo
<?php endif; ?>
</tbody>
<tfoot>
<?php if ( $item_totals ) : ?>
<?php foreach ( $item_totals as $total ) : ?>
<?php if ( $totals ) : ?>
<?php foreach ( $totals as $total ) : ?>
<tr>
<th scope="row" colspan="2"><?php echo $total['label']; ?></th><?php // @codingStandardsIgnoreLine ?>
<td class="product-total"><?php echo $total['value']; ?></td><?php // @codingStandardsIgnoreLine ?>

View File

@ -11,13 +11,13 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.5.3
*/
defined( 'ABSPATH' ) || exit;
if ( ! is_ajax() ) {
if ( ! wp_doing_ajax() ) {
do_action( 'woocommerce_review_order_before_payment' );
}
?>
@ -56,6 +56,6 @@ if ( ! is_ajax() ) {
</div>
</div>
<?php
if ( ! is_ajax() ) {
if ( ! wp_doing_ajax() ) {
do_action( 'woocommerce_review_order_after_payment' );
}

View File

@ -11,19 +11,13 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.6.0
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
if ( is_user_logged_in() ) {
return;
}
@ -54,7 +48,6 @@ if ( is_user_logged_in() ) {
<?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?>
<input type="hidden" name="redirect" value="<?php echo esc_url( $redirect ); ?>" />
<button type="submit" class="btn btn-outline-primary" name="login" value="<?php esc_attr_e( 'Login', 'woocommerce' ); ?>"><?php esc_html_e( 'Login', 'woocommerce' ); ?></button>
</p>
<p class="lost_password">
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'woocommerce' ); ?></a>

View File

@ -1,37 +0,0 @@
<?php
/**
* Loop Add to Cart
*
* This template can be overridden by copying it to yourtheme/woocommerce/loop/add-to-cart.php.
*
* 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
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.3.0
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
global $product;
echo apply_filters(
'woocommerce_loop_add_to_cart_link', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
sprintf(
'<div class="add-to-cart-container"><a href="%s" data-quantity="%s" class="%s product_type_%s single_add_to_cart_button btn btn-outline-primary btn-block %s" %s> %s</a></div>',
esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
esc_attr( $product->get_type() ),
$product->get_type() === 'simple' ? 'ajax_add_to_cart' : '',
isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
esc_html( $product->add_to_cart_text() )
),
$product,
$args
);

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.6.0
*/

View File

@ -13,7 +13,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.2.0
*/

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.5.0
*/

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.6.0
*/

View File

@ -11,8 +11,8 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 4.1.0
* @package WooCommerce\Templates
* @version 6.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -95,7 +95,7 @@ $col = 'yes' === get_option( 'woocommerce_enable_myaccount_registration' ) ? 6 :
<?php else : ?>
<p><?php esc_html_e( 'A password will be sent to your email address.', 'woocommerce' ); ?></p>
<p><?php esc_html_e( 'A link to set a new password will be sent to your email address.', 'woocommerce' ); ?></p>
<?php endif; ?>

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.5.2
*/

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.5.5
*/

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 2.6.0
*/
@ -53,16 +53,17 @@ $col = 1;
<?php foreach ( $get_addresses as $name => $address_title ) : ?>
<?php $address = wc_get_account_formatted_address( $name ); ?>
<div class="u-column woocommerce-Address">
<header class="woocommerce-Address-title title">
<h3><?php echo esc_html( $address_title ); ?></h3>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php echo $address ? esc_html__( 'Edit', 'woocommerce' ) : esc_html__( 'Add', 'woocommerce' ); ?></a>
</header>
<address>
<?php
$address = wc_get_account_formatted_address( $name );
echo $address ? wp_kses_post( $address ) : esc_html_e( 'You have not set up this type of address yet.', 'woocommerce' );
?>
<?php
echo $address ? wp_kses_post( $address ) : esc_html_e( 'You have not set up this type of address yet.', 'woocommerce' );
?>
</address>
</div>

View File

@ -2,8 +2,8 @@
/**
* My Orders - Deprecated
*
* @package WooCommerce/Templates
* @deprecated 2.6.0 this template file is no longer used. My Account shortcode uses orders.php.
* @package WooCommerce\Templates
*/
defined( 'ABSPATH' ) || exit;
@ -49,7 +49,7 @@ if ( $customer_orders ) : ?>
<tbody>
<?php
foreach ( $customer_orders as $customer_order ) :
$order = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Override
$order = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$item_count = $order->get_item_count();
?>
<tr class="order">
@ -77,11 +77,11 @@ if ( $customer_orders ) : ?>
<?php elseif ( 'order-actions' === $column_id ) : ?>
<?php
$orders_actions = wc_get_account_orders_actions( $order );
$actions = wc_get_account_orders_actions( $order );
if ( ! empty( $orders_actions ) ) {
foreach ( $orders_actions as $key => $orders_action ) {
echo '<a href="' . esc_url( $orders_action['url'] ) . '" class="btn btn-outline-primary ' . sanitize_html_class( $key ) . '">' . esc_html( $orders_action['name'] ) . '</a>';
if ( ! empty( $actions ) ) {
foreach ( $actions as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
echo '<a href="' . esc_url( $action['url'] ) . '" class=""btn btn-outline-primary ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}
?>

View File

@ -11,8 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 2.6.0
*/
@ -23,12 +22,18 @@ if ( ! defined( 'ABSPATH' ) ) {
do_action( 'woocommerce_before_account_navigation' );
?>
<nav class="woocommerce-MyAccount-navigation" role="navigation">
<nav class="woocommerce-MyAccount-navigation">
<div class="list-group">
<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"
class="list-group-item list-group-item-action"><?php echo esc_html( $label ); ?></a>
<?php endforeach; ?>
<?php
foreach ( wc_get_account_menu_items() as $endpoint => $label ) {
printf(
'<a href="%s" class="%s">%s</a>',
esc_url( wc_get_account_endpoint_url( $endpoint ) ),
wc_get_account_menu_item_classes( $endpoint ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Ok.
esc_html( $label )
);
}
?>
</div>
</nav>

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.3.0
*/
@ -27,6 +27,6 @@ if ( ! defined( 'ABSPATH' ) ) {
<input type="hidden" name="post_type" value="product" />
<div class="input-group-append">
<button class="btn btn-primary" type="submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'woocommerce' ); ?>"><?php echo esc_html_x( 'Search', 'submit button', 'woocommerce' ); ?></button>
</div>
</div>
</div>
</form>

View File

@ -11,7 +11,7 @@
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.4.0
*/

View File

@ -3,7 +3,7 @@
* Single variation cart button
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @package WooCommerce\Templates
* @version 3.4.0
*/