Accessing values from another script

I have an interface as follows:

public interface IPurchaseable
{
    string myItemName();
    float myItemPrice();
}

I then have other GameObjects which are items. Each GameObject has a script that implements the interface and they are similar to the one below:

public class AppleItem : MonoBehaviour, IPurchaseable
{
    [SerializeField] private string itemName = "Apple";
    [SerializeField] private float price = 5.1f;

    public string myItemName()
    {
        return itemName;
    }
    public float myItemPrice()
    {
        return price;
    }
}

I then added a cube to my scene which acts as a trigger area and it has the following script:

public class CashierReader : MonoBehaviour
{
    void OnTriggerEnter(Collider product)
    {
        Debug.Log("You placed an item in the cashier");
    }
}

I would like to find a way to read the name or price of the item being placed in the trigger area so that maybe I can display it in the log or store it somewhere else.

Rewrite your CashierReader like this:

public class CashierReader : MonoBehaviour
{
	void OnTriggerEnter(Collider product)
	{
		IPurchaseable item = product.GetComponent<IPurchaseable>();
		
		if (item!=null)
		{
			Debug.Log(item.myItemName());
			Debug.Log(item.myItemPrice());
		}
	}
}