admin管理员组

文章数量:1026664

I would like to have "add to cart" button nearby the price like in the picture.

By default, the button is placed after the price in the code, and I would like to move the button in the same tag of the price.

But I don't know which template of Woocommerce I have to edit to make this.

Thank's !

I would like to have "add to cart" button nearby the price like in the picture.

By default, the button is placed after the price in the code, and I would like to move the button in the same tag of the price.

But I don't know which template of Woocommerce I have to edit to make this.

Thank's !

Share Improve this question asked Mar 28, 2019 at 10:06 user10533272user10533272 334 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You can change the priority/order by removing and re-adding the parts you want the position changed - like this:

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );

Drop this piece of code into your functions.php to take effect.

I would like to have "add to cart" button nearby the price like in the picture.

By default, the button is placed after the price in the code, and I would like to move the button in the same tag of the price.

But I don't know which template of Woocommerce I have to edit to make this.

Thank's !

I would like to have "add to cart" button nearby the price like in the picture.

By default, the button is placed after the price in the code, and I would like to move the button in the same tag of the price.

But I don't know which template of Woocommerce I have to edit to make this.

Thank's !

Share Improve this question asked Mar 28, 2019 at 10:06 user10533272user10533272 334 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You can change the priority/order by removing and re-adding the parts you want the position changed - like this:

remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );

Drop this piece of code into your functions.php to take effect.

本文标签: Move add to cart in Woocommerce