Advertisement
Guest User

taxonomy-wpsc_product_category.php

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