• Resolved OniX777

    (@onix777)


    I need to display on the main page of the store only parent category of goods, and this I did, I comment output code sub-categories in the template.

    Now the problem is that – when you switch to any category of goods, I need to show only its sub categories, parent no. And so with all levels of sub categories, how to realize it?
    I understand this code

    <?php wpsc_start_category_query(array('category_group'=> 1, 'show_thumbnails'=> 1)); ?>
    <a href="<?php wpsc_print_category_url();?>"  title="<?php wpsc_print_category_name();?>">
    <?php wpsc_print_category_image(); ?>
    </a>
    wpsc_print_category_name();?>
    <?php wpsc_end_category_query(); ?>

    show categories. How to find a sub category of the current category to which the user is located and bring them out.
    What functions to use it, and how a paste it to this code?

    Sorry for my English, thanks.

    https://www.ads-software.com/extend/plugins/wp-e-commerce/

Viewing 9 replies - 1 through 9 (of 9 total)
  • u have to use wp_list_categories function for getting this.
    try this function u get result

    https://codex.www.ads-software.com/Template_Tags/wp_list_categories

    Thread Starter OniX777

    (@onix777)

    How it is used in the sub categories of products? I still need to display the picture for these sub categories… I don’t know a lot of php in order to understand it ??
    As I understood wp_list_categories displays a list of categories of posts, but not goods.

    u can print product category also in that wp_list_categories.

    and once u get the category name u get id of that category and using that u get the category image that u add.

    Thread Starter OniX777

    (@onix777)

    I have done differently:

    <?php
                $category_id = wpsc_category_id();
                $getsubs = "SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = 'wpsc_product_category' AND parent = '".$category_id."'";
                $subcats = mysql_query($getsubs);
                $num_subcats = mysql_num_rows($subcats); 
    
                while ($row = mysql_fetch_row($subcats)) {
                  foreach ($row as $subcat)
                    $catname = wpsc_category_name($subcat);
                    $catimage = wpsc_category_image($subcat);
                    $catlink = get_term_link((int)$subcat, 'wpsc_product_category');
                    if ($category_id >= 0 || $category_id != '') { ?>
    
                      <div class="wpsc_category_grid_item">
                                  <a href="<?php echo $catlink; ?>"  title="<?php echo $catname; ?>">
                                         <img src="<?php echo $catimage;  ?>" />
    	              </a>
    	            <?php echo $catname;?>
                      </div>
    
                <?php }  ?>

    it works ??
    mukesh panchal, thanks u too

    Where do you make these changes? (In what file?)

    Thread Starter OniX777

    (@onix777)

    wpsc-grid_view

    Hi OnlX777 – this is exactly what I’ve been looking to do. WP e-Commerce is really strange when it comes to category->sub cat->products!

    The code you have placed in this thread – did you replace all the code in wpsc-grid_view with that or just a portion? Could you possibly elaborate on how you got this working?

    Thanks

    Thread Starter OniX777

    (@onix777)

    Good time. Last posted code replaces only the code in the first post, not the entire file code wpsc-grid_view.

    Another thing I noticed in the work of such oddities – known files e-commerce partially transferred to the theme directory, but sometimes the changes you make to these files will not be displayed, and then I noticed that some of the work is referring to the same file, but from the category of plug-in.
    What is that and did not understand, so has harmonized the files to each other.

    Good luck in the coding ??

    Hey Guys,

    I’ve got a similar issue, I’ve customised my code quite a bit and I’m struggling to work out where to add your code…

    My code is:

    <?php
    global $wp_query;
    $image_width = get_option('product_image_width');
    $image_height = get_option('product_image_height');
    $cat = $_GET['type'];
    ?>
    <div id="grid_view_products_page_container">
    <?php wpsc_output_breadcrumbs(); ?>
    	<?php do_action('wpsc_top_of_products_page'); // Plugin hook for adding things to the top of the products page, like the live search ?>
    	<?php if(wpsc_display_products()): ?>
    
    		<?php if(wpsc_is_in_category()) : ?>
    
    			<div class="wpsc_category_details">
    				<?php if(get_option('wpsc_category_description') &&  wpsc_category_description()) : ?>
    					<?php echo nl2br(wpsc_category_description()); ?>
    				<?php endif; ?>
    			</div><!--close wpsc_category_details-->
    		<?php endif; ?>
    
    	<div class="product_grid_display group">
    		<?php while (wpsc_have_products()) :  wpsc_the_product(); ?>
    			<div class="product_grid_item product_view_<?php echo wpsc_the_product_id(); ?>">
    	<!--sold item code-->
    	<?php if (wpsc_category_id() == 30 ): ?>
    			<h2 class="prodtitle"><?php echo ucwords(wpsc_the_product_title()); ?></h2>
    			<div class="item_image">
    			<img style="width:<?php echo get_option('product_image_width'); ?>px;height:<?php echo get_option('product_image_height'); ?>px" class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>" />
    			</div>
    
    			<a href="JavaScript: popjack()" title="Make enquiry about <?php echo wpsc_the_product_title(); ?>" alt="Make enquiry about <?php echo wpsc_the_product_title(); ?>" ><img src="https://craftsbysteve.com/wp-content/uploads/2012/07/enquire.png" style="margin-top:10px;"></a>
    	</div>
    			<?php elseif (wpsc_category_id() != 30 ): ?>
    <!--TESTING CODE-->
    					<div class="item_image">
    						<a href="<?php echo wpsc_the_product_permalink(); ?>">
    						<img style="width:<?php echo get_option('product_image_width'); ?>px;height:<?php echo get_option('product_image_height'); ?>px" class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>" />
    						</a>
    					</div>
    
    				<div class="grid_product_info">
    							<h2 class="prodtitle"><a href="<?php echo wpsc_the_product_permalink(); ?>" title="<?php echo wpsc_the_product_title(); ?>"><?php echo ucwords(wpsc_the_product_title()); ?></a></h2>
    
    					<div class="price_container" style="width: 55px; float: left;">
    					<p class="pricedisplay <?php echo wpsc_the_product_id(); ?>">
    
    				<?php if(wpsc_product_on_special()) : ?>
    					<span class="sale"><?php echo wpsc_product_normal_price(); ?></span>
    				<?php endif; ?>
    
    					<span id='product_price_<?php echo wpsc_the_product_id(); ?>' class="currentprice pricedisplay"><?php echo wpsc_the_product_price(); ?></span></p>
    					</div><!--close price_container-->
    
                        <div class="more_details" style="height: 24px;"><a href="<?php echo wpsc_the_product_permalink(); ?>" class="more_details">More Details</a>
                        </div><!--close more_details-->
    
    					<div class="buy_now_button">
    						<form class="product_form"  enctype="multipart/form-data" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_<?php echo wpsc_the_product_id(); ?>" >
    							<?php do_action ( 'wpsc_product_form_fields_begin' ); ?>
    							<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
    							<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
    
    							<?php if((get_option('display_addtocart') == 1) && (get_option('addtocart_or_buynow') !='1')) :?>
    								<?php if(wpsc_product_has_stock()) : ?>
    									<input type="submit" value="<?php _e('Add To Basket', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
    								<?php else : ?>
    									<p class="soldout"><?php _e('Sorry, sold out!', 'wpsc'); ?></p>
    								<?php endif ; ?>
    
                    </div><!--close grid_product_info-->
    
    <!--TESTING END-->
    
                                				<div class="wpsc_loading_animation">
    											<img title="Loading" alt="Loading" src="<?php echo wpsc_loading_animation_url(); ?>" />
    											<?php _e('Updating cart...', 'wpsc'); ?>
    										</div><!--close wpsc_loading_animation-->
    						<?php do_action ( 'wpsc_product_form_fields_end' ); ?>
                        </form></div>                    
    
    				<?php endif; ?>
    			</div><!--close product_grid_item--><?php endif; ?>
    			<?php if((get_option('grid_number_per_row') > 0) && ((($wp_query->current_post +1) % get_option('grid_number_per_row')) == 0)) :?>
    			  <div class="grid_view_clearboth"></div>
    			<?php endif ; ?>
    
    			<!--close sold item code-->
    
    		<?php endwhile; ?>
    
    		<?php if(wpsc_product_count() == 0):?>
    			<p><?php  _e('There are no products in this group.', 'wpsc'); ?></p>
    		<?php endif ; ?>
    
    		</div>
    	</div><!--close product_grid_display-->
    		<?php if((wpsc_has_pages_bottom()) && (is_page() != 16)) : ?>
    			<div class="wpsc_page_numbers_bottom group">
    				<?php wpsc_pagination(); ?>
    			</div><!--close wpsc_page_numbers_bottom-->
    		<?php endif; ?>
    		<?php endif; ?>
        <?php do_action( 'wpsc_theme_footer' ); ?> 	
    
    </div><!--close grid_view_products_page_container-->

    Any ideas where I need to add the code?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to show only sub categories on the parent category page?’ is closed to new replies.