How can I relate a FK back to the purchasable ID? First off, HUGE thank you to Lindsey for opening this door for me. Opened up a whole new layer!

I have (another) plugin that is listening to the commerce_orders.onOrderComplete event. My plugin inspects the order, and if a specific product was purchased, I capture that and save the pre-defined values in a custom table.

For example, if you buy "Product A", you get to pick two "Product B" options (these options are defined in commerce/CP).

I am able to create the custom table and save the correct values - so far so good.

However, I would like to relate not only the user back to the user account, but the "Product A" back to the purchasable.

Something like this:

MyPluginRecord.php

public function defineAttributes()
{
    return array(
        'id' =&gt; array(AttributeType::Number, 'default' =&gt; null),
        'packageId' =&gt; array(AttributeType::Number, 'default' =&gt; null),
        ...
    );
}


public function defineRelations()
{
    return array(
        'element' =&gt; array(static::BELONGS_TO, 'ElementRecord', 'id', 'required' =&gt; true, 'onDelete' =&gt; static::CASCADE),
        'package' =&gt; array(static::BELONGS_TO, '????', 'id', 'required' =&gt; true, 'onDelete' =&gt; static::CASCADE),
    );
}


I'm not sure how to get back to the commerce purchasable record?

Thank you for any suggestions!
Thanks Brad for breaking it down like that. It helped me take a step back and see what it was I was doing.

Here is the relationship I have that is working:

public function defineAttributes()
{
    return array(
        'id' =&gt; AttributeType::Number,
        'packageId' =&gt; AttributeType::Number,
        ...
    );
}


public function defineRelations()
{
    return array(
        'element' =&gt; array(static::BELONGS_TO, 'ElementRecord', 'id', 'required' =&gt; true, 'onDelete' =&gt; static::CASCADE),
        'package' =&gt; array(static::BELONGS_TO, 'Commerce_PurchasableRecord', 'onDelete' =&gt; static::CASCADE),
    );
}


Now I am able to have a relation to the user id element and back to my product package.