Digital experiences for all disciplines
New Landing › How can we help? › Atelier › Hide empty description tab & messy add to cart product page
New Landing › How can we help? › Atelier › Hide empty description tab & messy add to cart product page
- This topic has 15 replies, 2 voices, and was last updated 9 years by Mohammad – SUPPORT.
-
Posted in: Atelier
-
November 12, 2015 at 1:46 pm #228190
Hi,
1. Regarding hiding the description tab on the product page, I have placed the following code in my child themes functions.php:
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function woo_remove_product_tabs( $tabs ) { $tabs['description']['priority'] = 50; //$tabs['description']['title'] = __( 'More Information' ); return $tabs; }
But unfortunately it only places the tab below the other tabs and not hides it. See screenshot.
On my site not all description tabs are empty, so a complete removal is not wanted.
Could you help me with a better code?2. Regarding the buttons for add to cart and wishlist on the product page, if the page is presented on a small screen, the buttons don’t line up nicely. Please have a look at my screenshot.
Any ideas on that?Thank you.
Buckie.Attachments:
You must be logged in to view attached files.November 16, 2015 at 10:11 am #228897Hi,
Please use this code to remove the tab.add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function woo_remove_product_tabs( $tabs ) { unset( $tabs['description'] ); // Remove the description tab return $tabs; }
Thanks
MohammadNovember 16, 2015 at 10:25 am #228903Hi,
Please use also this code for second issue:-@media only screen and (max-width: 767px) { button.single_add_to_cart_button { padding: 0px 6px !important; font-size: 9px !important; margin: 0px !important; } div.quantity{ margin:0px 1px 0px 0px !important; } }
Thanks
MohammadNovember 16, 2015 at 11:15 am #228934Hi Mohammed,
Thank you, but unfortunately it didn’t help.
1. This code hides all description tabs, even if it has content. Is it possible to have the tabs hidden only when no content is there?
2. The layout is still messy. Please have a look at my site.Thanks!
BuckiePS. I’ve cleared my cache.
November 16, 2015 at 11:17 am #228936This reply has been marked as private.November 16, 2015 at 11:56 am #228953Hi,
Please remove the last code and try to use this code:-add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function woo_remove_product_tabs( $tabs ) { $product_description = sf_get_post_meta($post->ID, 'sf_product_description', true); if ($product_description == "") { unset( $tabs['description'] ); // Remove the description tab } return $tabs; }
Thanks
MohammadNovember 16, 2015 at 1:44 pm #228998Unfortunately it still removes the tab with content.
Any other suggestions?Buckie.
November 16, 2015 at 1:53 pm #229001Hi,
Please remove my last code and use this new code:-add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function woo_remove_product_tabs( $tabs ) { global $post; $product_description = sf_get_post_meta($post->ID, 'sf_product_description', true); if ($product_description == "") { unset( $tabs['description'] ); // Remove the description tab } return $tabs; }
Thanks
MohammadNovember 16, 2015 at 1:57 pm #229003Works like a charm! Thank you!!
Any ideas on my second issue?Buckie.
November 16, 2015 at 2:01 pm #229004Hi,
Please use this code for your second issue.@media only screen and (max-width: 767px) { button.single_add_to_cart_button { padding: 0px 6px !important; font-size: 9px !important; margin: 0px !important; } div.quantity{ margin:0px 1px 0px 0px !important; } }
Thanks
MohammadNovember 16, 2015 at 2:21 pm #229012This reply has been marked as private.November 16, 2015 at 2:26 pm #229017Hi,
Whats your screen size?
Thanks
MohammadNovember 16, 2015 at 2:33 pm #229019Hi,
This problem occurs in screen sizes between approx. 765px and 1190px.
Hope this helps. I’ve already tried your css code with the max-width on 1024px, but it didn’t help.Thanks.
Buckie.November 16, 2015 at 2:40 pm #229022Hi,
Please try to use this code:-@media only screen and (min-width:767px) and (max-width: 1190px) { button.single_add_to_cart_button { padding: 0px 6px !important; font-size: 9px !important; margin: 0px !important; } div.quantity{ margin:0px 1px 0px 0px !important; } }
Thanks
MohammadNovember 17, 2015 at 1:17 pm #229338Hi Mohammad,
I kept having problems with your code, so I made it work with following css:
/* To resolve messy add to cart buttons on product page */ @media only screen and (min-width:767px) and (max-width: 1190px) { form.cart { margin-bottom:0;} .woocommerce div.product form.cart div.quantity{margin-bottom:20px !important;} .woocommerce form.cart button.add_to_cart_button{margin-bottom:20px !important; margin-right: 20px !important;} .woocommerce form.cart .yith-wcwl-add-to-wishlist{margin: 0 !important;} }
Do you think it could cause problems or is it okay?
Thank you!
Buckie. -
Posted in: Atelier
You must be logged in and have valid license to reply to this topic.