New Landing How can we help? Themeforest Theme Support Neighborhood Related Products based on attribute.

Viewing 10 posts - 1 through 10 (of 10 total)
  • #70642
    EdGunter
    Member
    Post count: 20

    Is there a way that I can change the related product section to only show items related to one specific attribute?

    I’ve taken a look in related.php but can’t see anything.

    Thanks.

    #70999
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please try to use given below code at functions.php under theme directory .

    function woo_related_products_attr() {
      global $product;
    $args = array(
        'post_type'             => 'product',
        'no_found_rows'         => 1,
        'posts_per_page'        => 6,
        'ignore_sticky_posts'   => 1,
        'orderby'               => $orderby,
        'post__in'              => $related,
        'post__not_in'          => array($product->id),
        'woocommerce_attributes' => 'attribute_slug',// please replace with color,size etc
    );
    return $args;
    }
    add_filter( 'woocommerce_related_products_args', 'woo_related_products_attr' );

    Hopefully that should work and let me know your feedback .

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #73259
    adotopanuga
    Member
    Post count: 25

    Hi,

    i need this feature too. I tried your code above but it did not work. Any suggestions on what could be wrong?

    #73333
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Have you changes ‘woocommerce_attributes’ => ‘attribute_slug’ to ‘woocommerce_attributes’ => ‘color’ or
    ‘woocommerce_attributes’ => ‘size’ .
    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #73533
    adotopanuga
    Member
    Post count: 25

    Hi Mohammad,

    Thank for responding, Yes i have but its still not working. How can i get this working?

    #73534
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Where are you putting this code ?
    Thanks

    #73536
    adotopanuga
    Member
    Post count: 25

    This is the code i put in my child’s theme functions.php (at the beginning of the file)

    function woo_related_products_attr() {
      global $product;
    $args = array(
        'post_type'             => 'product',
        'no_found_rows'         => 1,
        'posts_per_page'        => 8,
        'ignore_sticky_posts'   => 1,
        'orderby'               => $orderby,
        'post__in'              => $related,
        'post__not_in'          => array($product->id),
        'woocommerce_attributes' => 'colour',// please replace with color,size etc
    );
    return $args;
    }
    add_filter( 'woocommerce_related_products_args', 'woo_related_products_attr' );
    #73600
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please replace ‘woocommerce_attributes’ => ‘colour’, with ‘woocommerce_attributes’ => ‘color’, and check . It should work .

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #73819
    adotopanuga
    Member
    Post count: 25

    i did that but it did not work.

    any other solution

    #73924
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I do not have any solution beside it so please contact at woocommerce http://www.woothemes.com/support/ to get any possible solution .

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register