Advertisement
danielmoore123

taxonomy-wpsc_product_category.php

Apr 26th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 23.21 KB | None | 0 0
  1. <?php
  2.     /**
  3.      * The template for displaying all pages.
  4.      *
  5.      * This is the template that displays all pages by default.
  6.      * Please note that this is the WordPress construct of pages
  7.      * and that other 'pages' on your WordPress site will use a
  8.      * different template.
  9.      *
  10.      * @package WordPress
  11.      * @subpackage Twenty_Ten
  12.      * @since Twenty Ten 1.0
  13.      */
  14.      
  15.     global $theme; get_header(); ?>
  16.     <div id="main">    
  17.                     <div id="container">
  18.                             <div id="content" role="main">
  19.      <h2 class="page-title"><?php printf( __( '<span>%s</span>', 'themater' ), single_cat_title( '', false ) ); ?></h2>
  20. <?php wpsc_output_breadcrumbs(); do_action( 'wpsc_top_of_products_page' ); ?>
  21.     <?php
  22.      
  23.     // This is the contents of my wpsc-products_page.php
  24.     // it successfully shows hierarchical product categories.
  25.      
  26.     if (!function_exists('MGget_shopping_cart_category')){
  27.       function MGget_shopping_cart_category($name) {
  28.         global $wpdb;
  29.         $result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms WHERE slug='$name'"));
  30.         if (!$result) return 122;
  31.         return $result;
  32.       }
  33.     }
  34.      
  35.     if (!function_exists('MGgetProductCategories')){
  36.     // Get Product Categories
  37.       function MGgetProductCategories() {
  38.         $output = array();
  39.         $query = "SELECT wp_terms.term_id, wp_terms.name, wp_terms.slug, wp_term_taxonomy.parent FROM wp_terms INNER JOIN wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id WHERE taxonomy='wpsc_product_category'";
  40.         $result = mysql_query($query);
  41.         if (!$result) die('Invalid query: ' . mysql_error());
  42.      
  43.         while ($row=mysql_fetch_array($result)) {
  44.           $output[$row['term_id']] = array('id'=>$row['term_id'], 'name'=>$row['name'], 'slug'=>$row['slug'], 'order'=>$row['term_order'], 'parent'=>$row['parent']);
  45.         }
  46.         return $output;
  47.       }
  48.     }
  49.      
  50.     global $wp_query;      
  51.     /*
  52.      * Most functions called in this page can be found in the wpsc_query.php file
  53.      */
  54.     ?>
  55.      
  56.      
  57.     <?php $we_have_shown_categories = FALSE;  // set true if we show some categores ?>
  58.      
  59.      
  60.     <div id="default_products_page_container" class="wrap wpsc_container">
  61.      
  62.            
  63.             <?php do_action('wpsc_top_of_products_page'); // Plugin hook for adding things to the top of the products page, like the live search ?>
  64.     <?php
  65.             $cur_term = $wp_query->query_vars['term'];
  66.             if ($cur_term) {
  67.               $cur_cat = MGget_shopping_cart_category($cur_term);
  68.             } else {
  69.               $cur_cat = wpsc_category_id(get_option('wpsc_default_category'));
  70.             }
  71.      
  72.             echo '<ul class="wpsc_categories">';
  73.      
  74.             $product_categories = MGgetProductCategories();
  75.                                     foreach ($product_categories as $pc) {
  76.                                             $pc_id = $pc['id'];
  77.                                             $pc_name = $pc['name'];
  78.                                             $pc_parent = $pc['parent'];
  79.      
  80.                                             $pc_link = get_term_link( (int)$pc_id , 'wpsc_product_category');
  81.                                             $pc_image = wpsc_get_categorymeta( $pc_id, 'image' );
  82.                                             $pc_image = WPSC_CATEGORY_URL . $pc_image;
  83.                                             $image_width = get_option('category_image_width');
  84.                                             $image_height = get_option('category_image_height');
  85.      
  86.      
  87.                                             if ($pc_parent==$cur_cat) { // only show top level categories
  88.                 $we_have_shown_categories = TRUE;
  89.             ?>
  90.               <li>
  91.                                               <a href="<?=$pc_link;?>" title="<?=$pc_name;?>">
  92.                    <?php echo $pc_name; ?>
  93.                 </a>
  94.                     <?php echo wpsc_display_products_page( array( 'category_id'=>$pc_id,'limit_of_items' => 100,'number_per_page' => 100 ) ); ?>
  95.                
  96.               </li>
  97.                             <?php
  98.                                             }
  99.                                     }
  100.             echo '</ul>';
  101.                             ?>
  102.  
  103.      
  104.     <?php if (!$we_have_shown_categories) { ?>
  105.      
  106.             <?php if(wpsc_display_products()): ?>
  107.                     <?php if(wpsc_has_pages_top()) { ?>
  108.                             <div class="wpsc_page_numbers_top">
  109.                                     <?php wpsc_pagination(); ?>
  110.                             </div>
  111.                     <?php } ?>
  112.                    
  113.            
  114.                     <div class="wpsc_default_product_list">
  115.                     <?php /** start the product loop here */?><?php echo the_title(); ?>
  116.                     <?php while (wpsc_have_products()) :  wpsc_the_product(); ?>
  117.                            
  118.           <div style="clear:both"></div>
  119.      
  120.                             <div class="default_product_display product_view_<?php echo wpsc_the_product_id(); ?> <?php echo wpsc_category_class(); ?> group">  
  121.                                     <h2 class="prodtitle entry-title">
  122.                                                             <?php if(get_option('hide_name_link') == 1) : ?>
  123.                                                                     <?php echo wpsc_the_product_title(); ?>
  124.                                                             <?php else: ?>
  125.                                                                     <a class="wpsc_product_title" href="<?php echo wpsc_the_product_permalink(); ?>"><?php echo wpsc_the_product_title(); ?></a>
  126.                                                             <?php endif; ?>
  127.                                                     </h2>  
  128.                                     <?php if(wpsc_show_thumbnails()) :?>
  129.                                             <div class="imagecol" id="imagecol_<?php echo wpsc_the_product_id(); ?>">
  130.                                                     <?php if(wpsc_the_product_thumbnail()) :
  131.                                                     ?>
  132.                                                             <a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo wpsc_the_product_image(); ?>">
  133.                                                                     <img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>"/>
  134.      
  135.                                                             </a>
  136.                                                     <?php else: ?>
  137.                                                                     <a href="<?php echo wpsc_the_product_permalink(); ?>">
  138.                                                                     <img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="No Image" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/noimage.png" width="<?php echo get_option('product_image_width'); ?>" height="<?php echo get_option('product_image_height'); ?>" />    
  139.                                                                     </a>
  140.                                                     <?php endif; ?>
  141.                                                     <?php
  142.                                                     if(gold_cart_display_gallery()) :                                      
  143.                                                             echo gold_shpcrt_display_gallery(wpsc_the_product_id(), true);
  144.                                                     endif;
  145.                                                     ?>    
  146.                                             </div><!--close imagecol-->
  147.                                     <?php endif; ?>
  148.                                             <div class="productcol">
  149.                                            
  150.                                                    
  151.                                                    
  152.                                                     <?php                                                  
  153.                                                             do_action('wpsc_product_before_description', wpsc_the_product_id(), $wp_query->post);
  154.                                                             do_action('wpsc_product_addons', wpsc_the_product_id());
  155.                                                     ?>
  156.                                                    
  157.                                                    
  158.                                                     <div class="wpsc_description">
  159.                                                             <?php echo do_shortcode(wpsc_the_product_description()); ?>
  160.                 </div><!--close wpsc_description-->
  161.                                    
  162.                                                     <?php if(wpsc_the_product_additional_description()) : ?>
  163.                                                     <div class="additional_description_container">
  164.                                                            
  165.                                                                     <img class="additional_description_button"  src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/icon_window_expand.gif" alt="Additional Description" />
  166.                     <a href="<?php echo wpsc_the_product_permalink(); ?>" class="additional_description_link">
  167.                       <?php _e('More Details', 'wpsc'); ?>
  168.                                                               </a>
  169.                                                             <div class="additional_description">
  170.                                                                     <p><?php echo do_shortcode(wpsc_the_product_additional_description()); ?></p>
  171.                                                             </div><!--close additional_description-->
  172.                                                     </div><!--close additional_description_container-->
  173.                                                     <?php endif; ?>
  174.                                                    
  175.                                                     <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
  176.                                                             <?php $action =  wpsc_product_external_link(wpsc_the_product_id()); ?>
  177.                                                     <?php else: ?>
  178.                                                     <?php $action = htmlentities(wpsc_this_page_url(), ENT_QUOTES, 'UTF-8' ); ?>                                  
  179.                                                     <?php endif; ?>
  180.                 <div style="clear:both"></div>
  181.                                                    
  182.                                                    
  183.                                                    
  184.                                             <?php // */ ?>
  185.                                     </div><!--close productcol-->
  186.             <div style="clear:both"></div>
  187.             <form class="product_form"  enctype="multipart/form-data" action="<?php echo $action; ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_<?php echo wpsc_the_product_id(); ?>" >
  188.                                                     <?php /** the variation group HTML and loop */?>
  189.                             <?php if (wpsc_have_variation_groups()) { ?>
  190.                             <fieldset><legend><?php _e('Product Options', 'wpsc'); ?></legend>
  191.                                                     <div class="wpsc_variation_forms">
  192.                                     <table>
  193.                                                             <?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
  194.                                                                     <tr><td class="col1"><label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label></td>
  195.                                                                     <?php /** the variation HTML and loop */?>
  196.                                                                     <td class="col2"><select class="wpsc_select_variation" name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>">
  197.                                                                     <?php while (wpsc_have_variations()) : wpsc_the_variation(); ?>
  198.                                                                             <option value="<?php echo wpsc_the_variation_id(); ?>" <?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option>
  199.                                                                     <?php endwhile; ?>
  200.                                                                     </select></td></tr>
  201.                                                             <?php endwhile; ?>
  202.                                 </table>
  203.                                                     </div><!--close wpsc_variation_forms-->
  204.                             </fieldset>
  205.                                                     <?php } ?>
  206.                                                     <?php /** the variation group HTML and loop ends here */?>
  207.      
  208.                                                             <!-- THIS IS THE QUANTITY OPTION MUST BE ENABLED FROM ADMIN SETTINGS -->
  209.                                                             <?php if(wpsc_has_multi_adding()): ?>
  210.                                     <fieldset><legend><?php _e('Quantity', 'wpsc'); ?></legend>
  211.                                                                     <div class="wpsc_quantity_update">
  212.                                     <?php /*<label for="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>"><?php _e('Quantity', 'wpsc'); ?>:</label>*/ ?>
  213.                                                                     <input type="text" id="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>" name="wpsc_quantity_update" size="2" value="1" />
  214.                                                                     <input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
  215.                                                                     <input type="hidden" name="wpsc_update_quantity" value="true" />
  216.                                     </div><!--close wpsc_quantity_update-->
  217.                                     </fieldset>
  218.                                                             <?php endif ;?>
  219.      
  220.                                                             <div class="wpsc_product_price">
  221.                                                                     <?php if( wpsc_show_stock_availability() ): ?>
  222.                                                                             <?php if(wpsc_product_has_stock()) : ?>
  223.                                                                                     <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="in_stock"><?php _e('Product in stock', 'wpsc'); ?></div>
  224.                                                                             <?php else: ?>
  225.                                                                                     <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="out_of_stock"><?php _e('Product not in stock', 'wpsc'); ?></div>
  226.                                                                             <?php endif; ?>
  227.                                                                     <?php endif; ?>
  228.                                                                     <?php if(wpsc_product_is_donation()) : ?>
  229.                                                                             <label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>: </label>
  230.                                                                             <input type="text" id="donation_price_<?php echo wpsc_the_product_id(); ?>" name="donation_price" value="<?php echo wpsc_calculate_price(wpsc_the_product_id()); ?>" size="6" />
  231.      
  232.                                                                     <?php else : ?>
  233.                                                                             <?php if(wpsc_product_on_special()) : ?>
  234.                                                                                     <p class="pricedisplay product_<?php echo wpsc_the_product_id(); ?>"><?php _e('Old Price', 'wpsc'); ?>: <span class="oldprice" id="old_product_price_<?php echo wpsc_the_product_id(); ?>"><?php echo wpsc_product_normal_price(); ?></span></p>
  235.                                                                             <?php endif; ?>
  236.                                                                             <p class="pricedisplay product_<?php echo wpsc_the_product_id(); ?>"><?php _e('Price', 'wpsc'); ?>: <span id='product_price_<?php echo wpsc_the_product_id(); ?>' class="currentprice pricedisplay"><?php echo wpsc_the_product_price(); ?></span></p>
  237.                                                                             <?php if(wpsc_product_on_special()) : ?>
  238.                                                                                     <p class="pricedisplay product_<?php echo wpsc_the_product_id(); ?>"><?php _e('You save', 'wpsc'); ?>: <span class="yousave" id="yousave_<?php echo wpsc_the_product_id(); ?>"><?php echo wpsc_currency_display(wpsc_you_save('type=amount'), array('html' => false)); ?>! (<?php echo wpsc_you_save(); ?>%)</span></p>
  239.                                                                             <?php endif; ?>
  240.      
  241.                                                                             <!-- multi currency code -->
  242.                                                                             <?php if(wpsc_product_has_multicurrency()) : ?>
  243.                                                     <?php echo wpsc_display_product_multicurrency(); ?>
  244.                                         <?php endif; ?>
  245.      
  246.                                                                             <?php if(wpsc_show_pnp()) : ?>
  247.                                                                                     <p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p>
  248.                                                                             <?php endif; ?>
  249.                                                                     <?php endif; ?>
  250.                                                             </div><!--close wpsc_product_price-->
  251.      
  252.                                                             <input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
  253.                                                             <input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
  254.      
  255.                                                             <!-- END OF QUANTITY OPTION -->
  256.                                                             <?php if((get_option('hide_addtocart_button') == 0) &&  (get_option('addtocart_or_buynow') !='1')) : ?>
  257.                                                                     <?php if(wpsc_product_has_stock()) : ?>
  258.                                                                             <div class="wpsc_buy_button_container">
  259.                                                                                     <div class="wpsc_loading_animation">
  260.                                                                                             <img title="Loading" alt="Loading" src="<?php echo wpsc_loading_animation_url(); ?>" />
  261.                                                                                             <?php _e('Updating cart...', 'wpsc'); ?>
  262.                                                                                     </div><!--close wpsc_loading_animation-->
  263.                                                                                             <?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
  264.                                                                                             <?php $action = wpsc_product_external_link( wpsc_the_product_id() ); ?>
  265.                                                                                             <input class="wpsc_buy_button" type="submit" value="<?php echo wpsc_product_external_link_text( wpsc_the_product_id(), __( 'Buy Now', 'wpsc' ) ); ?>" onclick="return gotoexternallink('<?php echo $action; ?>', '<?php echo wpsc_product_external_link_target( wpsc_the_product_id() ); ?>')">
  266.                                                                                             <?php else: ?>
  267.                                                                                     <input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
  268.                                                                                             <?php endif; ?></div></div>
  269.                                                                             </div><!--close wpsc_buy_button_container-->
  270.                                                                     <?php endif ; ?>
  271.                                                             <?php endif ; ?>
  272.                                                             <div class="entry-utility wpsc_product_utility">
  273.                                                                     <?php edit_post_link( __( 'Edit', 'wpsc' ), '<span class="edit-link">', '</span>' ); ?>
  274.                                                             </div>
  275.                                                     </form><!--close product_form-->
  276.      
  277.                                                     <?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow')=='1')) : ?>
  278.                                                             <?php echo wpsc_buy_now_button(wpsc_the_product_id()); ?>
  279.                                                     <?php endif ; ?>
  280.      
  281.                                                     <?php echo wpsc_product_rater(); ?>
  282.      
  283.                             <?php if(wpsc_product_on_special()) : ?><span class="sale"><?php _e('Sale', 'wpsc'); ?></span><?php endif; ?>
  284.           <div style="clear:both"></div>
  285.           </div><!--close default_product_display-->
  286.  
  287.                     <?php endwhile; ?>
  288.                     <?php /** end the product loop here */?>
  289.                     </div>
  290.                     <?php if(wpsc_product_count() == 0):?>
  291.                             <h3><?php  _e('There are no products in this group.', 'wpsc'); ?></h3>
  292.                     <?php endif ; ?>        
  293.                
  294.      
  295.  
  296.                    
  297.      <?php get_sidebar(); ?><?php endif; ?>
  298.  
  299.     <?php } ?>
  300.      
  301.            </div><!-- #content -->
  302.                     </div><!-- #container --></div></div></div></span></div>    
  303.     <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement