Home Forums WoodMart support forum Automatic scrolling of marks

Automatic scrolling of marks

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #140807

    Th3k
    Participant

    Automatic scrolling of brands does not work

    #140826

    Eric Watson
    Participant

    Hi,

    Please, describe to us your problems in a bit more details. Attach some screenshots and provide us with a list of steps on how to reproduce it on your website.

    Thank you in advance.

    #140832

    Th3k
    Participant

    Hi, I would like the carousel to scroll automatically, but it is still and yet the automatic setting is there …

    Attachments:
    You must be logged in to view attached files.
    #140845

    Eric Watson
    Participant

    Hello,

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    function woodmart_shortcode_brands( $atts, $content = '' ) {
    		$item_class = $items_wrap_class = $owl_atts = '';
    		$parsed_atts = shortcode_atts( array_merge( woodmart_get_owl_atts(), array(
    			'title' => '',
    			'username' => 'flickr',
    			'number' => 20,
    			'hover' => 'default',
    			'target' => '_self',
    			'link' => '',
    			'ids' => '',
    			'style' => 'carousel',
    			'brand_style' => 'default',
    			'per_row' => 3,
    			'columns' => 3,
    			'orderby' => '',
    			'order' => 'ASC',
    			'scroll_carousel_init' => 'no',
    		) ), $atts );
    
    		extract( $parsed_atts );
    
    		$carousel_id = 'brands_' . rand(1000,9999);
    
    		$attribute = woodmart_get_opt( 'brands_attribute' );
    
    		if( empty( $attribute ) || ! taxonomy_exists( $attribute ) ) return '<div class="not-brand-selected">' . esc_html__( 'You must select your brand attribute in Theme Settings -> Shop -> Brands', 'woodmart' ) . '</div>';
    
    		ob_start();
    
    		$class = 'brands-widget slider-' . $carousel_id;
    
    		if( $style != '' ) {
    			$class .= ' brands-' . $style;
    		}
    
    		$class .= ' brands-hover-' . $hover;
    		$class .= ' brands-style-' . $brand_style;
    
    		if ( $style == 'carousel' ) {
    			$custom_sizes = apply_filters( 'woodmart_brands_shortcode_custom_sizes', false );
    
    			$parsed_atts['autoplay'] = 'yes';
    			$parsed_atts['wrap'] = $wrap;
    			$parsed_atts['scroll_per_page'] = 'yes';
    			$parsed_atts['carousel_id'] = $carousel_id;
    			$parsed_atts['slides_per_view'] = $per_row;
    			$parsed_atts['custom_sizes'] = $custom_sizes;
    			$owl_atts = woodmart_get_owl_attributes( $parsed_atts );
    
    			$items_wrap_class .= ' owl-carousel ' . woodmart_owl_items_per_slide( $per_row, array(), false, false, $custom_sizes );
    			$class .= ' woodmart-carousel-container';
    			$class .= ' woodmart-carousel-spacing-0';
    
    			if ( $scroll_carousel_init == 'yes' ) {
    				$class .= ' scroll-init';
    			}
    
    			if ( woodmart_get_opt( 'disable_owl_mobile_devices' ) ) {
    				$class .= ' disable-owl-mobile';
    			}
    		} else {
    			$items_wrap_class .= ' row';
    			$items_wrap_class .= ' woodmart-spacing-0';
    			$item_class .= woodmart_get_grid_el_class( 0, $columns );
    		}
    
    		echo '<div id="'. esc_attr( $carousel_id ) . '" class="brands-items-wrapper ' . esc_attr( $class ) . '" ' . $owl_atts . '>';
    
    		if(!empty($title)) { echo '<h3 class="title">' . $title . '</h3>'; };
    
    		$args = array(
    			'taxonomy' => $attribute,
    			'hide_empty' => false,
    			'order' => $order,
    			'number' => $number
    		);
    
    		if ( $orderby ) $args['orderby'] = $orderby;
    
    		if ( $orderby == 'random' ) {
    			$args['orderby'] = 'id';
    			$brand_count = wp_count_terms( $attribute, array(
    				'hide_empty' => 0
    			) );
    
    			$offset = rand( 0, $brand_count - $number );
    			if ( $offset <= 0 ) {
    				$offset = '';
    			}
    			$args['offset'] = $offset;
    		}
    
    		if( ! empty( $ids ) ) {
    			$args['include'] = explode(',', $ids);
    		}
    
    		$brands = get_terms( $args );
    		$taxonomy = get_taxonomy( $attribute );
    
    		if ( $orderby == 'random' ) shuffle( $brands );
    
    		if ( woodmart_is_shop_on_front() ) {
    			$link = home_url();
    		} else {
    			$link = get_post_type_archive_link( 'product' );
    		}
    		
    		echo '<div class="' . esc_attr( $items_wrap_class )  . '">';
    
     		if( ! is_wp_error( $brands ) && count( $brands ) > 0 ) {
    			foreach ($brands as $key => $brand) {
    				$image = get_term_meta( $brand->term_id, 'image', true );
    
    				$filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $attribute ) );
    
    				if ( is_object( $taxonomy ) && $taxonomy->public ) {
    					$attr_link = get_term_link( $brand->term_id, $brand->taxonomy );
    				} else {
    					$attr_link = add_query_arg( $filter_name, $brand->slug, $link );
    				}
    
    				echo '<div class="brand-item' . esc_attr( $item_class )  . '">';
    					echo '<a href="' . esc_url( $attr_link ) . '">';
    					if( $style == 'list' || empty( $image ) ) {
    						echo '<span class="brand-title-wrap">' . $brand->name . '</span>';
    					} else {
    						echo apply_filters( 'woodmart_image', '<img src="' . esc_url( $image ) . '" title="' . esc_attr( $brand->name ) . '" alt="' . esc_attr( $brand->name ) . '" />' );
    					}
    					echo '</a>';
    				echo '</div>';
    			}
    		}
    
    		echo '</div></div>';
    
    		$output = ob_get_contents();
    		ob_end_clean();
    
    		return $output;
    
    	}

    Kind Regards
    XTemos Studio

    #140861

    Th3k
    Participant

    It’s work, realy Thx!

    #140877

    Eric Watson
    Participant

    You are welcome!

Viewing 6 posts - 1 through 6 (of 6 total)