Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
4.0 kB
5
Indexable
Never
add_shortcode('marketking_store_link', function(){
    ob_start();
    if (!empty(get_query_var('vendorid'))){ 
        $store_url = get_query_var('vendorid');
        $users = get_users(array(
            'meta_key'     => 'marketking_store_url',
            'meta_value'   => $store_url,
            'meta_compare' => '=',
        ));
        if (!empty($users)){
            $vendor_id = $users[0]->ID;    
        }
    }
    if (!isset($vendor_id)){
        global $post;
        if (isset($post->ID)){
            $vendor_id = marketking()->get_product_vendor($post->ID);
        }
    }

    if (isset($vendor_id)){
        $store_link = marketking()->get_store_link($vendor_id);
        echo '<a href="'.esc_attr($store_link).'">'.$store_link.'</a>';
    }
    return ob_get_clean();
});
add_shortcode('marketking_product_vendor', function(){
    ob_start();
    if (!empty(get_query_var('vendorid'))){ 
        $store_url = get_query_var('vendorid');
        $users = get_users(array(
            'meta_key'     => 'marketking_store_url',
            'meta_value'   => $store_url,
            'meta_compare' => '=',
        ));
        if (!empty($users)){
            $vendor_id = $users[0]->ID;    
        }
    }
    if (!isset($vendor_id)){
        global $post;
        if (isset($post->ID)){
            $vendor_id = marketking()->get_product_vendor($post->ID);
        }
    }

    if (isset($vendor_id)){
        echo marketking()->get_store_name_display($vendor_id);
    }
    return ob_get_clean();
});
add_shortcode('marketking_vendor_rating', function(){
    ob_start();
    if (!empty(get_query_var('vendorid'))){ 
        $store_url = get_query_var('vendorid');
        $users = get_users(array(
            'meta_key'     => 'marketking_store_url',
            'meta_value'   => $store_url,
            'meta_compare' => '=',
        ));
        if (!empty($users)){
            $vendor_id = $users[0]->ID;    
        }
    }
    if (!isset($vendor_id)){
        global $post;
        if (isset($post->ID)){
            $vendor_id = marketking()->get_product_vendor($post->ID);
        }
    }

    if (isset($vendor_id)){
        $rating = marketking()->get_vendor_rating($vendor_id, 1);
        if (intval($rating['count'])!==0){
            echo '&nbsp;<strong>&nbsp;'.esc_html($rating['rating']).'</strong><span class="dashicons dashicons-star-filled marketking_product_other_offer_first_column_sold_by_star"></span>';
        }
    }
    return ob_get_clean();
});
add_shortcode('marketking_followers', function(){
    ob_start();
    if (!empty(get_query_var('vendorid'))){ 
        $store_url = get_query_var('vendorid');
        $users = get_users(array(
            'meta_key'     => 'marketking_store_url',
            'meta_value'   => $store_url,
            'meta_compare' => '=',
        ));
        if (!empty($users)){
            $vendor_id = $users[0]->ID;    
        }
    }
    if (!isset($vendor_id)){
        global $post;
        if (isset($post->ID)){
            $vendor_id = marketking()->get_product_vendor($post->ID);
        }
    }

    if (isset($vendor_id)){
        echo marketking()->get_number_of_followers($vendor_id);
    }
    return ob_get_clean();
});

add_shortcode('marketking_vendor_order_number', function(){
    ob_start();
    if (!empty(get_query_var('vendorid'))){ 
        $store_url = get_query_var('vendorid');
        $users = get_users(array(
            'meta_key'     => 'marketking_store_url',
            'meta_value'   => $store_url,
            'meta_compare' => '=',
        ));
        if (!empty($users)){
            $vendor_id = $users[0]->ID;    
        }
    }
    if (!isset($vendor_id)){
        global $post;
        if (isset($post->ID)){
            $vendor_id = marketking()->get_product_vendor($post->ID);
        }
    }

    if (isset($vendor_id)){
        echo marketking()->get_vendor_order_number($vendor_id);
    }
    return ob_get_clean();
});
Leave a Comment