Here is my function for adding an option to my orders page:
add_filter( 'woocommerce_my_account_my_orders_actions', 'add_my_account_my_orders_custom_action', 10, 2 );
function add_my_account_my_orders_custom_action( $actions, $order ) {
$action_slug = 'specific_name';
$actions[$action_slug] = array(
'url' => home_url('/the_action_url/'),
'name' => 'The Button Text',
);
return $actions;
}
My question is this : How Can I add my custom CSS to ONLY my newly created option
(There are 3 other buttons except my button that I do not want to change their style and all 4 of them have same class).
2
Answers
Using
$action_slug = 'specific_name';
will automatically add this as a class to the button.Then you can use the following selector
To apply CSS specifically or to overwrite existing CSS
To do the reverse and remove certain classes for this particular button, you need to overwrite the template file /myaccount/orders.php in addition to your existing code
yourtheme/woocommerce/myaccount/orders.php
.Replace line 69 – 71 @version 3.7.0
With
When displaying the buttons on the frontend, the action key is assigned as a classname, so you can assign different CSS based on action key like this: