diff --git a/discount/init.py b/discount/init.py index 7b819e6..49001e5 100644 --- a/discount/init.py +++ b/discount/init.py @@ -741,12 +741,12 @@ async def get_discount_setting_products(request): env = request._run_ns # Try multiple ways to get discountid from URL query params discountid = '' - if hasattr(request, 'rel_url') and request.rel_url: + if hasattr(request, '_run_env') and hasattr(request._run_env, 'param_kw'): + discountid = (request._run_env.param_kw or {}).get('discountid', '') + if not discountid and hasattr(request, 'rel_url') and request.rel_url: discountid = request.rel_url.query.get('discountid', '') if not discountid and hasattr(request, 'query'): discountid = request.query.get('discountid', '') - if not discountid: - discountid = (getattr(request, '_params_kw', {}) or {}).get('discountid', '') user_orgid = await env.get_userorgid() if not discountid or not user_orgid: