I am using Dokan for a listings site. The core set of products that will be used are bookable products.
As such I want to rename the products field to 'Bookings'. I have digging around in the plugin template files and can find where the tabs are included in the store template but can't seem to find where the actual tabs are defined.
Any help would be awesome thanks. For reference below the code where the tabs are being included:
<?php if ( $store_tabs ) { ?>
<div class="dokan-store-tabs<?php echo $no_banner_class_tabs; ?>">
<ul class="dokan-list-inline">
<?php foreach( $store_tabs as $key => $tab ) { ?>
<li><?php echo $tab['title']; ?></li>
<?php } ?>
<?php do_action( 'dokan_after_store_tabs', $store_user->get_id() ); ?>
</ul>
</div>
I am also having an issue with the reviews page (I removed the sidebars from store.php and store-review.php in child theme folder) and reviews page now just loads header and footer of my theme).
You can disable any tabs you want by adding a code in your function.php file (to avoid code deletion when theme updates).
For example:
To remove the reviews tab
// Disable Woocommerce Reviews Form Tab
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );
function wcs_woo_remove_reviews_tab($tabs) {
unset($tabs['reviews']);
return $tabs;
}
And to remove extra tabs by calling tab name
// Disable Seller More Products Tab
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_more_seller_product_tab', 98 );
function wcs_woo_remove_more_seller_product_tab($tabs) {
unset($tabs['more_seller_product']);
return $tabs;
}
Hope this can help you :)
Managed to figure out how to do it.
In the dokan plugin folder navigate to the includes folder. Inside this folder there is a functions.php file.
Search for 'dokan_get_store_tabs('
Find and replace Products with text of your choice within this function.
for remove Seller info tab on product page in dokan plugin:
add_filter( 'woocommerce_product_tabs', 'dokan_remove_seller_info_tab', 50 );
function dokan_remove_seller_info_tab( $array ) {
unset( $array['seller'] );
return $array;
}
for remove seller button on WC dashboard in dokan plugin:
remove_action( 'woocommerce_after_my_account', array( Dokan_Pro::init(), 'dokan_account_migration_button' ) );
for disable registration as a seller in WC registration in dokan plugin:
remove_action( 'woocommerce_register_form', 'dokan_seller_reg_form_fields' );
Related
This code works perfectly except I'm trying to determine how to EXCLUDE the main shop page from being included in the action. This hook adds the HTML code to all archive-type pages including the main shop page. Given this is a link back to the shop page, it should be excluded on the shop page.
Any help would be greatly appreciated.
function add_back_to_catalog_category() {
?>
<div><br><p class="button-catalog">Back to Catalog - All Products</p></div><?php
}
add_action( 'woocommerce_after_shop_loop', 'add_back_to_catalog_category' );
Visual reference to woocommerce_after_shop_loop action hook.
You can use the WooCommerce conditional tag is_shop() like:
add_action( 'woocommerce_after_shop_loop', 'add_back_to_catalog_category' );
function add_back_to_catalog_category() {
// Not on shop page
if( ! is_shop() ) {
printf( '<div><br><p class="button-catalog">%s</p></div>',
get_permalink( wc_get_page_id( 'shop' ) ),
__("Back to Catalog - All Products", "your-text-domain")
);
}
}
Code goes in functions.php file of the active child theme (or active theme). It should works.
I'm trying to remove the add to cart button from the categories page for products that are not purchasable.
This is my current code, which I have placed in the functions.php file of my child theme;
function buy_filter()
{
if ( ! is_product() ) return;
$product_id=get_the_ID();
$product = wc_get_product($product_id);
if ($product->is_virtual('yes'))
if ($product->is_virtual('yes'))
{
add_filter( 'woocommerce_is_purchasable', '__return_false');
}
}
add_action ('wp', 'buy_filter');
I've managed to remove the button from the individual product pages, however I still can't get it to be removed from the categories page. Now when I inspect the button shows the following code:
<a href="?add-to-cart=16972" data-quantity="1" class="button product_type_simple add_to_cart_button
ajax_add_to_cart" data-product_id="16972" data-product_sku="604544617405" aria-label=
"Add “Federal - 9MM Syntech, 115gr” to your cart" rel="nofollow">Add to cart</a>
Does this button need to be disabled in another way?
I really need this button to be removed as its a product that we only want to sell in our store, but we want people to know that we do stock that product as well.
Below is an image of what it currently looks like, and what I want to go. Ideally, I would like the button gone completely, but I will definitely settle for a replacement to the read more button if that is easier.
To remove it from everywhere (on single pages and category pages) use directly the filter instead, replacing your code with:
add_filter( 'woocommerce_variation_is_purchasable', 'filter_virtual_products', 10, 2 );
add_filter( 'woocommerce_is_purchasable', 'filter_virtual_products', 10, 2 );
function filter_virtual_products( $is_purchasable, $product )
{
if ( $product->is_virtual('yes') ) {
$is_purchasable = false;
}
return $is_purchasable;
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Please try this code inside your functions.php file
add_filter('woocommerce_is_purchasable', 'woocommerce_cloudways_purchasable');
function woocommerce_cloudways_purchasable($cloudways_purchasable, $product) {
return ($product->id == your_specific_product_id (like 22) ? false : $cloudways_purchasable);
}
Source: https://www.cloudways.com/blog/how-to-remove-hide-or-disable-add-to-cart-button-in-woocommerce/
or Use this plugin will solve your issue without any coding.
https://wordpress.org/plugins/non-purchasable-woocommerce-products/
How to move the product meta to the beginning of the product description tab?
I try:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_product_tabs_description', 'woocommerce_template_single_meta', 10 );
Remove works, but add_action() doesn't.
You can keep the first code line. Then to insert single product meta on product description tab, before description, you can use 2 different ways:
1). Using Hooks as follows:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_filter( 'woocommerce_product_tabs', 'woocommerce_custom_product_tabs', 999 );
function woocommerce_custom_product_tabs( $tabs ) {
// We overwrite the callback function with a custom one
$tabs['description']['callback'] = 'woocommerce_product_meta_and_description_tab';
// (optional) We can also overwrite the title
$tabs['description']['title'] = __('Meta and description', 'woocommerce');
return $tabs;
}
function woocommerce_product_meta_and_description_tab() { // this is where you indicate what appears in the description tab
wc_get_template( 'single-product/meta.php' ); // The meta content first
wc_get_template( 'single-product/tabs/description.php' ); // The product description after
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
2). Or Overriding templates:
You can override single-product/tabs/description.php template file via your theme as explained in this official documentation.
Once you have copied the file to the woocommerce folder inside your active theme, open edit single-product/tabs/description.php file and add the following line inside it:
wc_get_template( 'single-product/meta.php' );
It will displays the product meta information inside the product description tab.
Don't forget to keep in your active child theme's functions.php file:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
Related: WooCommerce action hooks and overriding templates
There actually is a way to do this within your functions without copying files from woocommerce and overriding them in your child theme.
Per WooCommerce documentation, you can customize the product data tabs. With a small modification to the code they provided, you can do what you're asking:
/**
* Customize product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$tabs['description']['callback'] = 'woo_custom_description_tab_content'; // Custom description callback
return $tabs;
}
function woo_custom_description_tab_content() { // this is where you indicate what appears in the description tab
wc_get_template( 'single-product/meta.php' ); // add this to add meta to content
the_content(); // keep this in to preserve original functionality
}
I would like to show text under Shop page main content. Different text for different categories.
I am aware of showing category description on the Shop page for each category but this is already in use.
Right now I am this far but it does not seem to work in the Child theme functions.php
if ( is_category( 'category1' ) ) {
function add_my_text() {
print '<p>This is my extra text.</p>';
}
add_action( 'woocommerce_after_main_content', 'add_my_text' );
}
Will be thankful if anyone knows how to improve this function
Thrilled I found this answer. Was struggling mightily to add content based on a custom taxonomy created with Custom Post Type UI. In case anyone else needs to know, you don't have to change permalinks or anything silly like that. Simple modification of LoicTheAztec's answer above does the trick.
add_action( 'woocommerce_product_meta_end', 'add_my_text' );
function add_my_text() {
if ( wc_get_product_class( $class = 'taxonomy-term' ) ) {
echo '<h2>IT WORKS!!!</h2>';
}
}
If you want to insert content into a different place on the page, choose a different hook from this very helpful WooCommerce Visual Hook Guide.
Hope this saves somebody else 9 hours :)
The Wordpress conditional function is_category() doesn't work with Woocommerce product categories which are a custom taxonomy. Instead use Woocommerce conditional tag is_product_category() inside your hooked function like:
add_action( 'woocommerce_after_main_content', 'add_my_text' );
function add_my_text() {
if ( is_product_category( 'category1' ) ) {
echo '<p>This is my extra text.</p>';
}
}
Code goes on function.php file of your active child theme (or active theme). It should works.
the products in our woocommerce shop don't need any of the default tabs so I have managed to disable them being that I only need to have the product description below the product however, while I want to keep the actual description, I believe the tab itself is redundant since there aren't any other tabs.
Basically, I want to remove the tab's & title altogether but keep the content box below it without modifying the woocommerce core php template file. Is there a way to add a filter to my WordPress theme's functions.php?
function woocommerce_default_product_tabs( $tabs = array() ) {
global $product, $post;
// Description tab - shows product content
if ( $post->post_content ) {
$tabs['description'] = array(
'title' => __( 'Description', 'woocommerce' ),
'priority' => 10,
'callback' => 'woocommerce_product_description_tab'
);
}
While CSS is great, if the stylesheet doesn't load correctly, you could end up showing someone tabs without meaning to. It is best to remove the content before loading (server side), by using a filter, as you had mentioned.
See code below as provided from Woothemes for unsetting data tabs.
EDIT Place within the functions.php file inside your theme.
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
EDIT As noted by #BasvanDijk
To remove altogether, you can use the following
add_filter( 'woocommerce_product_tabs', '__return_empty_array', 98 );
If you want to remove tabs from woo-commerce product details page, then add this code in your function.php
Option 1-
Go to functions.php and Add the following code.
(Go to Admin panel > Appearance > Editor > functions.php)
add_filter( 'woocommerce_product_tabs', 'woo_remove_tabs', 98 );
function woo_remove_tabs( $tabs ){
if(is_product()){
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
}
return $tabs;
}
By using this filter we can Remove the tabs From the Woocommerce Product Pages.
Option 2-
Or for an alternative approach just add this to your functions.php
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10);
Option 3-
Hide the tab by adding this to the bottom of woocommerce.css
.woocommerce_tabs .tabs {
display: none;
}
Read more -Woo-commerce: Remove tab from product page
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_product_description', 40 );
This work for me with the contributions i got here. Other than removing the tab and also to place back the text.
Credits to Swapnali & Mustafa
Here is the working code:
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );
function wcs_woo_remove_reviews_tab($tabs) {
unset($tabs['reviews']);
return $tabs;
}
for some reason the code to add to functions.php file did not work for me, even tho it is in the woo commerce codex.
I was getting lots of comment spam to these products that showed reviews.
in the end I manually removed the review tab from all the products using built in wordpress/woocommerce functionality.
go to the product lising page
click the checkbox to select all products (it will only select the products on this page so you may have to go thru several pages to repeat)
from the bulk actions drop down, select edit
click apply
you will now see all the bulk edit actions you can do. Choose the "comments" drop down, and select "Do not allow"
click update
make sure to delete any cache if using a caching plugin
Excuse me but the question is not only removing tabs but also keeping the product description. If you ever tried the code above you would realize that while removing tabs you are actually removing the product description. And this is not the desired case.
You should somewhere add the following code to add it back. But unfortunately this time you can add the description side by side the picture and making a narrow column. I couldn't find the solution to add it nicely below the picture where the tabs existed before.
The code:
function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 40 );
Using a combination of the answers above, nesting the function within the action so you can use within a conditional:
add_action( 'wp', 'custom_remove_tabs_by_tag' );
function custom_remove_tabs_by_tag() {
if ( is_product() && has_term( 'tag-term', 'product_tag' ) )
{
// Remove All Product Tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
// Add Product Description
add_action( 'woocommerce_after_single_product_summary',
function () { woocommerce_get_template( 'single-product/tabs/description.php' );},
40 );
}