<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
global $theme; get_header(); ?>
<div id="main">
<div id="container">
<div id="content" role="main">
<h2 class="page-title"><?php printf( __( '<span>%s</span>', 'themater' ), single_cat_title( '', false ) ); ?></h2>
<?php wpsc_output_breadcrumbs(); do_action( 'wpsc_top_of_products_page' ); ?>
<?php
// This is the contents of my wpsc-products_page.php
// it successfully shows hierarchical product categories.
if (!function_exists('MGget_shopping_cart_category')){
function MGget_shopping_cart_category($name) {
global $wpdb;
$result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms WHERE slug='$name'"));
if (!$result) return 122;
return $result;
}
}
if (!function_exists('MGgetProductCategories')){
// Get Product Categories
function MGgetProductCategories() {
$output = array();
$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'";
$result = mysql_query($query);
if (!$result) die('Invalid query: ' . mysql_error());
while ($row=mysql_fetch_array($result)) {
$output[$row['term_id']] = array('id'=>$row['term_id'], 'name'=>$row['name'], 'slug'=>$row['slug'], 'order'=>$row['term_order'], 'parent'=>$row['parent']);
}
return $output;
}
}
global $wp_query;
/*
* Most functions called in this page can be found in the wpsc_query.php file
*/
?>
<?php $we_have_shown_categories = FALSE; // set true if we show some categores ?>
<div id="default_products_page_container" class="wrap wpsc_container">
<?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
$cur_term = $wp_query->query_vars['term'];
if ($cur_term) {
$cur_cat = MGget_shopping_cart_category($cur_term);
} else {
$cur_cat = wpsc_category_id(get_option('wpsc_default_category'));
}
echo '<ul class="wpsc_categories">';
$product_categories = MGgetProductCategories();
foreach ($product_categories as $pc) {
$pc_id = $pc['id'];
$pc_name = $pc['name'];
$pc_parent = $pc['parent'];
$pc_link = get_term_link( (int)$pc_id , 'wpsc_product_category');
$pc_image = wpsc_get_categorymeta( $pc_id, 'image' );
$pc_image = WPSC_CATEGORY_URL . $pc_image;
$image_width = get_option('category_image_width');
$image_height = get_option('category_image_height');
if ($pc_parent==$cur_cat) { // only show top level categories
$we_have_shown_categories = TRUE;
?>
<li>
<a href="<?=$pc_link;?>" title="<?=$pc_name;?>">
<?php echo $pc_name; ?>
</a>
<?php echo wpsc_display_products_page( array( 'category_id'=>$pc_id,'limit_of_items' => 100,'number_per_page' => 100 ) ); ?>
</li>
<?php
}
}
echo '</ul>';
?>
<?php if (!$we_have_shown_categories) { ?>
<?php if(wpsc_display_products()): ?>
<?php if(wpsc_has_pages_top()) { ?>
<div class="wpsc_page_numbers_top">
<?php wpsc_pagination(); ?>
</div>
<?php } ?>
<div class="wpsc_default_product_list">
<?php /** start the product loop here */?><?php echo the_title(); ?>
<?php while (wpsc_have_products()) : wpsc_the_product(); ?>
<div style="clear:both"></div>
<div class="default_product_display product_view_<?php echo wpsc_the_product_id(); ?> <?php echo wpsc_category_class(); ?> group">
<h2 class="prodtitle entry-title">
<?php if(get_option('hide_name_link') == 1) : ?>
<?php echo wpsc_the_product_title(); ?>
<?php else: ?>
<a class="wpsc_product_title" href="<?php echo wpsc_the_product_permalink(); ?>"><?php echo wpsc_the_product_title(); ?></a>
<?php endif; ?>
</h2>
<?php if(wpsc_show_thumbnails()) :?>
<div class="imagecol" id="imagecol_<?php echo wpsc_the_product_id(); ?>">
<?php if(wpsc_the_product_thumbnail()) :
?>
<a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo wpsc_the_product_image(); ?>">
<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(); ?>"/>
</a>
<?php else: ?>
<a href="<?php echo wpsc_the_product_permalink(); ?>">
<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'); ?>" />
</a>
<?php endif; ?>
<?php
if(gold_cart_display_gallery()) :
echo gold_shpcrt_display_gallery(wpsc_the_product_id(), true);
endif;
?>
</div><!--close imagecol-->
<?php endif; ?>
<div class="productcol">
<?php
do_action('wpsc_product_before_description', wpsc_the_product_id(), $wp_query->post);
do_action('wpsc_product_addons', wpsc_the_product_id());
?>
<div class="wpsc_description">
<?php echo do_shortcode(wpsc_the_product_description()); ?>
</div><!--close wpsc_description-->
<?php if(wpsc_the_product_additional_description()) : ?>
<div class="additional_description_container">
<img class="additional_description_button" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/icon_window_expand.gif" alt="Additional Description" />
<a href="<?php echo wpsc_the_product_permalink(); ?>" class="additional_description_link">
<?php _e('More Details', 'wpsc'); ?>
</a>
<div class="additional_description">
<p><?php echo do_shortcode(wpsc_the_product_additional_description()); ?></p>
</div><!--close additional_description-->
</div><!--close additional_description_container-->
<?php endif; ?>
<?php if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
<?php $action = wpsc_product_external_link(wpsc_the_product_id()); ?>
<?php else: ?>
<?php $action = htmlentities(wpsc_this_page_url(), ENT_QUOTES, 'UTF-8' ); ?>
<?php endif; ?>
<div style="clear:both"></div>
<?php // */ ?>
</div><!--close productcol-->
<div style="clear:both"></div>
<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(); ?>" >
<?php /** the variation group HTML and loop */?>
<?php if (wpsc_have_variation_groups()) { ?>
<fieldset><legend><?php _e('Product Options', 'wpsc'); ?></legend>
<div class="wpsc_variation_forms">
<table>
<?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
<tr><td class="col1"><label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label></td>
<?php /** the variation HTML and loop */?>
<td class="col2"><select class="wpsc_select_variation" name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>">
<?php while (wpsc_have_variations()) : wpsc_the_variation(); ?>
<option value="<?php echo wpsc_the_variation_id(); ?>" <?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option>
<?php endwhile; ?>
</select></td></tr>
<?php endwhile; ?>
</table>
</div><!--close wpsc_variation_forms-->
</fieldset>
<?php } ?>
<?php /** the variation group HTML and loop ends here */?>
<!-- THIS IS THE QUANTITY OPTION MUST BE ENABLED FROM ADMIN SETTINGS -->
<?php if(wpsc_has_multi_adding()): ?>
<fieldset><legend><?php _e('Quantity', 'wpsc'); ?></legend>
<div class="wpsc_quantity_update">
<?php /*<label for="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>"><?php _e('Quantity', 'wpsc'); ?>:</label>*/ ?>
<input type="text" id="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>" name="wpsc_quantity_update" size="2" value="1" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
<input type="hidden" name="wpsc_update_quantity" value="true" />
</div><!--close wpsc_quantity_update-->
</fieldset>
<?php endif ;?>
<div class="wpsc_product_price">
<?php if( wpsc_show_stock_availability() ): ?>
<?php if(wpsc_product_has_stock()) : ?>
<div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="in_stock"><?php _e('Product in stock', 'wpsc'); ?></div>
<?php else: ?>
<div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="out_of_stock"><?php _e('Product not in stock', 'wpsc'); ?></div>
<?php endif; ?>
<?php endif; ?>
<?php if(wpsc_product_is_donation()) : ?>
<label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>: </label>
<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" />
<?php else : ?>
<?php if(wpsc_product_on_special()) : ?>
<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>
<?php endif; ?>
<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>
<?php if(wpsc_product_on_special()) : ?>
<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>
<?php endif; ?>
<!-- multi currency code -->
<?php if(wpsc_product_has_multicurrency()) : ?>
<?php echo wpsc_display_product_multicurrency(); ?>
<?php endif; ?>
<?php if(wpsc_show_pnp()) : ?>
<p class="pricedisplay"><?php _e('Shipping', 'wpsc'); ?>:<span class="pp_price"><?php echo wpsc_product_postage_and_packaging(); ?></span></p>
<?php endif; ?>
<?php endif; ?>
</div><!--close wpsc_product_price-->
<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
<!-- END OF QUANTITY OPTION -->
<?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow') !='1')) : ?>
<?php if(wpsc_product_has_stock()) : ?>
<div class="wpsc_buy_button_container">
<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 if(wpsc_product_external_link(wpsc_the_product_id()) != '') : ?>
<?php $action = wpsc_product_external_link( wpsc_the_product_id() ); ?>
<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() ); ?>')">
<?php else: ?>
<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"/>
<?php endif; ?></div></div>
</div><!--close wpsc_buy_button_container-->
<?php endif ; ?>
<?php endif ; ?>
<div class="entry-utility wpsc_product_utility">
<?php edit_post_link( __( 'Edit', 'wpsc' ), '<span class="edit-link">', '</span>' ); ?>
</div>
</form><!--close product_form-->
<?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow')=='1')) : ?>
<?php echo wpsc_buy_now_button(wpsc_the_product_id()); ?>
<?php endif ; ?>
<?php echo wpsc_product_rater(); ?>
<?php if(wpsc_product_on_special()) : ?><span class="sale"><?php _e('Sale', 'wpsc'); ?></span><?php endif; ?>
<div style="clear:both"></div>
</div><!--close default_product_display-->
<?php endwhile; ?>
<?php /** end the product loop here */?>
</div>
<?php if(wpsc_product_count() == 0):?>
<h3><?php _e('There are no products in this group.', 'wpsc'); ?></h3>
<?php endif ; ?>
<?php get_sidebar(); ?><?php endif; ?>
<?php } ?>
</div><!-- #content -->
</div><!-- #container --></div></div></div></span></div>
<?php get_footer(); ?>