How to add custom post type “package” as object in rates (no woocommerce)

Hello,
We have purchased Affiliates Pro and are using it on a client site that does not use WooCommerce.
Instead, we have a custom post type called “package”.
Our goal:
We want to assign affiliate rates to individual packages and have them appear in the “Object” column in the Rates section.
However, the “package” post type does not appear as a selectable object when creating or editing a rate.
What we have tried:
We added these filters to our theme’s functions.php:

add_filter(‘affiliates_supported_post_types’, function($post_types) {
$post_types[] = ‘package’;
return array_unique($post_types);
});

add_filter(‘affiliates_integrations’, function($integrations) {
$integrations[’package’] = array(
‘label’ => ‘Custom Package’,
‘post_type’ => ‘package’
);
return $integrations;
});

But the “package” post type still does not appear in the Object dropdown.
Question:
How can we make our custom post type (“package”) selectable as an Object when creating/editing a rate in Affiliates Pro?
Is there a filter, hook, or recommended method for this?
Thank you for your help!


Comments

5 responses to “How to add custom post type “package” as object in rates (no woocommerce)”

  1. George Avatar
    George

    Hi James, you’re welcome!

    Perhaps my first response wasn’t descriptive enough and I should apologize for that.
    The object id and term id that appear as selections for a new rate, relate to their respective integration. If the integration doesn’t exist( or isn’t installed, or is deactivated), then the object id field cannot populate because it is directly related to an integration.
    The role of an integration is to track a referred action and then Affiliates Pro finds the applicable rate and records a referral. Apart from that, it declares any custom post types or taxonomies that can be used for rates related to this integration.

    Let’s assume that you could include your custom post type “package” into rates as an object. This would be pointless because the rate using that object id would never apply, for the reason I mentioned earlier, because there’s no applicable integration that can track this referred action.
    Hope it helps.

    Kind regards,
    George

  2. James Nyachhyon Avatar
    James Nyachhyon

    Hi! I had asked about how to add our custom post type “package” in Rates, but the response mainly focused on modifying the plugin core and tracking referrals, which isn’t exactly what we were asking.

    We’re specifically looking for a way to include our custom post type “package” as an object in the Rates section — not how to record referrals programmatically in backend CMS. Could you please look into this and let us know if there’s a proper way to achieve it?

    Thank you!

  3. George Avatar
    George

    Hey James,

    Thank you for the details.
    What you’re missing here is the way to record referrals and this can be done using the evaluate() method as described here – https://docs.itthinx.com/document/affiliates-pro/api/referrals/. You can also check the example provided and if further details are needed, please let me know.

    What’s important in this method is the $amount argument that will have the commission amount you wish to grant to your referring affiliate. This can be calculated as follows:

    $amount = bcmul( $referral_rate, $transaction_amount, affiliates_get_referral_amount_decimals() );

    The $referral_rate will be the rate you wish to grant for the specific package purchased in this transaction and since you’d like to differentiate that, you can ie define an array of package_id => rate for each package. The $transaction_amount can be the package unit price * units purchased or the total transaction amount, whatever suits best your requirements. Finally, the affiliates_get_referral_amount_decimals() will adjust the amount of decimals used in the Affiliates system, which is by default 2. In this case the $base_amount can be null and the commission granted will be the $amount argument.

    Last but not least, make sure to call the method once you have confirmed your transaction. This way you will have a referral recorded for each confirmed purchase that has been referred on your site.

    Kind regards,
    George

  4. George Avatar
    George

    Hi there,

    Welcome to our support channel for Affiliates Pro and its addons.

    In order for a post_type to appear in the select list of Objects, additional implementations are needed in the plugin core, which include an integration with Affiliates Pro.
    However, before reaching that point, would you mind sharing additional details with us regarding your decision? What is the purpose of adding your custom post_type in Rates? Also, since the rate and its options are the way that the system decides whether a specific rate should apply for a referral, what is the action that will record the referral?

    The referral-related integrations found in Affiliates > Settings > Integrations(tab) are designed to track specific referred-user actions and record referrals. For example, the Affiliates WooCommerce integration tracks WC sales and grants a commission when a sale is referred by a valid affiliate. In a similar way, the Affiliates Ninja Forms integration will track form submissions and grant commissions.

    In your case, what is the action that should be tracked and grant a commission to the applicable affiliate?

    Apologies for all these questions, but the important point here is to figure out first how and when should a referral be recorded and then figure out, how can the custom post_type appear in Rates.

    Kind regards,
    George

    1. James Nyachhyon Avatar
      James Nyachhyon

      Hi George,

      Thank you for your detailed response.

      We’re using a custom post type called “package” to represent individual offerings on our client’s website. These packages are purchased directly through an external banking integration, not via WooCommerce.

      Our goal is to assign affiliate rates to specific packages. Once a user successfully completes the payment through the bank (via a callback or payment confirmation webhook), we manually record the referral using the Affiliates API. At that point, the affiliate should receive the commission — but only for the package that was purchased.

      To manage this cleanly and transparently, we would like the ability to associate individual packages with specific rates in the “Rates” section of Affiliates Pro — just as WooCommerce products can be associated. This will allow us to define different commission rates based on the package being purchased.

      We understand that deeper integration might be needed to show our post type in the Rates > Object dropdown. If there is a recommended way to extend this (e.g., via filters or a custom integration class), we’re happy to follow best practices.

      Please let us know how we should proceed to achieve this.