Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3062028
Frequently Bought Together bulk add
Closed

Comments

  • Austin started the conversation

    Hi, is it possible to add a single item to products in bulk? We have about 600 E-Bikes in our Shop, and we would like to add the same bike lock to each of the 600 E-Bikes as a frequently bought together option. Doing this one at a time would really suck. Is it possible to add in bulk? We use WP All-Import for bulk imports. Is there a way we could use the import function to add the bike lock to all of the E-Bikes?

  •  767
    Janilyn replied

    Hi Austin,

    Thank you for contacting WPClever Support Forum. 

    We’ve received your ticket and assigned one of our developers to help you with that. 

    He’ll be looking into your question and responding with specific instructions as soon as possible. 

    Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back.

    Best regards.

    Janilyn T. - WPClever Support Agent

  •  1,222
    Dustin replied

    Hi Austin,

    Please add the below custom code (How to add custom code?)

    add_filter( 'woobt_show_items', 'your_woobt_show_items', 99, 2 );
    function your_woobt_show_items( $items, $product_id ) {
        if ( $product_id != 2629 ) {
            $items[] = 2629;
        }
        return $items;
    }

    2629 is an example product ID https://www.screencast.com/t/vIpVzA0qCj that you want to add, so you can change it to another ID.

    Best regards,
    Dustin

  • Austin replied

    Hi Dustin,

    Thanks for the code! That worked perfectly. Would it be possible to make it category specific as well? For example, in the future if we only want it to show on products in specific categories like "mountain bikes" or something like that.

    Also, is there code we can add that will give us the same "above text" for each product as well? That way each product will also say "These items are frequently bought together." Thanks for your help!

  •  1,222
    Dustin replied

    #1. Please try the updated snippet:

    add_filter( 'woobt_show_items', 'your_woobt_show_items', 99, 2 );
    function your_woobt_show_items( $items, $product_id ) {
        if ( has_term( 'mountain-bikes', 'product_cat', $product_id ) && ( $product_id != 2629 ) ) {
            $items[] = 2629;
        }
        if ( has_term( 'city-bikes', 'product_cat', $product_id ) && ( $product_id != 1234 ) ) {
            $items[] = 1234;
        }
        return $items;
    }

    'mountain-bikes' or 'city-bikes' is the category slug, you can find them here https://www.screencast.com/t/ZUZIpdoD

    #2. In the new version, you can set the default above/under text here https://www.screencast.com/t/jPZZXD0gkPG

    Best regards,
    Dustin