WordPress.org

Ready to get started?Download WordPress

Forums

WP e-Commerce Related Products
[resolved] Displaying unrelated products when related products are not available (3 posts)

  1. babyhuey48089
    Member
    Posted 1 year ago #

    When no related product is available, the plugin is displaying random products. I need to find a way for it to display nothing if there is no related products. I relate products by tag. Help would be greatly appreciated.

    http://wordpress.org/extend/plugins/wpec-related-products/

  2. Onnay Okheng
    Member
    Plugin Author

    Posted 1 year ago #

    Hola,

    Yes, if product doesn't has any related product, this plugin will show random products. But if you want remove random products, modify "wpec-related-product.php"

    found this:

    if(!$related_product->have_posts()){
    
                     $query = array (
                        'showposts' => $number,
                        'orderby'   => 'rand',
                        'post_type' => 'wpsc-product',
                        'post__not_in' => array ($post->ID),
                    );
                    $related_product = new WP_Query($query);
                }

    change with this:

    if(!$related_product->have_posts()){
    
                     return;
    
                }

    Cheers!

  3. babyhuey48089
    Member
    Posted 1 year ago #

    Excellent! Worked perfectly! Thanks very much!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic