Example #1
0
    function widget($args, $instance)
    {
        if (get_integration_type() != 'simple') {
            if (is_plural_form_active()) {
                $names = get_catalog_names();
                $label = sprintf(__('%s Search', 'ecommerce-product-catalog'), ic_ucfirst($names['singular']));
            } else {
                $label = __('Product Search', 'ecommerce-product-catalog');
            }
            $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
            echo $args['before_widget'];
            if ($title) {
                echo $args['before_title'] . $title . $args['after_title'];
            }
            // Use current theme search form if it exists
            $search_button_text = apply_filters('product_search_button_text', '');
            echo '<form role="search" class="' . design_schemes('box', 0) . '" method="get" id="product_search_form" action="' . esc_url(home_url('/')) . '">
<input type="hidden" name="post_type" value="' . get_current_screen_post_type() . '" />
<input class="product-search-box" type="search" value="' . get_search_query() . '" id="s" name="s" placeholder="' . $label . '" />
<input class="product-search-submit" type="submit" id="searchsubmit" value="' . $search_button_text . '" />
</form>';
            echo $args['after_widget'];
        }
    }
Example #2
0
/**
 * Returns realted products
 *
 * @global object $post
 * @param int $products_limit
 * @param boolean $markup
 * @return string
 */
function get_related_products($products_limit = null, $markup = false)
{
    if (!isset($products_limit)) {
        $products_limit = get_current_per_row();
    }
    $current_product_id = get_the_ID();
    $taxonomy = get_current_screen_tax();
    $post_type = get_current_screen_post_type();
    $terms = get_the_terms($current_product_id, $taxonomy);
    if (is_array($terms) && !empty($taxonomy) && !empty($post_type)) {
        $terms = array_reverse($terms);
        $archive_template = get_product_listing_template();
        $i = 0;
        $inside = '';
        $products = array();
        foreach ($terms as $term) {
            $query_param = array('post_type' => $post_type, 'tax_query' => array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $term->slug)), 'posts_per_page' => $products_limit);
            $query = new WP_Query($query_param);
            while ($query->have_posts()) {
                $query->the_post();
                global $post;
                if ($current_product_id != $post->ID) {
                    $i++;
                    $products[] = $post->ID;
                }
                if ($i >= $products_limit) {
                    break;
                }
            }
            wp_reset_postdata();
            reset_row_class();
            if ($i >= $products_limit) {
                break;
            }
        }
        $div = '';
        if (!empty($products)) {
            $products = implode(',', $products);
            if ($markup) {
                $div = '<div class="related-products">';
                $single_names = get_single_names();
                if (!empty($single_names['other_categories'])) {
                    $div .= '<h2 class="catalog-header">' . $single_names['other_categories'] . '</h2>';
                }
                $div .= do_shortcode('[show_products product="' . $products . '"]');
                $div .= '</div>';
            } else {
                $div = do_shortcode('[show_products product="' . $products . '"]');
            }
        }
        return $div;
    }
    return;
}
Example #3
0
/**
 * Shows product search form
 */
function product_search_form()
{
    $search_button_text = __('Search', 'ecommerce-product-catalog');
    echo '<form role="search" method="get" class="search-form product_search_form" action="' . esc_url(home_url('/')) . '">
<input type="hidden" name="post_type" value="' . get_current_screen_post_type() . '" />
<input class="product-search-box" type="search" value="' . get_search_query() . '" id="s" name="s" placeholder="' . __('Product Search', 'ecommerce-product-catalog') . '" />
<input class="search-submit product-search-submit" type="submit" value="' . $search_button_text . '" />
</form>';
}