'title',
'id' => 'aisp_otools_other_section',
'title' => __( 'Other Tools', 'aisp-order-tools-for-woocommerce' ),
'desc' => __( 'Optional utilities that enhance WooCommerce usability and admin productivity.', 'aisp-order-tools-for-woocommerce' ),
],
[
'title' => __( 'Show product SKU on cart page', 'aisp-order-tools-for-woocommerce' ),
'desc' => __( 'Displays each product SKU directly below the item name on the cart page for easier reference.', 'aisp-order-tools-for-woocommerce' ),
'id' => 'aisp_otools_display_sku_cart',
'default' => 'no',
'type' => 'checkbox',
],
[
'title' => __( 'Add "Empty Cart" button', 'aisp-order-tools-for-woocommerce' ),
'desc' => __( 'Adds a quick-access button allowing customers to empty their entire cart in one click.', 'aisp-order-tools-for-woocommerce' ),
'id' => 'aisp_otools_clear_cart_button',
'default' => 'no',
'type' => 'checkbox',
],
[
'title' => __( 'Add company column', 'aisp-order-tools-for-woocommerce' ),
'desc' => __( 'Add company column in the WooCommerce admin order list and WordPress user list.
Add searchable field by company name and phone number in WordPress user list', 'aisp-order-tools-for-woocommerce' ),
'id' => 'aisp_otools_add_name_company',
'default' => 'no',
'type' => 'checkbox',
],
[
'title' => __( 'Sort users by registration date', 'aisp-order-tools-for-woocommerce' ),
'desc' => __( 'Automatically sorts the user list from newest to oldest registered. ', 'aisp-order-tools-for-woocommerce' ),
'id' => 'aisp_otools_sort_user',
'default' => 'no',
'type' => 'checkbox',
],
[
'title' => __( 'Show "View on Google Maps" on order page', 'aisp-order-tools-for-woocommerce' ),
'desc' => __( 'Displays a Google Maps link below the billing address in admin order pages.', 'aisp-order-tools-for-woocommerce' ),
'id' => 'aisp_otools_admin_maps_link',
'default' => 'no',
'type' => 'checkbox',
],
[
'title' => __( 'Show "View customer orders" button on user profile', 'aisp-order-tools-for-woocommerce' ),
'desc' => __( 'Adds a button in user profile page to quickly access all orders linked to that account', 'aisp-order-tools-for-woocommerce' ),
'id' => 'aisp_otools_customer_orders_button',
'default' => 'no',
'type' => 'checkbox',
],
[
'type' => 'sectionend',
'id' => 'aisp_otools_other_section',
],
];
return apply_filters( 'aisp_otools_other_tools_settings', $settings );
}
public static function enable_display_sku_cart() {
if ( 'yes' !== get_option( 'aisp_otools_display_sku_cart', 'no' ) ) {
return;
}
add_action( 'woocommerce_after_cart_item_name', function( $cart_item ) {
$product = $cart_item['data'];
if ( $product && $product->get_sku() ) {
echo '
📍 ' . esc_html__( 'View on Google Maps', 'aisp-order-tools-for-woocommerce' ) . '
'; } ); } public static function enable_sort_user_by_registration_date() { if ( 'yes' !== get_option( 'aisp_otools_sort_user', 'no' ) ) { return; } add_filter( 'manage_users_columns', function( $columns ) { $columns['registration_date'] = __( 'Registration date', 'aisp-order-tools-for-woocommerce' ); return $columns; } ); add_filter( 'manage_users_custom_column', function( $value, $column_name, $user_id ) { if ( 'registration_date' !== $column_name ) { return $value; } $user = get_userdata( $user_id ); if ( ! $user || empty( $user->user_registered ) ) { return '—'; } return date_i18n( get_option( 'date_format' ), strtotime( $user->user_registered ) ); }, 10, 3 ); add_filter( 'manage_users_sortable_columns', function( $columns ) { $columns['registration_date'] = 'registered'; return $columns; } ); add_filter( 'users_list_table_query_args', function( $args ) { if ( empty( $args['orderby'] ) ) { $args['orderby'] = 'registered'; $args['order'] = 'DESC'; } if ( isset( $args['orderby'] ) && 'registered' === $args['orderby'] ) { $args['orderby'] = 'user_registered'; } return $args; } ); } public static function enable_customer_orders_button() { if ( 'yes' !== get_option( 'aisp_otools_customer_orders_button', 'no' ) ) { return; } add_action( 'personal_options', function( $user ) { if ( ! current_user_can( 'manage_woocommerce' ) ) { return; } $user_id = (int) $user->ID; if ( ! $user_id ) { return; } $hpos_enabled = false; if ( class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) ) { $hpos_enabled = \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled(); } if ( $hpos_enabled ) { $orders_url = add_query_arg( [ 'page' => 'wc-orders', '_customer_user' => $user_id, 'orderby' => 'date', 'order' => 'desc', ], admin_url( 'admin.php' ) ); } else { $orders_url = add_query_arg( [ 'post_type' => 'shop_order', '_customer_user' => $user_id, 'orderby' => 'date', 'order' => 'desc', ], admin_url( 'edit.php' ) ); } $cache_key = 'aisp_order_count_' . $user_id; $order_count = wp_cache_get( $cache_key, 'aisp_otools' ); if ( false === $order_count ) { $query = wc_get_orders( [ 'customer_id' => $user_id, 'limit' => 1, 'return' => 'ids', 'paginate' => true, ] ); $order_count = isset( $query->total ) ? (int) $query->total : 0; wp_cache_set( $cache_key, $order_count, 'aisp_otools', 300 ); } $has_orders = $order_count > 0; $label = $has_orders /* translators: %d: number of orders */ ? sprintf( _n( 'View orders (%d)', 'View orders (%d)', $order_count, 'aisp-order-tools-for-woocommerce' ), $order_count ) : __( 'View orders (0)', 'aisp-order-tools-for-woocommerce' ); echo '