Home Forums WoodMart – Premium Template Built-in list comparison functionality does not work!

Tagged: 

This topic contains 10 replies, has 4 voices, and was last updated by Elise Noromit Elise Noromit 5 months, 1 week ago.

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

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

    Private Content Hidden
    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
    Navigator1974
    Customer

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

    Private Content Hidden
    #101455
    Navigator1974
    Navigator1974
    Customer

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

    #101466

    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
    Navigator1974
    Customer

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

    #101494

    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
    Navigator1974
    Customer

    I give you the data FTP

    Private Content Hidden
    #101525

    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
    Navigator1974
    Customer

    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

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

You must be logged in to reply to this topic.