domenica 27 aprile 2014

WOOCOMMRCE PRODUCT CATEGORIES

show product categories 
 
<?php
    echo $product->get_categories(
        ', ',
        '<span class="posted_in">' . _n( 'Category:', 'Categories:',
        sizeof( get_the_terms( $post->ID, 'product_cat' ) ),
        'woocommerce' ) . ' ',
        '.</span>'
    );
?>
 
 
loop products in category 
 
<ul class="products">
    <?php
        $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'shoes', 'orderby' => 'rand' );
        $loop = new WP_Query( $args );
        while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>

            <h2>Shoes</h2>

                <li class="product">    

                    <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>">

                        <?php woocommerce_show_product_sale_flash( $post, $product ); ?>

                        <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="300px" height="300px" />'; ?>

                        <h3><?php the_title(); ?></h3>

                        <span class="price"><?php echo $product->get_price_html(); ?></span>                    

                    </a>

                    <?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>

                </li>

    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
</ul><!--/.products--> 
 
 
 
-------------------------------------------------- 
<?php
$args = array(
    'number'     => $number,
    'orderby'    => $orderby,
    'order'      => $order,
    'hide_empty' => $hide_empty,
    'include'    => $ids,
     'parent'    => 0
);
$product_categories = get_terms( 'product_cat', $args );
foreach( $product_categories as $cat ) {
echo '<li><a href="'. get_site_url().'/product-category/'. $cat->slug .'">'. $cat->name . '</a></li>';
}
?>
 --------------------------------------------------
 
get categories for a specific product given the id
global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
    $product_cat_id = $term->term_id;
    break;
} 

WOOCOMMERCE MOVE PRODUCT DESCRIPTION

add to functions.php

function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 20 );

sabato 26 aprile 2014

WOOCOMMERE REMOVE RELATED PRODUCTS FROM PRODUCT PAGE

add to functions.php

remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );

WOOCOMMERCE REMOVE PRODUCTS PAGINATION

add to functions.php

add_filter('loop_shop_per_page', create_function('$cols', 'return 100;'));

WORDPRESS TEMPLATE PAGE STANDARD FILE

    <?php
    /*
    Template Name: manifest

    */
    ?>

get_header(); ?>

    <div id="primary" class="site-content">
        <div id="content" role="main">

            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', 'page' ); ?>
                <?php comments_template( '', true ); ?>
            <?php endwhile; // end of the loop. ?>

        </div><!-- #content -->
    </div><!-- #primary -->

<?php dynamic_sidebar( 'manifest' ); ?>
<?php get_footer(); ?>

WORDPRESS ADD CUSTOM SIDEBAR

add to function.php

<?php
/**
 * Register our sidebars and widgetized areas.
 *
 */
function example_init() {

 register_sidebar( array(
  'name' => 'Custom Sidebar',
  'id' => 'custom-sidebar',
  'before_widget' => '<div>',
  'after_widget' => '</div>',
  'before_title' => '<h2 class="rounded">',
  'after_title' => '</h2>',
 ) );
}
add_action( 'widgets_init', 'example_init' );
?>
 
 
add to template page
 
 
<?php if ( is_active_sidebar( 'left-sidebar' ) ) : ?>
 <ul id="sidebar">
  <?php dynamic_sidebar( 'left-sidebar' ); ?>
 </ul>
<?php endif; ?>