0

Please help . I need to add class to this button if user is not logged in

<?php echo apply_filters( 'my_order_html', '<button type="submit" class="ADD-CLASS-HERE cfw-primary-btn cfw-next-tab validate" name="my_list_html" id="place_order" formnovalidate="formnovalidate" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '"><span class="cfw-button-text">' . esc_html( $order_button_text ) . '</span></button>' ); // @codingStandardsIgnoreLine ?>
4
  • where is that code? WooCommerce dev support questions are offtopic here and not in this stacks scope, you should ask this in a WooCommerce community or via their official support routes
    – Tom J Nowell
    Commented Apr 21, 2022 at 12:55
  • its not woocommerce question Commented Apr 21, 2022 at 13:00
  • I just need to add class to a button if user not logged in Commented Apr 21, 2022 at 13:01
  • it's part of a WooCommerce filter, you edited out woocommerce_order_button_html etc, you can see it in the edit history. I'd suggest looking up filters and hooks as you may need to use them depending on where the code is located, but it's still a WooCommerce question, you should ask WooCommerce users how to modify a button in a WooCommerce filter.
    – Tom J Nowell
    Commented Apr 21, 2022 at 13:10

1 Answer 1

0

You can try something like this and implement it in your own case

<?php
if ( is_user_logged_in() ) {
   $extraClass = "hide-button";
} else {
   $extraClass = "";
}
?>

<a class="<?php echo $extraClass;? href="#">">Button text</a>

and give the new class a styling like "display: none;" or something

1
  • Thank you very much @Richardo Commented Apr 21, 2022 at 13:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.