woocommerce action help

in woocommerce theme i have this:
do_action( 'woocommerce_after_shop_loop_item_title' );

Open in new window

this brings back ratings and price. i want to separate them to appear in different places.
so i understand i should override the action with my own one. so i wrote this in the functions.php page:
    function action_woocommerce_after_shop_loop_item_title(  ) 
        echo "string";
    // add the action
    add_action( 'woocommerce_after_shop_loop_item_title', 'action_woocommerce_after_shop_loop_item_title' );

Open in new window

and the word string is indeed added, but u have no idea how to get the rating and the price variables? how can i pass them to the function?
i have the template files also, and i can change the html, but it still bundle the two together. maybe i miss where exactly they bundle them together?

best regards
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>ee: this brings back ratings and price. i want to separate them to appear in different places.

You can remove and then re-add the actions associated with ‘woocommerce_after_shop_loop_item_title’ hook with the desired priority.
woocommerce_after_shop_loop_item_title hook
hooked woocommerce_template_loop_rating - 5
hooked woocommerce_template_loop_price - 10

- For yourprefix you should use your theme's slug

Try this in your child theme's functions.php:
add_action( 'init', 'yourprefix_woocommerce_remove_actions', 11 );
function yourprefix_woocommerce_remove_actions() {
	// Remove the hooks you want to move
	remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
	remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );

	// Add it back with a different priority.
	add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 10 );
	add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 5 );

Open in new window

derridaAuthor Commented:
first, thanks for answering. but playing with the priorities doesn't help. maybe i should explain again what i need, i am new to woocommerce.
in content-product.php there is this :
<h5 class="price-text-color">
       <?php do_action( 'woocommerce_after_shop_loop_item_title' ); ?>

Open in new window

this spit out both the price and the ratings inside the h5. i want to get those seperately and display them whereever i need.i tried what you gave me and play with priorities and it doesn't give me control of the variables and where to display them.

best regards
It is wrong to have this:
<h5 class="price-text-color">
at this place.

Woocommerce action hook:
woocommerce_after_shop_loop_item_title is
hooked to:
woocommerce_template_loop_rating function (priority - 5) and
woocommerce_template_loop_price function (priority - 10)
do_action( 'woocommerce_after_shop_loop_item_title' );
execute all functions hooked on this action hook.

Try this what I have posted, with another wp theme and you'll see that the rating and price change their order.

Instead of this:
// Add it back with a different priority.
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 5 );

Open in new window

You can use your own functions e.g.:
add_action( 'woocommerce_after_shop_loop_item_title', 'yourprefix_woocommerce_template_loop_rating', 10 );

add_action( 'woocommerce_after_shop_loop_item_title', 'yourprefix_woocommerce_template_loop_price', 5 );

function yourprefix_woocommerce_template_loop_price() {
	//echo "string";
	global $product;

	if ( $price_html = $product->get_price_html() ) :?>
		<span class="price"><?php echo $price_html; ?></span>


Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.