Skip to main content

Show product sales on front end

Hey all, I am selling memberships and would love to be able to show the current number of active memberships. It would also be useful in other scenarios to be able to show total products sold. Something like
Join [sub_sales_count id="<\>"] happy subscribers!

Is this possible?

Jesse Benjamin

Mike CameronΒ not sure if this is possible just with Fluent Cart, but I could recommend using FluentCRM with Cart to achieve your goal like so:

Set up tags and integrations for each of your memberships

First create a CRM tag for each of your memberships (e.g "[Subscription] Level 1", "[Subscription] Level 2", "[Subscription] Level 3", etc. Then set up an integration from the relevant subscription product for each membership (e.g apply tag on subscription start, remove tag on subscription end)

Make a custom block/shortcode to display the counts

You can then use PHP to get the number of contacts with the relevant tag. It could go something like so:

<?php
function get_contact_count_by_tag_id( $tag_id ) {
    if ( ! function_exists( 'FluentCrmApi' ) ) {
        return 0;
    }

    try {
        $contacts = FluentCrm\App\Models\Subscriber::filterByTags([$tag_id])->get();
        return count($contacts);

    } catch ( \Exception $e ) {
        error_log( 'FluentCRM Error: ' . $e->getMessage() );
        return 0;
    }
}

$tag_id_to_check = 2; 
$contact_count = get_contact_count_by_tag_id( $tag_id_to_check );

echo "Number of contacts with tag ID {$tag_id_to_check}: " . $contact_count;

By using FluentCRM, you'll also be able to easily send targeted emails to active subscribers for your memberships via the tags.

You'll also be able to see membership growth over time using the tag-wise reporting in FluentCRM.

Feel free to shoot me a community message here if you need some more help!

Mike Cameron

Jesse BenjaminΒ thank you for this. I guess my wondering is if we are going to query an api why not just query the FluentCart API directly so we can get the count of sold product as well as possibly total amount if we wanted it.

I haven't looked deep into the database structure or API but was wondering about creating a shortcode by querying the product

Can we do similar to what you propose but directly in FluentCart? I do have FluentCRM but it seems like a workaround we should not have to do.

I'll have a deeper look into your idea and get back to you. Thank you again so much