-
webbrewersParticipant
For ecommerce sites, I used to add a custom query to the home page to generate a loop of products that included thumbnail and add to cart button. Enlightenment makes it very easy to add the “loop” but the query only has the title and description. Where can I find the template file/function so I can add the thumbnail and cart button if it’s a product archive?
I’d rather use the awesome features built into the theme than go “old school” and add my own query………..- This topic was modified 9 years, 12 months ago by webbrewers.
Daniel TaraKeymasterFull support for WooCommerce plugin is planned for a future version. Until then you only have the option to go old-school. You need to remove some hooks as explained in this tutorial and create a child theme with the plugin’s template files.
webbrewersParticipantThanks, I already did that part to make the woo pages compatible but when using the product post type in a widget custom query, only the title and description are pulled in. What I’d like to show also are the thumbnail, price and add to cart button. In other words, to make it look like a woo category/archive page.
What I add in other themes is the following but I’d prefer to utilize the custom query option in Enlightenment, if possible. I just don’t see where to alter the query:`<ul class=”products”>
<?php
$args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘posts_per_page’ => 5, ‘meta_key’ => ‘_featured’, ‘meta_value’ => ‘yes’ );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?><li class=”product type-product status-publish featured”>
<a id=”id-<?php the_id(); ?>” href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”>
<h3><?php the_title(); ?></h3>
<div class=”prod-top”></div>
<?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=”65px” height=”115px” />’; ?>
<br /><span class=”price”><?php echo $product->get_price_html(); ?></span>
</a>
<br />
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
</li><!– /span3 –>
<?php endwhile; ?>
<?php wp_reset_query(); ?></ul>`
Daniel TaraKeymasterThere’s no need for a custom query, in Enlightenment or any other theme. Did you add the required template files? You don’t need to add the line
add_theme_support( 'woocommerce' );
otherwise I don’t see any reason why the template files wouldn’t work.webbrewersParticipantBy “custom query” I mean the theme’s custom query widget. In short, I want to display a selection of woo products on the home page.
I added a theme custom query widget to the “home main” sidebar location.
Settings:
Type: List
Grid: 4 columns
Query: Post type archive
Post type: product
# entries : 4
# leading entries: this defaults to 4
What this produces is:
Product title
Product description
I want to also display the thumbnail, price and add to cart button.
If you can point me to where the html is generated, I can figure it out.Daniel TaraKeymasterI understand now. Unfortunately this isn’t easy to accomplish. As stated, support for WooCommerce will be added in a future version and it will include the add to cart and price in custom query widgets. Have you considered using the plugin’s shortcodes instead?
webbrewersParticipantThat’s a good idea and seems to work fine. I’ve done that before but it didn’t occur to me this time!
Thanks for sticking with it!yourgypsysoulParticipantHi Webbrewers,
I know it’s a few months later, but I was just wondering if you could share what you did to get WooCommerce working with your site. I’m reviewing my functions.php right now but haven’t figured out exactly what I need to do. Thanks in advance!
– Rachel
webbrewersParticipantHi,
Pretty sure I used the woo commerce featured products shortcode to get products on the home page.
Is that what you needed to know?yourgypsysoulParticipantThanks for the quick reply.
The problem I am having is I have a “Shop” page set up, but the alignment is not correct. I think the problem that I am having can be solved with these stepsthese steps, but I am not entirely sure how to go about it.
webbrewersParticipantThe site I was working on is finished and I no longer have access but to get woo/theme compatibility you need to follow those directions to replace the wrapper element woo uses with what the theme uses. So look at page.php to see what the theme uses to start the content area. Chances are it’s <div id=”content” class=”site-content”> so try:
function my_theme_wrapper_start() {
echo ‘<div id=”content” class=”site-content”>’;
}function my_theme_wrapper_end() {
echo ‘</div>’;
}- This reply was modified 9 years, 2 months ago by webbrewers.
You must be logged in to reply to this topic.