Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)
  • in reply to: Issue with Version V3.2.0 #234557
    lellis690
    Member
    Post count: 8

    Thank you for the prompt confirmation.

    in reply to: Best Sellers #187400
    lellis690
    Member
    Post count: 8

    Yes, however I was going to start it on a new thread rather than confuse this one.

    It seems there may be a bug in the way Woocommerce displays the bestsellers.  I’ve contacted them for advice.

    lellis690
    Member
    Post count: 8
    This reply has been marked as private.
    lellis690
    Member
    Post count: 8
    This reply has been marked as private.
    lellis690
    Member
    Post count: 8
    This reply has been marked as private.
    lellis690
    Member
    Post count: 8

    As I said, I’m not very experienced in overriding functions. Do I need to add some extra code at the beginning?

    lellis690
    Member
    Post count: 8

    Hi – I’m clearly doing something wrong as I’m getting the same issue (I’m not that experienced in this type of thing). I’ve reproduced the entire functions.php I’m using below:

    <?php // Ensure visibility
    	            if ( ! $product->is_visible() )
    	            	return;
    
    	            if ( has_post_thumbnail() ) {
    	    			$image_title 		= esc_attr( get_the_title( get_post_thumbnail_id() ) );
    	    			$image_link  		= wp_get_attachment_url( get_post_thumbnail_id() );
    
    	    			$image = aq_resize( $image_link, 70, 91, true, false);
    
    	    			if ($image) {
    	    				$image_html = '<img itemprop="image" src="'.$image[0].'" width="'.$image[1].'" height="'.$image[2].'" alt="'.$image_title.'" />';
    	    			} else {
    	    				$image_html = '<img itemprop="image" src="'.$image_link.'" width="70" height="91" alt="'.$image_title.'" />';
    	    			}
    	           	}
    
    	           	if ( comments_open() ) {
    
    	           		$count = $wpdb->get_var("
    	           		    SELECT COUNT(meta_value) FROM $wpdb->commentmeta
    	           		    LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
    	           		    WHERE meta_key = 'rating'
    	           		    AND comment_post_ID = $post->ID
    	           		    AND comment_approved = '1'
    	           		    AND meta_value > 0
    	           		");
    
    	           		$rating = $wpdb->get_var("
    	           	        SELECT SUM(meta_value) FROM $wpdb->commentmeta
    	           	        LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
    	           	        WHERE meta_key = 'rating'
    	           	        AND comment_post_ID = $post->ID
    	           	        AND comment_approved = '1'
    	           	    ");
    
    	           	    if ( $count > 0 ) {
    
    	           	        $average = number_format($rating / $count, 2);
    	           	        $rating_output = '<div class="star-rating" title="'.sprintf(__('Rated %s out of 5', 'swiftframework'), $average).'" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"><span style="width:'.($average*16).'px"><span itemprop="ratingValue" class="rating">'.$average.'</span> '.__('out of 5', 'swiftframework').'</span></div>';
    
    	           	    }
    	           	}
    
    	            $product_output .= '<li class="clearfix" itemscope itemtype="http://schema.org/Product">';
    
    	           	if ($image) {
    		            $product_output .= '<figure>';
    		            $product_output .= '<a href="'.get_permalink($post->ID).'">';
    		            $product_output .= $image_html;
    		            $product_output .= '</a>';
    		            $product_output .= '</figure>';
    	            }
    	            $product_output .= '<div class="product-details">';
    	            $product_output .= '<h5 itemprop="name"><a href="'.get_permalink($post->ID).'">'.get_the_title().'</a></h5>';
    
    	       		if ($asset_type == "top-rated") {
    
    	       			$product_output .= $rating_output;
    
    	       		} else {
    
                		$size = sizeof( get_the_terms( $post->ID, 'product_cat' ) );
                		$product_output .= $product->get_categories( ', ', '<span class="product-cats">' . _n( '', '', $size, 'swiftframework' ) . ' ', '</span>' );
    
                	}
                	if (!$catalog_mode) {
    	            $product_output .= '<span class="price" itemprop="price">'.$product->get_price_html().'</span>';
    	            }
    	            $product_output .= '</div>';
    	            $product_output .= '</li>';
    
    	            $product_list_output .= $product_output;
    
    	       endwhile;
    
    	       wp_reset_query();
    	       wp_reset_postdata();
    	       remove_filter( 'posts_clauses',  array( $woocommerce->query, 'order_by_rating_post_clauses' ) );
    
    	       $product_list_output .= '</ul>';
    
    	       return $product_list_output;
    	    }
    
    	}
    
    	if ( ! function_exists( 'sf_product_items' ) ) {
    		function sf_product_items($asset_type, $category, $carousel, $product_size, $item_count, $width) {
    
    			global $woocommerce, $woocommerce_loop;
    
    			$args = array();
    
    			global $sidebars;
    			$columns = 4;
    
    			if ($sidebars == "no-sidebars") {
    				    if ($width == "3/4") {
    			   	    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 );
    			   	    $columns = 3;
    				    } else if ($width == "1/2") {
    			   	    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 2 );
    			   	    $columns = 2;
    			   	} else if ($width == "1/4") {
    			   	    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 1 );
    			   	    $columns = 1;
    				    } else {
    				    	if ($product_size == "mini") {
    				    		$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 6 );
    				    		$columns = 6;
    				    	} else {
    				    		$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );
    				    	}
    				    }
    			} else if ($sidebars == "one-sidebar") {
    				if ($width == "3/4") {
    				    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 );
    				    $columns = 3;
    				} else if ($width == "1/2") {
    				    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 2 );
    				    $columns = 2;
    				} else if ($width == "1/4") {
    				    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 1 );
    				    $columns = 1;
    				} else {
    					if ($product_size == "mini") {
    						$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );
    					} else {
    						$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 );
    						$columns = 3;
    					}
    				}
    			} else {
    				if ($width == "3/4") {
    				    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 2 );
    				    $columns = 2;
    				} else if ($width == "1/2") {
    				    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 1 );
    				    $columns = 1;
    				} else if ($width == "1/4") {
    				    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 1 );
    				    $columns = 1;
    				} else {
    					if ($product_size == "mini") {
    						$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 );
    						$columns = 3;
    					} else {
    						$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 2 );
    						$columns = 2;
    					}
    				}
    			}
    			?>

    Can you tell me what I’m missing?

    lellis690
    Member
    Post count: 8

    Thank you for such a speedy response!

    I’ve created a functions.php file, added the changes and uploaded to the child theme. The website then shows a blank page. Clearly I’m not adding enough code or what I have added is incorrect. The bit I want to change is:

    if ( ! $product->is_visible() )
    	            	return;
    
    	            if ( has_post_thumbnail() ) {
    	    			$image_title 		= esc_attr( get_the_title( get_post_thumbnail_id() ) );
    	    			$image_link  		= wp_get_attachment_url( get_post_thumbnail_id() );
    
    	    			$image = aq_resize( $image_link, 70, 91, true, false);
    
    	    			if ($image) {
    	    				$image_html = '<img itemprop="image" src="'.$image[0].'" width="'.$image[1].'" height="'.$image[2].'" alt="'.$image_title.'" />';
    	    			} else {
    	    				$image_html = '<img itemprop="image" src="'.$image_link.'" width="70" height="91" alt="'.$image_title.'" />';
    	    			}
    	           	}

    Can you tell me what I need to add to functions.php to do this?

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