$anchor, 'icon' => 'list-checks', 'title' => __( 'How quotes work on this shop', 'ai-eshop-optimizer' ), 'description' => __( 'Every setting that shapes a quote, wherever it lives, as it is now. Each line links to where it is changed.', 'ai-eshop-optimizer' ), ) ); echo $open; echo \Rooster\Admin\Ui::facts( self::facts(), array( 'columns' => 2 ) ); echo $close; } public static function facts() { $s = AIEO_Product_Request_Settings::get( true ); $display = self::url( 'product_requests_display' ); $notify = self::url( 'product_requests' ) . '#aieo-card-product-requests-notifications'; $line = static function ( $text, $url ) { return esc_html( $text ) . ' ' . esc_html__( 'Change', 'ai-eshop-optimizer' ) . ''; }; $facts = array(); $on = AIEO_Product_Request_Settings::frontend_is_active(); $facts[] = array( 'label' => __( 'Requests on the storefront', 'ai-eshop-optimizer' ), 'html' => $line( $on ? __( 'On: visitors can ask for a quote.', 'ai-eshop-optimizer' ) : __( 'Off: no request card shows anywhere.', 'ai-eshop-optimizer' ), $display . '#aieo-card-product-requests-display-front-end-gate' ), 'tone' => $on ? 'success' : 'warning', ); $types = AIEO_Product_Request_Settings::types(); $offered = array(); foreach ( AIEO_Product_Request_Settings::clean_types( $s['request_types'] ) as $type ) { $offered[] = $types[ $type ] ?? $type; } $facts[] = array( 'label' => __( 'What visitors can ask', 'ai-eshop-optimizer' ), 'html' => $line( implode( ', ', $offered ), $display . '#aieo-card-product-requests-display-front-end-gate' ), ); $rules = array( 'not_purchasable' => __( 'The product cannot be bought (no price, or not purchasable)', 'ai-eshop-optimizer' ), 'out_of_stock' => __( 'The product is out of stock', 'ai-eshop-optimizer' ), 'taxonomy' => __( 'The product is in one of the categories or brands below', 'ai-eshop-optimizer' ), 'always' => __( 'Always, on every product', 'ai-eshop-optimizer' ), ); $where = $rules[ (string) $s['display_rule'] ] ?? (string) $s['display_rule']; $where .= '. ' . ( AIEO_Product_Request_Settings::placement_is_automatic( $s ) ? __( 'Added to the product page for you.', 'ai-eshop-optimizer' ) : __( 'Only where you put a block or a shortcode.', 'ai-eshop-optimizer' ) ); $facts[] = array( 'label' => __( 'Where the request card shows', 'ai-eshop-optimizer' ), 'html' => $line( $where, $display . '#aieo-card-product-requests-display-front-end-gate' ), ); if ( class_exists( 'AIEO_Catalogue_Mode' ) ) { $cat = AIEO_Catalogue_Mode::settings(); $parts = array(); if ( $cat['disable_cart'] || $cat['hide_prices'] ) { $parts[] = $cat['disable_cart'] && $cat['hide_prices'] ? __( 'The whole shop: no prices, no add to cart.', 'ai-eshop-optimizer' ) : ( $cat['disable_cart'] ? __( 'The whole shop: no add to cart.', 'ai-eshop-optimizer' ) : __( 'The whole shop: no prices.', 'ai-eshop-optimizer' ) ); } if ( class_exists( 'AIEO_DMM_Catalogue_Mode' ) ) { $m = AIEO_DMM_Catalogue_Mode::marked(); if ( $m['categories'] || $m['catalogue'] ) { $parts[] = sprintf( __( '%1$d categories and %2$d products shown as a catalogue.', 'ai-eshop-optimizer' ), count( $m['categories'] ), count( $m['catalogue'] ) ); } } $facts[] = array( 'label' => __( 'Catalogue mode', 'ai-eshop-optimizer' ), 'html' => $line( $parts ? implode( ' ', $parts ) : __( 'Off: every product can be bought.', 'ai-eshop-optimizer' ), self::url( 'catalogue_mode' ) ), ); } $delay = max( 0, min( 1440, (int) $s['notify_delay_minutes'] ) ); $facts[] = array( 'label' => __( 'Before the staff are emailed', 'ai-eshop-optimizer' ), 'html' => $line( 0 === $delay ? __( 'No wait: the email goes at the first request, so what the visitor adds later is not in it.', 'ai-eshop-optimizer' ) : sprintf( _n( 'Collected for %d minute after the first request; the email lists everything added by then.', 'Collected for %d minutes after the first request; the email lists everything added by then.', $delay, 'ai-eshop-optimizer' ), $delay ), $notify ), 'tone' => 0 === $delay ? 'warning' : '', ); $to = class_exists( 'AIEO_Product_Request_Mailer' ) ? AIEO_Product_Request_Mailer::recipients( 'quote', $s ) : array( 'emails' => array() ); $who = array(); foreach ( (array) $to['emails'] as $email ) { $hours = class_exists( 'AIEO_Staff_Digest' ) ? AIEO_Staff_Digest::hours( $email ) : 0; $who[] = $hours > 0 ? sprintf( __( '%1$s (%2$s)', 'ai-eshop-optimizer' ), $email, AIEO_Staff_Digest::choices()[ (string) $hours ] ?? '' ) : $email; } $facts[] = array( 'label' => __( 'Who is emailed', 'ai-eshop-optimizer' ), 'html' => $line( $who ? implode( ', ', $who ) : __( 'Nobody: no address can be found.', 'ai-eshop-optimizer' ), $notify ), 'tone' => $who ? '' : 'warning', ); $ttl = max( 1, (int) $s['basket_ttl_hours'] ); $open = 'local' === (string) $s['basket_storage'] ? sprintf( __( '%1$d hours in the visitor\'s browser, %2$d hours at most on the server.', 'ai-eshop-optimizer' ), max( 1, (int) $s['basket_local_hours'] ), $ttl ) : sprintf( __( 'Until the visitor closes the browser, %d hours at most on the server.', 'ai-eshop-optimizer' ), $ttl ); $facts[] = array( 'label' => __( 'A quote stays open', 'ai-eshop-optimizer' ), 'html' => $line( $open, $display . '#aieo-card-product-requests-display-quote-basket' ), ); $finish = 'yes' === (string) $s['finish_enabled']; $facts[] = array( 'label' => __( '"Send my list"', 'ai-eshop-optimizer' ), 'html' => $line( $finish ? __( 'On: the visitor sends the list when done (the staff get it again, complete), and can start a new quote.', 'ai-eshop-optimizer' ) : __( 'Off: the visitor cannot send the list or start a new quote; it stays open until it expires (above).', 'ai-eshop-optimizer' ), $display . '#aieo-card-product-requests-display-quote-basket' ), 'tone' => $finish ? '' : 'warning', ); $facts[] = array( 'label' => __( 'Items in one quote', 'ai-eshop-optimizer' ), 'html' => $line( sprintf( __( 'At most %d.', 'ai-eshop-optimizer' ), (int) $s['max_items'] ), $display . '#aieo-card-product-requests-display-quote-basket' ), ); $ack = 'yes' === (string) $s['ack_enabled']; $facts[] = array( 'label' => __( 'The visitor\'s confirmation email', 'ai-eshop-optimizer' ), 'html' => $line( $ack ? __( 'On: sent at once, with what they asked about.', 'ai-eshop-optimizer' ) : __( 'Off: the visitor gets the message on the page only.', 'ai-eshop-optimizer' ), $notify ), ); return $facts; } private static function url( $tab ) { return add_query_arg( array( 'page' => class_exists( 'AIEO_DMM' ) ? AIEO_DMM::MENU_SLUG : 'ai-eshop-dmm', 'dmm_tab' => $tab ), admin_url( 'admin.php' ) ); } }