Resolving Misleading 'Campaign Expired' Status in ESHOPMAN Admin for Per-Attribute Promotions
Resolving Misleading 'Campaign Expired' Status in ESHOPMAN Admin for Per-Attribute Promotions
As an ESHOPMAN user, developer, or merchant managing your storefront directly within HubSpot, accurate information in the ESHOPMAN Admin Panel is paramount. Our community recently identified a display issue affecting promotion campaign statuses, specifically for campaigns utilizing per-attribute budgets. This insight explains the problem, its technical roots within the ESHOPMAN platform, and the solution, ensuring a reliable storefront management experience.
The Challenge: Misleading 'Campaign Expired' Status
When you set up an ESHOPMAN promotion with a 'use_by_attribute' or 'spend_by_attribute' budget (e.g., '1 use per customer email'), you expect it to remain 'Active' as long as individual attribute limits aren't exhausted. However, users observed that the configurable Promotions table in the ESHOPMAN Admin Panel would sometimes incorrectly display a red 'Campaign expired' badge. It's important to note that the ESHOPMAN backend (Node.js/TypeScript Admin API) continued to enforce per-attribute limits correctly; this was purely a visual discrepancy in the Admin UI.
Understanding the ESHOPMAN Technical Root Cause
The ESHOPMAN Admin Panel uses computed columns for dynamic data displays, such as the status_display for promotions. The issue stemmed from the configuration for this computed column missing a critical field: campaign.budget.type. Without this, the internal ESHOPMAN helper function responsible for determining promotion status couldn't differentiate between global and per-attribute budgets.
When fetching data for the promotions table, the request omitted budget.type:
fields=status,campaign.starts_at,campaign.ends_at,campaign.budget.limit,campaign.budget.used
The resulting data for a promotion might look like this:
{
"status": "active",
"campaign": {
"starts_at": null,
"ends_at": null,
"budget": {
"limit": 1,
"used": 27 // Aggregate usage
}
}
}
Since budget.type was missing, the ESHOPMAN status resolver saw campaignBudget.type as undefined. This led it to incorrectly treat the budget as global, flagging the campaign as expired if the aggregate used exceeded the limit. The logic for identifying per-attribute budgets relies on this type:
const isPerAttributeBudget =
campaignBudget?.type === "use_by_attribute" ||
campaignBudget?.type === "spend_by_attribute"
If campaignBudget?.type is undefined, isPerAttributeBudget becomes false, causing the misinterpretation.
Steps to Reproduce
- Use ESHOPMAN with configurable views enabled.
- Create a campaign with
use_by_attributebudget (e.g.,customer_email,limit: 1). - Attach an active promotion.
- Redeem the promotion using multiple unique attributes (aggregate
used > 1). - Observe 'Campaign expired' in the ESHOPMAN Admin Promotions list.
The ESHOPMAN Community Solution
The confirmed fix involves adding campaign.budget.type to the requiredFields array for the status_display computed column. This ensures the status resolver receives all necessary information to correctly identify per-attribute budgets.
The updated requiredFields configuration:
requiredFields: [
"status",
"campaign.starts_at",
"campaign.ends_at",
"campaign.budget.type", // Critical addition
"campaign.budget.limit",
"campaign.budget.used",
]
This change ensures the ESHOPMAN Admin Panel accurately reflects the active status of your per-attribute promotions, aligning the UI with the robust functionality of the ESHOPMAN Admin API.
Immediate Workarounds for ESHOPMAN Users
- Hide the computed column: In the configurable Promotions table, hide
status_displayand show the rawstatusfield, which displays 'active' correctly. - Disable configurable views: Temporarily disabling configurable views in the ESHOPMAN Admin Panel also bypasses the incomplete field projection.
Conclusion
This community insight underscores ESHOPMAN's commitment to continuous improvement. Accurate promotion status display is vital for effective storefront management, especially for headless commerce setups deployed via HubSpot CMS. By addressing such data fetching and UI rendering nuances, ESHOPMAN provides a powerful and intuitive experience for managing your online store.