How to move the objects contained within another object?

So am working on this cart model wherein i drag and drop items into the shopping cart and now i need to move the cart along with the items present in it. The objects in the shopping cart don’t remain within the constraints of the cart while pushing it and remain in the same position after being dropped even after the cart is pushed.

I find two ways to solve your problem:

  1. Put all gameobjects which go in cart as childs of cart gameobject. Then, you only need to change cart transform.position and all object will move with it.

  2. Second is to have objects position at same as cart gameobject.

    foreach (int element in cart_elements)
    {
    element.transform.Position = cart.transform.Position;
    }