- General WC
- WC Bookings
Last active
October 27, 2019 20:50
-
-
Save krugazul/3910ccf53cfcc263049dc393196ca868 to your computer and use it in GitHub Desktop.
Disable the WooCommerce My Account logout confirmation endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Outputs the list of the sellers categories attached to their products | |
| * @param $seller WP_User() | |
| * @param $store_info | |
| */ | |
| function get_seller_categories( $seller, $store_info ) { | |
| $output = array(); | |
| $bookable_products = wc_get_products( array ( | |
| 'type' => 'booking', | |
| 'author' => $seller->get( 'id' ), | |
| ) ); | |
| if ( ! empty( $bookable_products ) ) { | |
| $ids = array(); | |
| /** | |
| * Run through the found products and grab their IDS | |
| * @var $bookable_product WC_Product_Booking() | |
| */ | |
| foreach ( $bookable_products as $bookable_product ) { | |
| $ids[] = $bookable_product->get_id(); | |
| } | |
| if ( ! empty( $ids ) ) { | |
| $categories = wp_get_object_terms( $ids, 'product_cat' ); | |
| if ( ! empty( $categories ) ) { | |
| /** | |
| * @var $category WP_Term() | |
| */ | |
| foreach ( $categories as $category ) { | |
| $output[] = '<a href="' . get_term_link( $category, 'product_cat' ) . '" title="' . $category->name . '">' . $category->name . '</a>'; | |
| } | |
| } | |
| } | |
| } | |
| //output the categories | |
| if ( ! empty( $output ) ) { | |
| echo implode( ', ', $output ); | |
| } | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Change the logout endpoint to a normal logout url | |
| * @param $url | |
| * @param $endpoint | |
| * @param $value | |
| * @param $permalink | |
| * | |
| * @return string | |
| */ | |
| function custom_account_menu_logout_url( $url, $endpoint, $value, $permalink ) { | |
| if ( 'customer-logout' === $endpoint ) { | |
| $url = wp_logout_url( home_url() ); | |
| } | |
| return $url; | |
| } | |
| add_filter( 'woocommerce_get_endpoint_url', 'custom_account_menu_logout_url', 20, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment