Hi,
It is possible to add a short description of the product onto shop page. So that under the image would show the short description.
Also, how can I add a sidebar to the single product pages?
Thanks,
Hi,
It is possible to add a short description of the product onto shop page. So that under the image would show the short description.
Also, how can I add a sidebar to the single product pages?
Thanks,
Hi there,
Thanks for posting in.
Yes possible, but through custom code. Please add these codes to your child theme’s functions.php
function x_woocommerce_shop_product_thumbnails_custom() {
GLOBAL $product;
$id = get_the_ID();
$thumb = 'entry';
$rating = ( function_exists( 'wc_get_rating_html' ) ) ? wc_get_rating_html( $product->get_average_rating() ) : $product->get_rating_html();
woocommerce_show_product_sale_flash();
echo '<div class="entry-featured">';
echo '<a href="' . get_the_permalink() . '">';
echo get_the_post_thumbnail( $id, $thumb );
if ( ! empty( $rating ) ) {
echo '<div class="star-rating-container aggregate">' . $rating . '</div>';
}
echo '</a>';
if ( x_is_shop() ) woocommerce_template_single_excerpt();
echo "</div>";
}
add_action('init', 'x_override_product_item', 99999999 );
function x_override_product_item () {
remove_action( 'woocommerce_before_shop_loop_item_title', 'x_woocommerce_shop_product_thumbnails', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'x_woocommerce_shop_product_thumbnails_custom', 10 );
}
function x_get_content_layout() {
$content_layout = x_get_option( 'x_layout_content' );
if ( $content_layout != 'full-width' ) {
if ( is_home() ) {
$opt = x_get_option( 'x_blog_layout' );
$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
} elseif ( is_singular( 'post' ) ) {
$meta = get_post_meta( get_the_ID(), '_x_post_layout', true );
$layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;
} elseif ( x_is_portfolio_item() ) {
$layout = 'full-width';
} elseif ( x_is_portfolio() ) {
$meta = get_post_meta( get_the_ID(), '_x_portfolio_layout', true );
$layout = ( $meta == 'sidebar' ) ? $content_layout : $meta;
} elseif ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
$layout = 'content-sidebar';
} elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
$layout = 'sidebar-content';
} elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
$layout = 'full-width';
} elseif ( is_archive() ) {
if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
$opt = x_get_option( 'x_woocommerce_shop_layout_content' );
$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
} else {
$opt = x_get_option( 'x_archive_layout' );
$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
}
} elseif ( x_is_product() ) {
$layout = 'full-width';
} elseif ( x_is_bbpress() ) {
$opt = x_get_option( 'x_bbpress_layout_content' );
$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
} elseif ( x_is_buddypress() ) {
$opt = x_get_option( 'x_buddypress_layout_content' );
$layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
} elseif ( is_404() ) {
$layout = 'full-width';
} else {
$layout = $content_layout;
}
} else {
$layout = $content_layout;
}
if ( x_is_product() ) return 'content-sidebar';
return $layout;
}
add_filter( 'ups_sidebar', 'ups_display_product_sidebar', 99 );
function ups_display_product_sidebar ( $sidebar ) {
return x_is_product() ? 'SIDEBAR_ID_HERE' : $sidebar;
}
Now, go to Admin > Appearance > Sidebars
and add a sidebar, then please remember the ID of the sidebar you just created. Then from above code, change SIDEBAR_ID_HERE
with your sidebar’s ID.
These custom codes may not work in the future due to updates or conflicts with other features. We may or may not cover it in the future depending on the severity, we can only cover simple customization as a help (as we can’t really cover any type of customization ).
Hope these help
Thank you for the help. The code worked.
Thanks,
You’re always welcome!
Cheers.
hi there,
that works for me too and it is just what i needed. thanks!
is there a way to include this short desciption also on the category pages?
i just have a layout issue which can be seen on the screenshot. there is a pragraph big space below the last text line of the short description and no space between the outlined picture-text-box and the h3 product name. i assume the two divs (entry-featured and entry-wrap) got mixed somehow?
could that be fixed? thanks a lot! kai
i used this code:
function x_woocommerce_shop_product_thumbnails_custom() {
GLOBAL $product;
$id = get_the_ID();
$thumb = 'entry';
$rating = ( function_exists( 'wc_get_rating_html' ) ) ? wc_get_rating_html( $product->get_average_rating() ) : $product->get_rating_html();
woocommerce_show_product_sale_flash();
echo '<div class="entry-featured">';
echo '<a href="' . get_the_permalink() . '">';
echo get_the_post_thumbnail( $id, $thumb );
if ( ! empty( $rating ) ) {
echo '<div class="star-rating-container aggregate">' . $rating . '</div>';
}
echo '</a>';
if ( x_is_shop() ) woocommerce_template_single_excerpt();
echo "</div>";
}
add_action('init', 'x_override_product_item', 99999999 );
function x_override_product_item () {
remove_action( 'woocommerce_before_shop_loop_item_title', 'x_woocommerce_shop_product_thumbnails', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'x_woocommerce_shop_product_thumbnails_custom', 10 );
}
Hi There,
Would you mind providing us with login credentials(by clicking on the Secure Note button at the bottom) so we can take a closer look? To do this, you can make a post with the following info:
Thanks.
thanks al lot thai!
and something else. the detailed product page has the same headling twice (Beschreibung) since i deactivated all the other tabs or don’t use them. how can i have only one? thanks! kai
Hello There,
To resolve your issue, you need to update the code and move the short description outside of the div for the featured image. Please use this:
function x_woocommerce_shop_product_thumbnails_custom() {
GLOBAL $product;
$id = get_the_ID();
$thumb = 'entry';
$rating = ( function_exists( 'wc_get_rating_html' ) ) ? wc_get_rating_html( $product->get_average_rating() ) : $product->get_rating_html();
woocommerce_show_product_sale_flash();
echo '<div class="entry-featured">';
echo '<a href="' . get_the_permalink() . '">';
echo get_the_post_thumbnail( $id, $thumb );
if ( ! empty( $rating ) ) {
echo '<div class="star-rating-container aggregate">' . $rating . '</div>';
}
echo '</a>';
echo "</div>";
if ( x_is_shop() ) woocommerce_template_single_excerpt();
}
add_action('init', 'x_override_product_item', 99999999 );
function x_override_product_item () {
remove_action( 'woocommerce_before_shop_loop_item_title', 'x_woocommerce_shop_product_thumbnails', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'x_woocommerce_shop_product_thumbnails_custom', 10 );
}
Please let us know how it goes.
hi there! thanks a million. that looks much nicer!
and how would i change the php file to have the category pages display this short description, too?
i would suggest to include this option in the woocommerce settings of x/pro. maybe even with an option to select the short description or the one for the shopping cart
thanks again! kai
Hello There,
To include the short description in product category archives, please remove this line:
if ( x_is_shop() ) woocommerce_template_single_excerpt();
And replace it with this:
if ( x_is_shop() || x_is_product_category() ) woocommerce_template_single_excerpt();
We’ve also added your feedback as a feature request so it can be taken into consideration for future development.
Thank you.
thanks a million @RueNel !!! it worked fine
looking forward to feature updates of x after the template manager is finally ready
have a great day! kai
You’re welcome!
We’re glad we were able to help you out.
Hey @arrowmultimedia,
Your post has been withdrawn. Please post your issue in a separate thread instead.
We will respond to that new thread shortly.