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 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. 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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.