array(
'default_rows' => 12,
'min_rows' => 1,
'max_rows' => 24,
'default_columns' => 3,
'min_columns' => 1,
'max_columns' => 6,
) ) );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
}
add_action( 'after_setup_theme', 'dfu_busacc_fn_wc_setup' );
/**
* WooCommerce specific scripts & stylesheets.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_wc_scripts' ) ) {
function dfu_busacc_fn_wc_scripts() {
wp_enqueue_style( 'dfuba-wc-style', get_template_directory_uri() . '/inc/css/theme-wcstyle.min.css', array( 'dfuba-theme-style' ), wp_get_theme()->get( 'Version' ), 'all' );
}
}
add_action( 'wp_enqueue_scripts', 'dfu_busacc_fn_wc_scripts' );
if ( ! function_exists( 'dfu_busacc_fn_wc_widgets_init' ) ) {
function dfu_busacc_fn_wc_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'WooCommerce before shop (WC top bar)', 'dfu-busacc' ),
'id' => 'dba-wc-b4-content-sidebar',
'description' => esc_html__( 'Add widgets here.', 'dfu-busacc' ),
'before_widget' => '',
'before_title' => '
is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '
';
}
return $html;
}
}
add_filter( 'woocommerce_loop_add_to_cart_link', 'dfu_busacc_fn_wc_qty_inputs', 10, 2 );
}
/**
* Cart Fragments.
* Ensure cart contents update when products are added to the cart via AJAX.
*
* @param array $fragments Fragments to refresh via AJAX.
* @return array Fragments to refresh via AJAX.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_wc_cart_link_fragment' ) ) {
function dfu_busacc_fn_wc_cart_link_fragment( $fragments ) {
$iconbgcolor = dfu_busacc_fn_footer_iconbg();
ob_start();
dfu_busacc_fn_wc_cart_link();
$fragments['a.dba-wc-cart'] = ob_get_clean();
ob_start();
dfu_busacc_fn_wc_cart_btm_link( $iconbgcolor );
$fragments['a.dba-wc-cart-btm'] = ob_get_clean();
return $fragments;
}
}
add_filter( 'woocommerce_add_to_cart_fragments', 'dfu_busacc_fn_wc_cart_link_fragment' );
/**
* Cart Link.
* Displayed a link to the cart including the number of items present and the cart total.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_wc_cart_link' ) ) {
function dfu_busacc_fn_wc_cart_link() {
/* translators: 1: number of cart item, 2: number of cart item */
$cart_cnt_txt = sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'dfu-busacc' ), WC()->cart->get_cart_contents_count(), 'dfu-busacc' );
if ( class_exists( 'Mega_Menu' ) && max_mega_menu_is_enabled( 'main-menu' ) ) {
$menustyle = 'mega-menu-link';
} else {
$menustyle = 'nav-link';
}
?>
cart->get_cart_contents_count() ); ?>
theme_location == 'main-menu' ) {
ob_start();
echo wp_kses_post( $items );
$showcart = get_theme_mod( 'dba_wc_cart_on_menu' );
if ( $showcart && true == $showcart ) {
if ( class_exists( 'Mega_Menu' ) && max_mega_menu_is_enabled( 'main-menu' ) ) {
$menu_theme = mmm_get_theme_for_location( 'main-menu' );
$megamenu_breakpoint = $menu_theme['responsive_breakpoint'];
if ( empty( $megamenu_breakpoint ) ) {
$megamenu_breakpoint = '600px';
}
echo '';
echo '';
}
return ob_get_clean();
} else {
return $items;
}
}
}
add_filter( 'wp_nav_menu_items', 'dfu_busacc_fn_add_cart_on_nav', 10, 2 );
/**
* Single product details styles
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_wc_prod_accordion' ) && ( 'accordion' == get_theme_mod( 'dba_wc_sglprod_det_style', 'accordion' ) ) ) {
function dfu_busacc_fn_wc_prod_accordion( $tabs ) {
?>
' . esc_html( $saletext ) . '';
return $html;
}
}
add_filter( 'woocommerce_sale_flash', 'dfu_busacc_fn_wc_shop_sale_badge', 10, 3 );
/**
* Show additional hover image from first image in product image gallery in product listings
*******************************************************************************************************************************************/
$dfu_busacc_addhoverimg = get_theme_mod( 'dba_wc_add_hover_img', false );
if ( $dfu_busacc_addhoverimg ) {
add_action( 'woocommerce_shop_loop_item_title', 'dfu_busacc_fn_wc_add_hover_img', 15);
if ( ! function_exists( 'dfu_busacc_fn_wc_add_hover_img' ) ) {
function dfu_busacc_fn_wc_add_hover_img() {
global $product;
$imgids = $product->get_gallery_image_ids();
if ( $imgids && $product->get_image_id() ) {
// has product gallery
echo '
' . wp_get_attachment_image( $imgids[0], 'woocommerce_thumbnail' ) . '
';
}
}
}
}
/**
* Product display - original/grid/list view
*******************************************************************************************************************************************/
$dfu_busacc_prodview = get_theme_mod( 'dba_wc_prod_view', 'original' );
if ( 'original' !== $dfu_busacc_prodview ) {
add_action( 'woocommerce_before_shop_loop', 'dfu_busacc_fn_wc_product_columns_wrapper', 15 );
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open');
add_action( 'woocommerce_before_shop_loop_item', 'dfu_busacc_fn_product_wrap_start', 9 );
add_action( 'woocommerce_before_shop_loop_item_title', 'dfu_busacc_fn_product_image_start', 0 );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_open',5);
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_close',10);
add_action( 'woocommerce_before_shop_loop_item_title', 'dfu_busacc_fn_product_image_end', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'dfu_busacc_fn_product_content_start', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', 11);
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 0 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 5);
add_action( 'woocommerce_after_shop_loop_item_title', 'dfu_busacc_fn_add_product_info', 8 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'dfu_busacc_fn_product_content_end', 20 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'dfu_busacc_fn_product_wrap_end', 11 );
add_action( 'woocommerce_after_shop_loop', 'dfu_busacc_fn_wc_product_columns_wrapper_close', 15 );
}
/**
* Product columns wrapper open - woocommerce_before_shop_loop
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_wc_product_columns_wrapper' ) ) {
function dfu_busacc_fn_wc_product_columns_wrapper() {
$prodview = get_theme_mod( 'dba_wc_prod_view', 'original' );
if ( $prodview == 'grid' ) {
echo '
';
} elseif ( $prodview == 'list' ) {
echo '
';
}
}
}
/**
* Product columns wrapper close - woocommerce_after_shop_loop
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_wc_product_columns_wrapper_close' ) ) {
function dfu_busacc_fn_wc_product_columns_wrapper_close() {
echo '
';
}
}
/**
* Product wrap start.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_product_wrap_start' ) ) {
function dfu_busacc_fn_product_wrap_start() {
echo '
';
}
}
/**
* Product wrap close.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_product_wrap_end' ) ) {
function dfu_busacc_fn_product_wrap_end(){
echo '
';
}
}
/**
* Product image wrap start.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_product_image_start' ) ) {
function dfu_busacc_fn_product_image_start() {
echo '
';
}
}
/**
* Product image wrap close.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_product_image_end' ) ) {
function dfu_busacc_fn_product_image_end() {
echo '
';
}
}
/**
* Product content start.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_product_content_start' ) ) {
function dfu_busacc_fn_product_content_start() {
echo '
';
}
}
/**
* Product content close.
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_product_content_end' ) ) {
function dfu_busacc_fn_product_content_end() {
echo '
';
}
}
/**
* Product info
*******************************************************************************************************************************************/
if ( ! function_exists( 'dfu_busacc_fn_add_product_info' ) ) {
function dfu_busacc_fn_add_product_info(){
?>