فهرست منبع

Neo: send the grid action name in pricing callbacks so free plans can be chosen (#5884)

The pricing element posted every callback action as a=buy with
ids[]=items.join(''). The ACL grid gives free levels a `choose` action
with no items and no redirect_url, so choosing a free plan threw on
items.join or did nothing. Post a=<action name> with the cart item, or
the grid row id from attr.bx_grid_action_data when there is none, and
redirect only when the action has a redirect_url.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Andrey Yasko 5 روز پیش
والد
کامیت
dca2709901
1فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 6 4
      neo/packages/app/components/elements/pricing.js

+ 6 - 4
neo/packages/app/components/elements/pricing.js

@@ -58,8 +58,8 @@ function ElementPricingPeriod({ data, period, unit, settings }) {
     const filtered = data.filter(item => item?.period?.value.unit === period.unit);
     const filtered = data.filter(item => item?.period?.value.unit === period.unit);
     const [showModal, setShowModal] = useState(false);
     const [showModal, setShowModal] = useState(false);
 
 
-    const fetchData = async (ids) => {
-        let sUrl = '/api.php?r=system/perfom_action_api/TemplServiceGrid/&params[]=&o=' + settings.object + '&a=buy&ids[]=' + ids;
+    const fetchData = async (action, ids) => {
+        let sUrl = '/api.php?r=system/perfom_action_api/TemplServiceGrid/&params[]=&o=' + settings.object + '&a=' + action + '&ids[]=' + ids;
         if (settings?.query_append)
         if (settings?.query_append)
             Object.keys(settings.query_append).forEach((sKey) => {
             Object.keys(settings.query_append).forEach((sKey) => {
                 sUrl += '&' + sKey + '=' + settings.query_append[sKey];
                 sUrl += '&' + sKey + '=' + settings.query_append[sKey];
@@ -75,8 +75,10 @@ function ElementPricingPeriod({ data, period, unit, settings }) {
         }
         }
 
 
         if (data.type == "callback") {
         if (data.type == "callback") {
-            fetchData(data.items.join(''));
-            redirectRef.current.redirect(data.redirect_url);
+            // `choose` (free level) posts the grid row id; `buy` posts its cart item.
+            const ids = data.items?.length ? data.items.join('') : data.attr?.bx_grid_action_data;
+            await fetchData(data.name || 'buy', ids);
+            if (data.redirect_url) redirectRef.current.redirect(data.redirect_url);
         }
         }
     }
     }