PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 13, 2022

[FIXED] Move additional information from product tab under add to cart button in WooCommerce

 March 13, 2022     hook-woocommerce, php, product, woocommerce, wordpress     No comments   

Issue

In single product pages, I would like to change the location of "additional information" from tabs, under add to cart button using Woocommerce hooks (removing the "additional information" tab).

I have:

add_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );

and: woocommerce_after_add_to_cart_button

I'm trying:

remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );

add_action( 'woocommerce_after_add_to_cart_button', 'woocommerce_product_additional_information' );

and

remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );

add_action( 'woocommerce_single_product_summary', 'woocommerce_product_additional_information', 60 );

But it doesn't work.

How can I move properly "additional information" below add to cart button?


Solution

The following code will remove additional information tab and add additional information below add to cart:

 // Remove additional information tab
add_filter( 'woocommerce_product_tabs', 'remove_additional_information_tab', 100, 1 );
function remove_additional_information_tab( $tabs ) {
    unset($tabs['additional_information']);

    return $tabs;
}

// Add "additional information" after add to cart
add_action( 'woocommerce_single_product_summary', 'additional_info_under_add_to_cart', 35 );
function additional_info_under_add_to_cart() {
    global $product;

    if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
        wc_display_product_attributes( $product );
    }
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.



Answered By - LoicTheAztec
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing