Home Forums WoodMart support forum Built-in list comparison functionality does not work!

Built-in list comparison functionality does not work!

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #101438

    Navigator1974
    Participant

    I can not find the reason for the empty lists of the comparison page, help who can!

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

    Hello,

    Please refer to this article and make sure you have configured everything https://xtemos.com/docs/woodmart/faq-guides/set-compare-wishlist-pages/

    If you have configured everything but the problem still exists, please provide your site admin access for checking.

    Best Regards

    #101454

    Navigator1974
    Participant

    I know it and did it for a long time, I am ready to provide access

    #101455

    Navigator1974
    Participant

    I have made a complete translation of your theme into Russian, I am ready to give it to you!

    #101466

    Eric Watson
    Participant

    Hello,

    Could you please disable all plugins that are not related to our theme and check the problem again?

    Thank you in advance

    #101468

    Navigator1974
    Participant

    Now everything is turned off, but I did it before, it still does not work!

    #101494

    Artem Temos
    Keymaster

    In this situation are you able to provide us your FTP access so we could troubleshoot it and provide you with a solution?

    Best Regards

    #101519

    Navigator1974
    Participant

    I give you the data FTP

    #101525

    Eric Watson
    Participant

    Hello,

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

    	function woodmart_get_compared_products_data() {
    		$ids = woodmart_get_compared_products();
    
    		if ( empty( $ids ) ) {
    			return array();
    		}
    
    		$args = array(
    			'include' => $ids,
    		);
    
    		$products = array();
    
    		foreach ( $ids as $id ) {
    			$products[] = wc_get_product( $id );
    		}
    
    		$products_data = array();
    
    		$fields = woodmart_get_compare_fields();
    
    		$fields = array_filter( $fields, function(  $field ) {
    			return 'pa_' === substr( $field, 0, 3 );
    		}, ARRAY_FILTER_USE_KEY );
    
    		$divider = '-';
    
    		foreach ( $products as $product ) {
    			$rating_count = $product->get_rating_count();
    			$average = $product->get_average_rating();
    
    			$products_data[ $product->get_id() ] = array(
    				'basic' => array(
    					'title' => $product->get_title() ? $product->get_title() : $divider,
    					'image' => $product->get_image() ? $product->get_image() : $divider,
    					'rating' => wc_get_rating_html( $average, $rating_count ),
    					'price' => $product->get_price_html() ? $product->get_price_html() : $divider,
    					'add_to_cart' => woodmart_compare_add_to_cart_html( $product ) ? woodmart_compare_add_to_cart_html( $product ) :$divider,
    				),
    				'id' => $product->get_id(),
    				'image_id' => $product->get_image_id(),
    				'permalink' => $product->get_permalink(),
    				'dimensions' => wc_format_dimensions( $product->get_dimensions( false ) ),
    				'description' => $product->get_short_description() ? $product->get_short_description() : $divider,
    				'weight' => $product->get_weight() ? $product->get_weight() : $divider,
    				'sku' => $product->get_sku() ? $product->get_sku() : $divider,
    				'availability' => woodmart_compare_availability_html( $product ),
    			);
    
    			foreach ( $fields as $field_id => $field_name ) {
    				if ( taxonomy_exists( $field_id ) ) {
    					$products_data[ $product->get_id() ][ $field_id ] = array();
    					$terms = get_the_terms( $product->get_id(), $field_id );
    					if ( ! empty( $terms ) ) {
    						foreach ( $terms as $term ) {
    							$term = sanitize_term( $term, $field_id );
    							$products_data[ $product->get_id() ][ $field_id ][] = $term->name;
    						}
    					} else {
    						$products_data[ $product->get_id() ][ $field_id ][] = '-';
    					}
    					$products_data[ $product->get_id() ][ $field_id ] = implode( ', ', $products_data[ $product->get_id() ][ $field_id ] );
    				}
    			}
    		}
    
    		return $products_data;
    	}

    Kind Regards
    XTemos Studio

    #101539

    Navigator1974
    Participant

    Solution with inserting code into functions.php of a child theme – Works !!
    Is this a normal way out – inserting code into child functions.php? What is the cause of my problem?

    #101564

    Hello,

    There was the problem in the functions which gets the products for further output in compare code which we have provided. This is just an alternative way so everything would work.

    Best Regards

Tagged: 

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