admin管理员组

文章数量:1429486

I am trying to add this to functions.php. In my test lab on a different site it adds the test info information fine. But on the website I am trying to add it to nothing happens. The website is running a builder thrifty theme with the latest woocommerce. Any ideas? I'm basically just wanting to add a line of text on every product page that is like a disclaimer but can't.

add_action('woocommerce_before_add_to_cart_form','print_something_below_short_description');

function print_something_below_short_description() {
    echo 'Test Info.';
}

I am trying to add this to functions.php. In my test lab on a different site it adds the test info information fine. But on the website I am trying to add it to nothing happens. The website is running a builder thrifty theme with the latest woocommerce. Any ideas? I'm basically just wanting to add a line of text on every product page that is like a disclaimer but can't.

add_action('woocommerce_before_add_to_cart_form','print_something_below_short_description');

function print_something_below_short_description() {
    echo 'Test Info.';
}
Share Improve this question edited Jun 6, 2017 at 2:56 DaveLak 1,0577 silver badges18 bronze badges asked Jun 6, 2017 at 1:06 WebberMDWebberMD 91 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

It's possible the theme or another plugin are using that hook with a later priority. Your add_action would have the default of 10; try giving it a 12 or a 20, etc. and see if the text shows up.

add_action('woocommerce_before_add_to_cart_form','print_something_below_short_description', 10);

You can read about Priority with Action Hooks here.

Please try this code. Hope it will work now.

function action_woocommerce_before_add_to_cart_form(  ) { 
    echo 'Test Info.';
};        
add_action( 'woocommerce_before_add_to_cart_form', 'action_woocommerce_before_add_to_cart_form', 10, 0 );

本文标签: actionsFunctionsphp change for Woocommerce not working