feat: customers see an order code, not the sequential number
Some checks failed
Some checks failed
"Minha conta" lists and opens orders as "Pedido 1E867B56" (the first 8 characters of the order's id) and searches by that code, so a customer never sees how many orders the store has. The Kanban shows the code beside the # number, with a copy button, and its search finds an order by the code a customer reads out. Tiny keeps its reference (DTF-<number>): it is how a resent order is found there instead of duplicated, and the WhatsApp notices the client sends from Tiny use Tiny's own number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -301,6 +301,11 @@ def search(q: str = Query(min_length=2, max_length=100), user=Depends(operator))
|
||||
if digits and len(digits) <= 9:
|
||||
sql += ' OR number=%s'
|
||||
params.append(int(digits))
|
||||
# The code a customer reads out (the id's first characters, see order_code).
|
||||
code = q.strip().lstrip('#').lower()
|
||||
if 6 <= len(code) <= 12 and re.fullmatch(r'[0-9a-f]+', code):
|
||||
sql += " OR replace(id::text,'-','') LIKE %s"
|
||||
params.append(code + '%')
|
||||
quote_match, quote_params = customer_match('q.draft', q)
|
||||
with db.connect() as c:
|
||||
orders = c.execute(f'''SELECT * FROM dtf_local.orders WHERE {sql}
|
||||
|
||||
Reference in New Issue
Block a user