theme_location ) { $nav_cart = wc_get_template_html( 'bs4-mini-cart.php' ); } if ( 'top' === $args->theme_location && ! has_nav_menu( 'top_secondary' ) ) { $nav_cart = wc_get_template_html( 'bs4-mini-cart.php' ); } } return $items . $nav_cart; } add_filter( 'wp_nav_menu_items', 'bs4_wc_display_top_nav_cart_menu_item', 10, 2 ); /** * Add image size to WordPress. Used for WooCommerce shopping cart product images. */ add_image_size( '50x50', 50, 50, true ); /** * Filters product categories list to make compatible with Bootstrap 4 badges. * * @param array $links List of terms to display. */ function bs4_wc_product_term_product_cat( $links ) { return bs4_wc_term_link_badge_html( $links, 'product_cat' ); } add_filter( 'term_links-product_cat', 'bs4_wc_product_term_product_cat' ); /** * Filters product tags list to make compatible with Bootstrap 4 badges. * * @param array $links List of terms to display. */ function bs4_wc_product_term_product_tag( $links ) { return bs4_wc_term_link_badge_html( $links, 'product_tag' ); } add_filter( 'term_links-product_tag', 'bs4_wc_product_term_product_tag' ); /** * Output HTML for WooCommerce taxonomy term link. * * @param array $html List of terms to display. * @param string $taxonomy Taxonomy name. */ function bs4_wc_term_link_badge_html( $html, $taxonomy ) { $badge_class = get_theme_mod( "wc_{$taxonomy}_badge_color", 'primary' ); $classes = ''; if ( $badge_class ) { $badge_class = 'bg-' . sanitize_html_class( $badge_class ); $classes = join( ' ', bs4_get_badge_class( $badge_class ) ); } $html = str_replace( ' rel="tag"', ' class="' . esc_attr( $classes ) . '" rel="tag"', $html ); return $html; } /** * Open wrapper for WooCommerce product list widget. */ function bs4_wc_before_widget_product_list() { return '
'; } add_filter( 'woocommerce_after_widget_product_list', 'bs4_wc_after_widget_product_list' ); /** * When product is on sale then show Bootstrap badge component. * * @param string $sales_flash Sales flash HTML for products. */ function bs4_wc_sale_flash( $sales_flash ) { $badge_class = get_theme_mod( 'wc_sales_badge_color', 'primary' ); $classes = ''; if ( $badge_class && 'none' !== $badge_class ) { $badge_class = 'bg-' . sanitize_html_class( $badge_class ); $classes = join( ' ', bs4_get_badge_class( $badge_class ) ); } // Replace current sales badge class with added classes. $sales_flash = str_replace( 'class="onsale"', 'class="onsale ' . esc_attr( $classes ) . '"', $sales_flash ); return $sales_flash; } add_filter( 'woocommerce_sale_flash', 'bs4_wc_sale_flash' ); /** * Make single product variation select fields Bootstrap friendly. * * @param array $args Select field arguments. */ function bs4_wc_dropdown_variation_attribute_options_args( $args ) { $args['class'] = 'form-control form-control-sm'; return $args; } add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'bs4_wc_dropdown_variation_attribute_options_args' ); /** * Make single product variation select field reset link Bootstrap friendly. * * @param array $html Reset variations link HTML. */ function bs4_wc_reset_variations_link( $html ) { $html = str_replace( 'class="reset_variations"', 'class="reset_variations form-text small"', $html ); return $html; } add_filter( 'woocommerce_reset_variations_link', 'bs4_wc_reset_variations_link' ); /** * Make WooCommerce breadcrumbs Bootstrap 4 friendly. * * @link https://docs.woocommerce.com/document/customise-the-woocommerce-breadcrumb/ * * @param array $args Breadcrumb with new args. */ function bs4_filter_default_wc_breadcrumbs( $args ) { // Set new breadcrumb settings. $args = array( 'delimiter' => ' ', 'wrap_before' => '', 'before' => '