• Resolved ravihumint

    (@ravihumint)


    Hello Everybody! I am trying to make this plugin work on site running on Flatsome theme. I’ve checked everywhere, but I am somehow not able to get any help at all. Following is how my archive-product.php code looks like:

    <?php
    /**
     * The Template for displaying product archives, including the main shop page which is a post type archive.
     *
     * Override this template by copying it to yourtheme/woocommerce/archive-product.php
     *
     * @author 		WooThemes
     * @package 	WooCommerce/Templates
     * @version     2.0.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    
    get_header( 'shop' );
    
    // Add Custom Shop Content if set
    if(is_shop() && flatsome_option('html_shop_page_content') && $wp_query->query_vars['paged'] < 1){
       	echo do_shortcode('<div class="shop-page-content">'.flatsome_option('html_shop_page_content').'</div>');
    } else{
    	wc_get_template_part( 'layouts/category', flatsome_option('category_sidebar'));
    }
    
    get_footer( 'shop' );
    
    ?>

    I’ve realised, this is probably not the file, I am looking for, thus I found one more file by the name “category.php”. And the code inside looks like following:

    <div class="row category-page-row">
    
    		<div class="col large-3 hide-for-medium <?php flatsome_sidebar_classes(); ?>">
    			<div id="shop-sidebar" class="sidebar-inner col-inner">
    				<?php
    				  if(is_active_sidebar('shop-sidebar')) {
    				  		dynamic_sidebar('shop-sidebar');
    				  	} else{ echo '<p>You need to assign Widgets to <strong>"Shop Sidebar"</strong> in <a href="'.get_site_url().'/wp-admin/widgets.php">Appearance > Widgets</a> to show anything here</p>';
    				  }
    				?>
    			</div><!-- .sidebar-inner -->
    		</div><!-- #shop-sidebar -->
    
    		<div class="col large-9">
    		<?php
    			/**
    			 * woocommerce_before_main_content hook
    			 *
    			 * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
    			 * @hooked woocommerce_breadcrumb - 20
    			 */
    			do_action( 'woocommerce_before_main_content' );
    		?>
    
    		<?php do_action( 'woocommerce_archive_description' ); ?>
    
    		<?php if ( have_posts() ) : ?>
    
    			<?php
    				do_action( 'woocommerce_before_shop_loop' );
    			?>
    
    			<?php woocommerce_product_loop_start(); ?>
    
    				<?php woocommerce_product_subcategories(); ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php wc_get_template_part( 'content', 'product' ); ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    			<?php woocommerce_product_loop_end(); ?>
    
    			<?php
    				/**
    				 * woocommerce_after_shop_loop hook
    				 *
    				 * @hooked woocommerce_pagination - 10
    				 */
    				do_action( 'woocommerce_after_shop_loop' );
    			?>
    
    		<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>
    
    			<?php wc_get_template( 'loop/no-products-found.php' ); ?>
    
    		<?php endif; ?>
    
    		<?php
    		 	do_action('flatsome_products_after');
    			/**
    			 * woocommerce_after_main_content hook
    			 *
    			 * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
    			 */
    			do_action( 'woocommerce_after_main_content' );
    		?>
    
    		</div>
    </div>

    Can somebody, kindly please hand-hold me, as to what and where exactly do I need to add the Ajax Load More Shortcode? By the way, if at all it helps, then this is the page where I am trying to make changes: https://www.wethechic.com/product-tag/game-of-thrones/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @ravihumint,
    Ive never used Flatsome so Im not sure which template is the actual product archive template.

    Can you start by determining which template is used on https://www.wethechic.com/product-tag/game-of-thrones/ and then I can help you more?

    Cheers,

    Thread Starter ravihumint

    (@ravihumint)

    As I pasted above. I think category.php is the file/code which is driving this link: https://www.wethechic.com/product-tag/game-of-thrones/. If that’s not really the case, then I am completely lost here ??

    • This reply was modified 6 years, 10 months ago by ravihumint.
    Plugin Author Darren Cooney

    (@dcooney)

    Ok, if thats the case then you would replace the following code with your Ajax Load More shortcode:

    
    <?php while ( have_posts() ) : the_post(); ?>
       <?php wc_get_template_part( 'content', 'product' ); ?>
    <?php endwhile; // end of the loop. ?>

    Ajax Load More will take care of your loop.

    • This reply was modified 6 years, 10 months ago by Darren Cooney.
    Plugin Author Darren Cooney

    (@dcooney)

    Also, not sure you seen but there is a blog post on this.
    https://connekthq.com/woocommerce-infinite-scrolling/#edit-woocommerce-templates

    Hope that helps if you havent seen it.

    Thread Starter ravihumint

    (@ravihumint)

    The only remaining file that I think might be the real product archive file in flatsome theme is following; please help me and let me know if this indeed the one we are looking for? The name of the file is content-product_cat.php, and following is it’s content:

    <?php
    /**
     * The template for displaying product category thumbnails within loops
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/content-product_cat.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see     https://docs.woothemes.com/document/template-structure/
     * @author  WooThemes
     * @package WooCommerce/Templates
     * @version 2.6.1
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    
    $cat_style = flatsome_option('cat_style');
    $color = '';
    $text_pos = '';
    
    if($cat_style == 'overlay' || $cat_style == 'shade'){
    	$color = 'dark';
    }
    if($cat_style == 'overlay'){
    	$text_pos = 'box-text-middle text-shadow-5';
    }
    if($cat_style == 'badge'){
    	$text_pos .= ' hover-dark';
    }
    
    $classes = array('product-category','col');
    
    ?>
    <div <?php wc_product_cat_class( $classes, $category ); ?>>
    <div class="col-inner">
    	<?php do_action( 'woocommerce_before_subcategory', $category ); ?>
    
    		<div class="box box-<?php echo $cat_style; ?>  <?php echo $text_pos;?> <?php echo $color; ?>">
    		<div class="box-image">
    			<?php
    				/**
    				 * woocommerce_before_subcategory_title hook
    				 *
    				 * @hooked woocommerce_subcategory_thumbnail - 10
    				 */
    				do_action( 'woocommerce_before_subcategory_title', $category );
    			?>
    			<?php if($cat_style == 'overlay'){ ?><div class="overlay"></div><?php } ?>
    			<?php if($cat_style == 'shade'){ ?><div class="shade"></div><?php } ?>
    		</div><!-- box-image -->
    		<div class="box-text text-center">
    			<div class="box-text-inner">
    					<h5 class="uppercase header-title">
    	       					<?php echo $category->name; ?>
    					</h5>
    					<p class="is-xsmall uppercase count">
    						<?php if ( $category->count > 0 ) echo apply_filters( 'woocommerce_subcategory_count_html', ' ' . $category->count . ' '.__('Products','woocommerce').'', $category); ?>
    					</p>
    					<?php
    						/**
    						 * woocommerce_after_subcategory_title hook
    						 */
    						do_action( 'woocommerce_after_subcategory_title', $category );
    					?>
    
    			</div><!-- .box-text-inner -->
    		</div><!-- .box-text -->
    		</div>
    
    	<?php do_action( 'woocommerce_after_subcategory', $category ); ?>
    </div>
    </div>
    Plugin Author Darren Cooney

    (@dcooney)

    THis looks correct.
    Copy and paste that into your Repeater Template and see if it works.

    Thread Starter ravihumint

    (@ravihumint)

    Alright! I replaced the code as you suggested with the following code:

    <?php
        $obj = get_queried_object();
        $taxonomy = $obj->taxonomy;
        $taxonomy_term = $obj->slug;
        echo do_shortcode('[ajax_load_more post_type="product" taxonomy="'. $taxonomy .'" taxonomy_terms="'. $taxonomy_term .'" taxonomy_operator="IN" css_classes="products" repeater="default"]');
    ?>

    I also copied the contents of “content-product_cat.php” file to the “default.php” file inside repeater folder. But now none of the products are visible on any of the pages. Please check – https://www.wethechic.com/product-tag/big-bang-theory/

    Thread Starter ravihumint

    (@ravihumint)

    By the way, I am really sorry. I am probably asking for a lot. But you see I am not too familiar with PHP, thus finding these things a bit challenging. And again not really patronising but I really found your plugin quite sleek and sophisticated, thus would love to have this working on this site.

    Plugin Author Darren Cooney

    (@dcooney)

    There is a 500 error. Sorry, i’m not sure if that is the correct template or not.

    It looks like this template replies on some variables that might not be available with Ajax Load More.

    For example, $category, <?php do_action( 'woocommerce_before_subcategory', $category ); ?>

    If you want me to investigate, please open a support ticket and provide login details so I can help more efficiently.
    https://connekthq.com/plugins/ajax-load-more/support/

    Plugin Author Darren Cooney

    (@dcooney)

    By the way, I am really sorry. I am probably asking for a lot. But you see I am not too familiar with PHP, thus finding these things a bit challenging. And again not really patronising but I really found your plugin quite sleek and sophisticated, thus would love to have this working on this site.

    Yea, no worries at all. It is difficult to get this going with Woo. I understand that. Happy to help over email.

    Cheers,

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to make it work with Flatsome theme’ is closed to new replies.