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

Okay
  Public Ticket #3833668
Query
Open

Comments

  •  16
    Chun Lee started the conversation

    Hi,

    I try to use a repeater to display upsell product on single product page, could you please let me know if that possible display upsell product or cross sell prodcut via query setting?

  •  1,355
    Dustin replied

    Hi Chun,

    You can try the code like this:

    $upsell_ids = $product->get_upsell_ids(); // our plugin already filtered  to get correct products here
    
    foreach ( $upsell_ids as $upsell_id ) {
    	$upsell_product = wc_get_product( $upsell_id );
    
    	// Do your stuff here
    }

    Best regards,
    Dustin

  •  16
    Chun Lee replied

    Hi Dustin,

    $upsell_ids = $product->get_upsell_ids(); // our plugin already filtered  to get correct products here

    Sorry, I can't understand it. 

    If it's already filtered,  I put it direclty in wp query, as screenshot. why there's no result?

    POST_IN = $upsell_ids


    or I shoud put this in a snippet code 

    $upsell_ids = $product->get_upsell_ids(); // our plugin already filtered  to get correct products here
    foreach ( $upsell_ids as $upsell_id ) {
        $upsell_product = wc_get_product( $upsell_id );
        // Do your stuff here
    }

    then using wp query?



    Attached files:  9.PNG