• Resolved Tommaso99

    (@tommaso99)


    Hello, I’m building a modal popup on add to cart click.
    Basically when the user clicks on Add to Cart, a popup will show up with the related products (upsells and cross sells).
    At the moment I’m doing that manually. I create a different popup in Elementor for every product with its related products.
    I would like to generate them automatically.
    Is there a function that I can call that returns the related products giving the product ID of the Add to cart link?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @tommaso99 ,

    This is an interesting idea.

    WooCommerce does have two functions available to display both upsell products and related products. They are added to your single product page using these hooks –

    add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
    add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );

    You can find the function definition of those in this file – \woocommerce\includes\wc-template-functions.php

    I hope this information helps.

    Thank you ??

    Hi there,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Thank you ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Function for related products’ is closed to new replies.