/ Published in: PHP
Various WooCommerce theme customizations. See comments in code.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Ensure cart contents update when products are added to the cart via AJAX, in "$0.00" format add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' ); function woocommerce_header_add_to_cart_fragment( $fragments ) { ob_start(); ?> <a class="cart-contents" href="<?php echo WC()->cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a> <?php return $fragments; } // ADD BRAND CUSTOM FIELD TO SINGLE PRODUCT SUMMARY add_action( 'woocommerce_single_product_summary', 'add_custom_field', 7 ); add_action( 'woocommerce_after_shop_loop_item_title', 'add_custom_field', 40 ); function add_custom_field() { global $post; echo "<div class='artist'>"; echo get_post_meta( $post->ID, 'Collaborative Artist', true ); echo "</div>"; return true; } // Change root breadcrumb link add_filter( 'woocommerce_breadcrumb_defaults', 'jk_change_breadcrumb_home_text' ); function jk_change_breadcrumb_home_text( $defaults ) { // Change the breadcrumb home text from 'Home' to 'Shop' $defaults['home'] = 'Shop'; return $defaults; } add_filter( 'woocommerce_breadcrumb_home_url', 'woo_custom_breadrumb_home_url' ); function woo_custom_breadrumb_home_url() { return '/shop'; }