Forum Replies Created

Viewing 14 replies - 16 through 29 (of 29 total)
  • Thread Starter adsim

    (@adsim)

    Hi Shadi, the web store is based in Germany.

    Thread Starter adsim

    (@adsim)

    You are right. The marketplace is missing in the settings.
    Seems it got lost as my client changed his amazon credentials in the settings.

    Anyway.

    Problem resolved.

    Thanks.

    Thread Starter adsim

    (@adsim)

    And which quotation marks should it be?

    But … what does that have to do with the search field? If I use the search field I normally don’t have a shortcode yet, or am I wrong?

    Thread Starter adsim

    (@adsim)

    No, in the moment I can’t show you an example URL. Sorry.
    Hm, ruling out the theme is tricky I think, because the things I want (list products AND subcategories,but not products from subcategories) are only possible via changes in the theme.

    Thread Starter adsim

    (@adsim)

    Maybe it’s the code in my template file.
    My archive-product.php looks like this:

    <?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' );
    global $wp_query; $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']);
    ?>
    
    	<?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 	
    
    			$cat_slug = get_queried_object()->slug;
    		    $args = array(
    				//'number'     => $number,
    				//'orderby'    => $orderby,
    				//'order'      => $order,
    				'parent'     => 0
    				//'hide_empty' => $hide_empty
    				//'include'    => $ids
    			);
    
    			global $my_product_categories;
    			$my_product_categories = get_terms( 'product_cat', $args );
    			$product_categories_listitems = '';
    			if ( ! empty( $my_product_categories ) && ! is_wp_error( $my_product_categories ) ) {
    				$count = count( $my_product_categories );
    				$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
    				$product_categories_list = '<ul class="product-categories">';
    				$allactive = false;
    				foreach ( $my_product_categories as $product_category ) {
                        if($cat_slug == $product_category->slug){
    					  $active = ' class="active"';
    					  $allactive = true;
    					}else{
    					  $active = '';
    					}
    					$product_categories_listitems .= '<li><a '.$active.' href="' . get_term_link( $product_category ) . '" title="' . sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $product_category->name ) . '">' . $product_category->name . '</a></li>';
    				}
    				if(!$allactive){
    				  $shopactive = ' class="active"';
    				}else{
    				  $shopactive = '';
    				}
    				echo $product_categories_list.'<li><a '.$shopactive.' href="'.$shop_page_url.'">Alle</a></li>'.$product_categories_listitems.'</ul>';
    
    			}
    		?>
    
    		<?php
    			/**
    			 * woocommerce_archive_description hook
    			 *
    			 * @hooked woocommerce_taxonomy_archive_description - 10
    			 * @hooked woocommerce_product_archive_description - 10
    			 */
    			do_action( 'woocommerce_archive_description' );
    		?>
    
    		<?php 	if(is_product_category()) : ?>			
    
    		<?php if ( have_posts() ) : ?>
    
    			<?php
    				/**
    				 * woocommerce_before_shop_loop hook
    				 *
    				 * @hooked woocommerce_result_count - 20
    				 * @hooked woocommerce_catalog_ordering - 30
    				 */
    				do_action( 'woocommerce_before_shop_loop' );
    			?>
    
    			<?php woocommerce_product_loop_start(); ?>
    
    				<?php woocommerce_product_subcategories(array('force_display' => true)); ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    				<?php $terms = wp_get_post_terms(get_the_ID(), $wp_query->query_vars['taxonomy']);
    				if ($terms[0]->term_id == $term->term_id): ?>
    					<?php wc_get_template_part( 'content', 'product' ); ?>
    
    				<?php endif; 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 else : ?>
    
    		<?php if ( have_posts() ) : ?>
    
    			<?php
    				/**
    				 * woocommerce_before_shop_loop hook
    				 *
    				 * @hooked woocommerce_result_count - 20
    				 * @hooked woocommerce_catalog_ordering - 30
    				 */
    				do_action( 'woocommerce_before_shop_loop' );
    			?>
    
    			<?php woocommerce_product_loop_start(); ?>
    
    				<?php
                    //var_dump($product_categories);
    			   $catID = array();
    			   foreach ( $my_product_categories as $product_category ) {
    				   array_push($catID, $product_category->slug);
    				}
    				woocommerce_product_subsubcategories(array('force_display' => true)); ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    				<?php if(has_term( $catID, 'product_cat' ) ) : ?>
    					<?php wc_get_template_part( 'content', 'product' ); ?>
    				<?php endif; 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 endif; ?>
    
    	<?php
    		/**
    		 * woocommerce_after_main_content hook
    		 *
    		 * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
    		 */
    		do_action( 'woocommerce_after_main_content' );
    	?>
    
    	<?php
    		/**
    		 * woocommerce_sidebar hook
    		 *
    		 * @hooked woocommerce_get_sidebar - 10
    		 */
    		do_action( 'woocommerce_sidebar' );
    	?>
    
    <?php get_footer( 'shop' ); ?>

    and the function woocommerce_product_subcategories looks like this:

    function woocommerce_product_subsubcategories( $args = array() ) {
        global $wp_query;
    	global $my_product_categories;	
    
    	//print_r($my_product_categories);
    
    	$defaults = array(
          'before'        => '',
          'after'         => '',
          'force_display' => false
        );
    
        $args = wp_parse_args( $args, $defaults );
    
        extract( $args );
    
        // Main query only
        if ( ! is_main_query() && ! $force_display ) {
          return;
        }
    
        // Don't show when filtering, searching or when on page > 1 and ensure we're on a product archive
        if ( is_search() || is_filtered() || is_paged() || ( ! is_product_category() && ! is_shop() ) ) {
          return;
        }
    
        // Check categories are enabled
        if ( is_shop() && get_option( 'woocommerce_shop_page_display' ) == '' ) {
          return;
        }
    
        // Find the category + category parent, if applicable
        $term       = get_queried_object();
        $parent_id     = empty( $term->term_id ) ? 0 : $term->term_id;
    
        if ( is_product_category() ) {
          $display_type = get_woocommerce_term_meta( $term->term_id, 'display_type', true );
    
          switch ( $display_type ) {
            case 'products' :
              return;
            break;
            case '' :
              if ( get_option( 'woocommerce_category_archive_display' ) == '' ) {
                return;
              }
            break;
          }
        }
    
        // NOTE: using child_of instead of parent - this is not ideal but due to a WP bug ( http://core.trac.wordpress.org/ticket/15626 ) pad_counts won't work
        $product_categories = get_categories( apply_filters( 'woocommerce_product_subcategories_args', array(
          'parent'       => $parent_id,
          'menu_order'   => 'ASC',
          'hide_empty'   => 0,
          'hierarchical' => 1,
          'taxonomy'     => 'product_cat',
          'pad_counts'   => 1
        ) ) );
    	//var_dump($product_categories);
    	$child_cats = array();
    	foreach($my_product_categories as $cat){
    		$my_cats = get_categories(
    			array( 'parent' => $cat->term_id,
    				  'menu_order'   => 'ASC',
    				  'hide_empty'   => 0,
    				  'hierarchical' => 1,
    				  'taxonomy'     => 'product_cat',
    				  'pad_counts'   => 1
    			));
    		array_push($child_cats, $my_cats);
    	}
    
        if ( ! apply_filters( 'woocommerce_product_subcategories_hide_empty', false ) ) {
          $product_categories = wp_list_filter( $product_categories, array( 'count' => 0 ), 'NOT' );
        }
    
        if ( $product_categories ) {
          echo $before;
    
    	 foreach($child_cats as $single_cat){
          foreach ( $single_cat as $category ) {
            wc_get_template( 'content-product_cat.php', array(
              'category' => $category
            ) );
          }
    	 }
    
          // If we are hiding products disable the loop and pagination
          if ( is_product_category() ) {
            $display_type = get_woocommerce_term_meta( $term->term_id, 'display_type', true );
    
            switch ( $display_type ) {
              case 'subcategories' :
                $wp_query->post_count    = 0;
                $wp_query->max_num_pages = 0;
              break;
              case '' :
                if ( get_option( 'woocommerce_category_archive_display' ) == 'subcategories' ) {
                  $wp_query->post_count    = 0;
                  $wp_query->max_num_pages = 0;
                }
              break;
            }
          }
    
          if ( is_shop() && get_option( 'woocommerce_shop_page_display' ) == 'subcategories' ) {
            $wp_query->post_count    = 0;
            $wp_query->max_num_pages = 0;
          }
    
          echo $after;
    
          return true;
        }
      }

    Thread Starter adsim

    (@adsim)

    Yes, all subcats are displayed before the products.
    But the pagination makes strange things. It shows 8 pages with products, but after page 1 (which contains 8 products instead of 12 … and 2 subcats) the pages 2 to 5 are empty, page 6 contains one product and pages 7 and 8 are complete.
    I don’t know why.

    Thread Starter adsim

    (@adsim)

    Hi Nico,

    yes the suggested solution works, but it means to change core files from the Event Calendar plugin. So I have to change it again and again after each update.
    And yes the problem remains if I use a default WordPress theme. With a default theme I lose all my custom post types, but one can see the unwanted language parameter on event posts.
    It adds an ?lang=de which it shouldn’t (because I use the directory option as language indicator instead of the language parameter AND because German is the default language – so there shouldn’t be a language indicator in urls for german posts and pages at all AND because I deactivated translations for custom post types at all – only pages and “normal” posts should be translated).

    Best wishes
    Sven

    Thread Starter adsim

    (@adsim)

    PHP Version 5.6.7-1, FastCGI, Memcache … doesn’t work
    PHP Version 5.6.4-4ubuntu6.4, Apache 2.0 Handler, Memcache … doesn’t work
    PHP Version 5.3.10-1ubuntu3.21, FastCGI … works

    Don’t know what else could be important.

    Thread Starter adsim

    (@adsim)

    No, it’s not with the same host. Complete different environment, complete different providers.
    Ok. I tried a third environment (a server I run by myself) and it works. So it seems something is here right what’s wrong at the two others. But what is it that’s wrong?
    Hm.
    The error message remains the same as I wrote above.
    Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /var/www/testboks.com/html/tausendsassa/wp-content/plugins/insta-grabagram/admin/class-insta-grab-admin.php on line 309
    I updated all three to the latest version 1.1.8.
    All others plugins are deactivated and I use a default theme.

    Thread Starter adsim

    (@adsim)

    Yep, with theme twentyfifteen and no other plugin activated.
    Same error message.
    I also tried another WP installation on another server (with other PHP version and so on).
    Same error message.
    WP version is 4.4.2

    Thread Starter adsim

    (@adsim)

    Ok, I caught the culprit.
    The Product Gallery Slider seems to change the hook.
    https://www.woothemes.com/products/product-gallery-slider/
    If I deactivate it everything is “normal”, means the item_title hook is used.

    Very strange.

    Thanks for your help.
    Let’s see how I could use the strange behaviour. 😉

    Thread Starter adsim

    (@adsim)

    That’s strange.
    Hm.
    Ok. Thanks.

    So I have to look if another plugin causes this weird behaviour.
    It’s not my theme, because the problem remains if I change to a default theme.

    Thread Starter adsim

    (@adsim)

    I know that the template contains both hooks, but only one hook outputs the thumbnail (and which one depends on which loop is used … see my writing above)
    Hm.
    So you mean that’s not how it should be?

    Thread Starter adsim

    (@adsim)

    Yes, I know. But both loops use INSIDE of content-product.php different hooks to output the product thumbnail.
    I don’t know why.
    If archive-products.php uses content-product.php the woocommerce_before_shop_loop_item hook is used and if related.php uses the content-product.php the woocommerce_before_shop_loop_item_title hook is used.
    And so the output is different (woocommerce_before_shop_loop_item wraps an extra anchor around the thumbnail and places it BEFORE the other anchor with the headline, price and so on … that’s the output I want to have … woocommerce_before_shop_loop_item_title wraps no extra anchor around the thumbnail and places it INSIDE the anchor with the headline, price and so on).

    And my question is if there is a way to change this behaviour.

Viewing 14 replies - 16 through 29 (of 29 total)