How to make the price of one product vary depending on another

Hi :grinning:

I’ve been trying these days to find a code that allows me to connect two products, since on my page I put a product on the cart page (Product A) that works as cross-selling, but the price of this is static, and I need that It varies depending on the quantity that my clients want to buy of another specific product (Product B). That is, the quantity of product B (which is what my client wants to buy) is the same as product A (which is just a cross-selling on the cart page). For example, if my client wants to buy 5 products B, this quantity must be connected to the quantity of product A (which just in case is anchored to the cart page) not necessarily with the intention of buying, just that it is the same quantity.

Thank you!