Woocommerce. How to change a sale text label?
functions.php
add_filter('woocommerce_sale_flash', 'my_custom_sale_flash', 10, 3);
function my_custom_sale_flash($text, $post, $_product) {
return '<span class="onsale"> СКИДКА 5% </span>';
}
How to make more product in wooommerce page?
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 64;' ), 20 );
Where 64 is number of products.
woocommerce and view products from category
Add in you page or post:
[product_category category="My category" per_page="5" columns="5" orderby="date" order="desc" ]
How delete all buttons "Add to cart"?
functions.php
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 ); remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
Chortcode in wordpress text widget
If you want add chortcode in wordpress text widjet, you should add line in functions.php
add_filter('widget_text', 'do_shortcode');
Get current woocommerce category
<?php global $wp_query; $cat_obj = $wp_query->get_queried_object(); $category_name = $cat_obj->name; // <----current category ?>
WordPress text widget with text from post for each category woocommerce
How make wordpress text widget with text from post for each category woocommerce?
It's easy!
- install plugin Enhanced Text Widget;
- add code in Enhanced Text Widget textarea;
<?php
function show_text($id)
{
$my_postid = $id;
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content=apply_filters('the_content',$content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
}
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$category_name = $cat_obj->name;
switch($category_name){
case 'Test1': show_text(22);break;
case 'Test2': show_text(23);break;
case 'Test3': show_text(24);break;
case 'Test4': show_text(25);break;
}
?>
WordPress text widget with text from post
- install plugin Enhanced Text Widget;
- add code in Enhanced Text Widget textarea;
<?php
$my_postid = 22; //id your post
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content =apply_filters('the_content',$content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
?>
Woocommerce: Short description in list products
wp-content/plugins/woocommerce/templates/content-product.php
<?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action( 'woocommerce_after_shop_loop_item_title' ); global $post; if ( ! $post->post_excerpt ) return; ?> <div itemprop="description" class="description"> <?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?> </div>