Moving woocommerce shortdescription - wordpress

im new at wordpress, and im trying to move the blocks from the product page details of woocommerce. In my situation im trying to move the short_description block after the add button, but isnt working.
Here my code:
add_action( 'woocommerce_after_add_to_cart_button', 'woocommerce_short_description');

woocommerce_short_description is a filter, not a function that loads the short description template. The function that you want is woocommerce_template_single_excerpt
add_action( 'woocommerce_after_add_to_cart_button', 'woocommerce_template_single_excerpt' );

Related

remove links from woocommerce category using a shortcode

I'm using the shortcode
[product_category category="jacuzzis" columns="3"]
to show some amazon affiliate products on my website. The issue is that I don't want the user going to the product page under my domain but instead going to the amazon affiliate link.
In order to do that I'm trying first eliminating the link on the products. I'm using this code
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 10 );
It should remove the open link tag and the close link tag, but the link is still working after adding the snippet.
Does anyone know why?
You could use woocommerce_after_add_to_cart_quantity hook to add your custom button with ACF field. and just remove 'buy' button with CSS or another hook.

WooCommerce Shop page : Customize sorting dropdown to product categories dropdown

I would like to modify the products sorting on the shop page to product categories filter where the user can select the browse the products of categories from there.
I am a rookie in programming. I checked the WooCommerce directory to find the .php file I should work on. I got some clue it is in archive-product.php but I don't see the code which display the sorting dropdown.
Can anyone give me some clue to achieve this ? Or is there any workaround ? Thanks.
I added this in functions.php :
// remove default sorting dropdown
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
// now add the new dropdown
add_action( 'woocommerce_before_shop_loop', 'add_product_category_dropdown' );
function add_product_category_dropdown(){
print '<span class="woocommerce-ordering">'; // So it takes the same position as the default dropdown
the_widget( 'WC_Widget_Product_Categories', 'dropdown=1' );
print '</span>';
}
The reason you wouldn't see the code is that majority of what is generated by Woocommerce is handled by actions and hooks. In easier terms this means Woocommerce creates functions that spits out content and assigns them to different areas of the website.(For more information on Woocommerce actions and hooks, read here - https://docs.woothemes.com/document/introduction-to-hooks-actions-and-filters/ )
I'd recommend using the plugin below. It does exactly what you seem to be asking for and you can avoid having to play in parts you might not be comfortable with yet.
https://wordpress.org/plugins/yith-woocommerce-ajax-navigation/
Most awesome thing is that it's not one of those plugins that force you to get premium to actually get the desired effect.
I just found the solution few days ago. I use the function of WooCommerce product categories widget on the shop page.
This line of code will output the dropdown of product categories:
<?php the_widget( 'WC_Widget_Product_Categories', 'dropdown=1' ); ?>

Removing action added by a plugin in Wordpress

I am using Popup Maker plugin for Wordpress and I am trying to prevent it to load on a particular page using the functions.php file of a child theme.
I've located in the plugin's directory the file popup-maker.php which contains the following line at the end:
add_action( 'plugins_loaded', 'popmake_initialize', 0 );
If I remove / comment this line, the popup will not fire, so I guess this is the action I need to remove. I have read the WP codex and numerous posts but still can't get it to work.
Right now I am stuck at this (function I have added in my child theme's functions.php file):
function remove_popmaker() {
remove_action('plugins_loaded', 'popmake_initialize', 0);
}
add_action( 'init', 'remove_popmaker', 1 );
PS: I am using shopkeeper theme and Woocommerce.
All help appreciated, thanks.
you are adding a action to init which is after plugins_loaded so you cannot remove a action after it has run.
you can try the same action but you will have to do this from a plugin
remove_action( 'plugins_loaded', 'remove_popmaker', 0 );
But i suspect actions added before yours will be run after, this may be unpredictable if not you may have to code a MUplugin (google this).
There is a way I managed to do this:
add_action('wp', 'disableEmailPopup');
function disableEmailPopup () {
global $post;
if ($post->ID === 11625249) return remove_action( 'wp_enqueue_scripts', 'popmake_load_site_scripts');
}
#BMM - Without knowing the use case as to why you need to disable the entire plugin on one page its hard to give you the best answer.
For example if you simply wanted a single popup to not show on one page you can use the conditions panel to add a negative condition using the (!) button. Click it to turn it red and you will check for the opposite of a condition, so (!) Page Selected: Page xyz would prevent it from loading on that page.
Alternatively you can create your own custom conditions allowing you to add that condition to any popup.
Lastly if you wanted to unhook it just from the front end you can simply remove the rendering & script handlers
remove_action( 'wp_footer', 'popmake_render_popups', 1 );
remove_action( 'wp_head', 'popmake_script_loading_enabled' );
And if you want to prevent the queries as well
remove_action( 'wp_enqueue_scripts', 'popmake_preload_popups', 11 );
Hope that helps.

Moving Short Description in Woo Commerce

I've hunted everywhere to figure out how to move the Product Short Description from the right side of the picture on a Single Product page of Woocommerce into the tabs. I just can't find it anywhere!
Can someone please help me accomplish that.
Just remove the woocommerce_template_single_excerpt callback from the woocommerce_single_product_summary action:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
...and add it directly to a custom tabs.php template:
woocommerce_template_single_excerpt();
Read more about overriding templates in the docs.

How to add an "add to cart" button in single-product.php page in woocommerce?

I am using woocommerce to develop a ecommerce site
In single-product.php I am facing a problem.
I can't display the add to cart button under the product in this page.
So far I am using this code:
<?php
//global $post;
echo do_shortcode('[add_to_cart id="$post->ID"]');
?>
But no luck for me yet!
Maybe you made a simple writing mistake? Try this:
<?php
echo do_shortcode('[add_to_cart id="'.$post->ID.'"]');
?>
I would suggest using the WooCommerce default content-single-product.php template.
By default, the single product's add to cart template is added via the woocommerce_template_single_add_to_cart() function and is added to the woocommerce_single_product_summary hook (priority 30).
If you must change the single product content very radically, you can either call woocommerce_template_single_add_to_cart() directly or add it to a different hook. There's no reason to use a shortcode here.
If I understood you right, you want to move the Add-to-Cart button from the top of the page to the bottom of the page, so that it would go below the main product description.
Here is how I've done this on my website:
/* Removing the Add-To-Cart button from right below the product summary.
*/
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
/* Adding the Add-To-Cart button so that it would go after the main product description.
*/
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_single_add_to_cart', 12 );

Resources