Changeset 155756 for sydney/1.81/inc/woocommerce.php
- Timestamp:
- 10/04/2021 01:47:40 PM (4 years ago)
- Location:
- sydney/1.81
- Files:
-
- 1 edited
- 1 copied
-
. (copied) (copied from sydney/1.80)
-
inc/woocommerce.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sydney/1.81/inc/woocommerce.php
r139705 r155756 197 197 add_filter( 'woocommerce_product_additional_information_heading', '__return_false' ); 198 198 add_filter( 'woocommerce_product_description_heading', '__return_false' ); 199 200 if ( ! function_exists( 'sydney_woocommerce_cart_link_fragment' ) ) { 201 /** 202 * Cart Fragments. 203 * 204 * Ensure cart contents update when products are added to the cart via AJAX. 205 * 206 * @param array $fragments Fragments to refresh via AJAX. 207 * @return array Fragments to refresh via AJAX. 208 */ 209 function sydney_woocommerce_cart_link_fragment( $fragments ) { 210 ob_start(); 211 ?> 212 213 <span class="cart-count"><i class="sydney-svg-icon"><?php sydney_get_svg_icon( 'icon-cart', true ); ?></i><span class="count-number"><?php echo esc_html( WC()->cart->get_cart_contents_count() ); ?></span></span> 214 215 <?php 216 $fragments['.cart-count'] = ob_get_clean(); 217 218 return $fragments; 219 } 220 } 221 add_filter( 'woocommerce_add_to_cart_fragments', 'sydney_woocommerce_cart_link_fragment' ); 222 223 if ( ! function_exists( 'sydney_woocommerce_cart_link' ) ) { 224 /** 225 * Cart Link. 226 * 227 * Displayed a link to the cart including the number of items present and the cart total. 228 * 229 * @return void 230 */ 231 function sydney_woocommerce_cart_link() { 232 233 $link = '<a class="cart-contents" href="' . esc_url( wc_get_cart_url() ) . '" title="' . esc_attr__( 'View your shopping cart', 'sydney' ) . '">'; 234 $link .= '<span class="cart-count"><i class="sydney-svg-icon">' . sydney_get_svg_icon( 'icon-cart', false ) . '</i><span class="count-number">' . esc_html( WC()->cart->get_cart_contents_count() ) . '</span></span>'; 235 $link .= '</a>'; 236 237 return $link; 238 } 239 } 240 241 if ( ! function_exists( 'sydney_woocommerce_header_cart' ) ) { 242 /** 243 * Display Header Cart. 244 * 245 * @return void 246 */ 247 function sydney_woocommerce_header_cart() { 248 $show_cart = get_theme_mod( 'enable_header_cart', 1 ); 249 $show_account = get_theme_mod( 'enable_header_account', 1 ); 250 251 if ( is_cart() ) { 252 $class = 'current-menu-item'; 253 } else { 254 $class = ''; 255 } 256 ?> 257 258 <?php if ( $show_account ) : ?> 259 <?php echo '<a class="header-item wc-account-link" href="' . esc_url( get_permalink( get_option('woocommerce_myaccount_page_id') ) ) . '" title="' . esc_html__( 'Your account', 'sydney' ) . '"><i class="sydney-svg-icon">' . sydney_get_svg_icon( 'icon-user', false ) . '</i></a>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> 260 <?php endif; ?> 261 262 <?php if ( $show_cart ) : ?> 263 <div id="site-header-cart" class="site-header-cart header-item"> 264 <div class="<?php echo esc_attr( $class ); ?>"> 265 <?php echo sydney_woocommerce_cart_link(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> 266 </div> 267 <?php 268 $instance = array( 269 'title' => esc_html__( 'Your cart', 'sydney' ), 270 ); 271 272 the_widget( 'WC_Widget_Cart', $instance ); 273 ?> 274 </div> 275 <?php endif; ?> 276 <?php 277 } 278 }
Note: See TracChangeset
for help on using the changeset viewer.