Insert short description after YITH Wishlist button - php

I'm using YITH WooCommerce Wishlist plugin and in my WooCommerce single product pages, I'm trying to insert the "Short description" block after the YITH Wishlist button.
My wishlist html element is:
<div class="yith-wcwl-add-to-wishlist add-to-wishlist-48">
label
<div class="yith-wcwl-wishlistaddresponse"></div>
</div>
What is the tag to add action so that description goes after the element wish list?
My example code:
add_action('woocommerce_...','woocommerce_template_single_excerpt' );
Thanks.

That is possible easily and instead of moving the short description, you can place this Wishlist button before the short description. You will have first to change in the General settings of YITH WooCommerce Wishlist plugin, for "Position" you will choose "Use shortcode" and you will save that setting:
Then you will add a custom function hooked in woocommerce_single_product_summary action hook with a priority of 15 (between the product price (10) and the short description (20)):
add_action( 'woocommerce_single_product_summary', 'custom_yith_wcwl_add_to_wishlist', 15 );
function custom_yith_wcwl_add_to_wishlist(){
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
}
The Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Related WooCommerce template: content-single-product.php

PHP Snippet: Display YITH Wishlist Buttons # Shop Page – WooCommerce YITH WooCommerce Wishlist Add code in your theme fuctions.php file
Then create a page for example (whislist) and [yith_wcwl_wishlist] paste short code there and update page and then go to YITH Plugin Settings then Select Wishlist Page (page name wishlist which you created).
add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_display_yith_wishlist_loop', 97 );
function bbloomer_display_yith_wishlist_loop() {
echo do_shortcode( "[yith_wcwl_add_to_wishlist]" );
}

Related

How to remove Woocommerce cart notifications?

Question:
How to remove the Woocommerce cart notifications as: "Product was removed from cart", "Product was added to your cart", "Show cart".
Platform:
Wordpress & Woocommerce
Theme:
Astra
Plugin:
Elementor Pro
See photos for notifications I want to be removed.
Added to cart:
Removed from cart:
What I have already done is removing the coupon code from the checkout page through some code in the functions.php but I don't know if it's possible to remove these notifications through code or other options?
Here is hook to remove "Add to cart notifications" use this in functions.php
add_filter( 'wc_add_to_cart_message_html', 'dont_show_message');
function dont_show_message( $message, $products ) {
return '';
};
Or simply yon can use CSS to hide the same.

Remove mini cart menu from sidebar and redirect to checkout page

I'm using theme called Blance on my site, but want to remove right sidebar mini cart widget which appears when you add some product to cart. I tried this:
Disabled "Redirect to the cart page after successful addition" and "Enable AJAX Buy Now buttons on archives" from WooCommerce settings.
After that added this function into functions.php file:
add_filter( 'woocommerce_add_to_cart_redirect', 'add_to_cart_checkout_redirection', 10, 1 );
function add_to_cart_checkout_redirection( $url ) {
return wc_get_checkout_url();
}
But seems that products still appears in the right sidebar cart after pressing Buy Now button. How to override that, and redirect to checkout directly?

Remove "Custom fields" metabox in Woocommerce order edit pages

I'm trying to remove the 'postcustom' meta box from the order details for a simple wooCommerce shop. The div #postcustom appears in Orders--->Click on single order --> bottom of page as 'Custom Fields'. I want to get rid of it. There are loads of examples of how to do this by calling the following function:
function remove_custom_field_meta_box()
{
remove_meta_box('postcustom', 'page', 'normal');
}
I've hooked it (currently) into:
//Remove postcustom meta box
add_action('admin_menu', 'remove_custom_field_meta_box');
I've also tried 'dashboard' and 'post' as $context to no avail.
I've also tried hooking to remove_meta_boxes, admin_init, and a few others.
I'm working in a child themes functions.php and using the default wooCommerce theme. Any thoughts on why this isn't firing? That pesky #postcustom div is still there in the admin menu! Is my context incorrect? I also tried 'orders'. Thanks#
Updated: For orders in Woocommerce the post type is 'shop_order', so your code should be:
add_action( 'add_meta_boxes', 'remove_shop_order_meta_boxe', 90 );
function remove_shop_order_meta_boxe() {
remove_meta_box( 'postcustom', 'shop_order', 'normal' );
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Or you can hide it hitting the "screen options" tab and unchecking "Custom Fields" checkbox:

Add a DIV in Woocommerce Shop Page only

I'd like to add a DIV under the title of my Shop page, but ONLY my main shop page.
I added some code in " archive-product.php " but then it display the code on every shop page.
In fact i just need a DIV saying " choose a category below " on the main Shop Page.
Thnaks a lot for your help!
Vince
Instead of overriding archive-product.php template, You can use the following custom hooked function, that will add a custom <div> below the title in shop page only:
add_action( 'woocommerce_archive_description', 'additional_div_in_shop', 5 );
function additional_div_in_shop() {
// Only on "shop" archives pages
if( ! is_shop() ) return;
// Output the div
?>
<div class="shop-below-title"><?php _e( "Choose a category below", "woocommerce" ); ?></div>
<?php
}
Code goes in function.php file of your active child theme (or active theme).
Tested and works.
Related Docs: woocommerce conditional tags
You can add that div conditionally like the following and then the div will be shown only on shop page
if ( is_shop() ) {
echo '<div>Choose a category below</div>';
}
I know this is an old post but, there is a page selected as the shop page for woocommerce. U can simply switch back to classic editor and add a div in the text section of the page u selected in the woocommerce settings. That way u don't need child theme or anything.

Add short product description to Widget products in WooCommerce

it is possible to add short description to the products list in the woocommerce products wordpress widget?
How I do it?
I'm not a pro, be easy in your answers, please!
Thanks
You should need to override WooCommerce content-widget-product.php template via your active theme. Here is a documentation related: Template structure & Overriding templates via a theme
So you will need to create a folder named woocommerce in your active child theme (or active theme), if not done yet, in which you will copy the file located in:
wp-content/plugins/woocommerce/templates/content-widget-product.php
to:
wp-content/themes/your-child-theme/woocommerce/content-widget-product.php
Once done you will add after the line 34 the following:
<div class="produc-excerpt"><?php echo $product->get_short_description(); ?></div>
This will add the product short description for each product in the Widget Products output list.
In upcoming WooCommerce version 3.3, you will be able to replace that using a custom function hooked in dedicated woocommerce_widget_product_item_end action hook:
add_action( 'woocommerce_widget_product_item_end', 'add_excerpt_to_widget_products', 10, 1 );
function add_excerpt_to_widget_products( $args ) {
global $product;
echo '<div class="produc-excerpt">Bla: '. $product->get_short_description(). '</div>';
}
Code goes in function.php file of your active child theme (or active theme).
Tested and works only in WooCommerce version 3.3+.

Categories