0 ? $id : (int) AIEO_Table_Columns::value( $row, 'product_id', 0 ); return $id > 0 ? '/?p=' . $id : ''; }; $aieo_ff_no_cart = class_exists( 'AIEO_Catalogue_Mode' ) && AIEO_Catalogue_Mode::cart_off(); if ( $aieo_ff_no_cart ) { $aieo_ff_request = (string) AIEO_Catalogue_Mode::request_label(); $aieo_ff_action = '' === $aieo_ff_request ? array() : array( array( 'key' => 'product_id', 'label' => $aieo_ff_request, 'type' => 'link', 'format' => array( 'href' => static function ( $row ) use ( $aieo_ff_product_url ) { $url = (string) $aieo_ff_product_url( $row ); return '' === $url ? '' : $url . AIEO_Catalogue_Mode::REQUEST_ANCHOR; }, 'text' => $aieo_ff_request, 'class' => 'aieo-c-btn aieo-c-btn--sm aieo-catalogue-request', ), 'width' => '170px', 'sortable' => false, ), ); } else { $aieo_ff_action = array( array( 'key' => 'product_id', 'label' => '', 'sr_label' => __( 'Product ID', 'ai-eshop-optimizer' ), 'type' => 'text', 'hidden' => true, 'sortable' => false, ), array( 'key' => 'stock', 'label' => __( 'Add to cart', 'ai-eshop-optimizer' ), 'type' => 'link', 'format' => array( 'href' => static function ( $row ) { $stock = AIEO_Table_Columns::value( $row, 'stock', null ); $id = (int) AIEO_Table_Columns::value( $row, 'product_id', 0 ); if ( null === $stock || (float) $stock <= 0 || $id <= 0 ) { return ''; } if ( class_exists( 'AIEO_Catalogue_Mode' ) && AIEO_Catalogue_Mode::any_marks() ) { $parent = (int) AIEO_Table_Columns::value( $row, 'parent_id', 0 ); if ( AIEO_Catalogue_Mode::cart_off( $parent > 0 ? $parent : $id ) ) { return ''; } } return '?add-to-cart=' . $id; }, 'text' => __( 'Buy', 'ai-eshop-optimizer' ), 'class' => 'aieo-c-btn aieo-c-btn--sm aieo-c-btn--primary add_to_cart_button ajax_add_to_cart', 'attrs' => static function ( $row ) { return array( 'data-product_id' => (int) AIEO_Table_Columns::value( $row, 'product_id', 0 ), 'data-quantity' => 1, ); }, ), 'width' => '150px', 'sortable' => false, ), ); } return array( 'id' => 'fast_finder', 'label' => __( 'Fast Finder', 'ai-eshop-optimizer' ), 'description' => __( 'Every published product with its brand, sections and professional discount, searchable and filterable.', 'ai-eshop-optimizer' ), 'source' => 'table', 'table' => '{prefix}aieo_core_product_vitals', 'base_where' => 'status = 1', 'registry_id' => 'fast_finder.storefront_product_finder', 'scope' => 'local', 'version' => '1', 'per_page' => 10, 'default_sort' => array( 'name', 'asc' ), 'empty_state' => __( 'No products match. Clear a filter or two and try again.', 'ai-eshop-optimizer' ), 'columns' => array_merge( array( array( 'key' => 'product_url', 'label' => '', 'sr_label' => __( 'Product page', 'ai-eshop-optimizer' ), 'type' => 'text', 'hidden' => true, 'sortable' => false, ), array( 'key' => 'parent_id', 'label' => '', 'sr_label' => __( 'Parent ID', 'ai-eshop-optimizer' ), 'type' => 'text', 'hidden' => true, 'sortable' => false, ), array( 'key' => 'image_url', 'label' => '', 'sr_label' => __( 'Product image', 'ai-eshop-optimizer' ), 'type' => 'image', 'format' => array( 'size' => 72, 'rehost' => true, 'href' => $aieo_ff_product_url, ), 'width' => '88px', 'sortable' => false, ), array( 'key' => 'name', 'label' => __( 'Item', 'ai-eshop-optimizer' ), 'type' => 'link', 'format' => array( 'href' => $aieo_ff_product_url ), 'sortable' => true, 'searchable' => true, ), array( 'key' => 'brand_id', 'label' => '', 'sr_label' => __( 'Brand ID', 'ai-eshop-optimizer' ), 'type' => 'text', 'hidden' => true, 'sortable' => false, ), array( 'key' => 'brand', 'label' => __( 'Brand', 'ai-eshop-optimizer' ), 'type' => 'link', 'format' => array( 'href' => static function ( $row ) { $id = (int) AIEO_Table_Columns::value( $row, 'brand_id', 0 ); if ( $id <= 0 || ! taxonomy_exists( 'product_brand' ) ) { return ''; } $url = get_term_link( $id, 'product_brand' ); return is_wp_error( $url ) ? '' : (string) $url; }, ), 'width' => '140px', 'sortable' => true, 'searchable' => true, 'filter' => 'multiselect', ), array( 'key' => 'menu_category', 'label' => __( 'Section', 'ai-eshop-optimizer' ), 'hidden' => true, 'type' => 'text', 'width' => '150px', 'sortable' => true, 'filter' => 'multiselect', ), array( 'key' => 'head_category', 'label' => __( 'Product groups', 'ai-eshop-optimizer' ), 'hidden' => true, 'type' => 'text', 'width' => '150px', 'sortable' => true, 'filter' => 'multiselect', ), array( 'key' => 'sub_category', 'label' => __( 'Categories', 'ai-eshop-optimizer' ), 'hidden' => true, 'type' => 'text', 'width' => '150px', 'sortable' => true, 'filter' => 'multiselect', ), array( 'key' => 'profdiscount', 'label' => __( 'Professional discount', 'ai-eshop-optimizer' ), 'type' => 'text', 'width' => '120px', 'sortable' => true, 'filter' => 'select', ), ), $aieo_ff_action ), );