Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow search on Order ID in CMS #2001

Closed
oadslug opened this issue Feb 14, 2021 · 12 comments
Closed

Allow search on Order ID in CMS #2001

oadslug opened this issue Feb 14, 2021 · 12 comments
Labels
💡 enhancement Ideas and suggestions ℹ️ status: need more info When waiting for user to supply database or more information.

Comments

@oadslug
Copy link

oadslug commented Feb 14, 2021

Currently it is only possible to use the reference number or the short reference number to search for orders within the CMS. Please consider adding the ability to search orders using Order ID (aka Entity ID). My client currently uses the Order ID as the invoice number (as I assume many others do as well), and cannot easily find orders without cross referencing them to ref number, or email address.

(It would be nice if this were implemented throughout Craft for all entities, but that is a separate issue.)

@oadslug oadslug added New 💡 enhancement Ideas and suggestions labels Feb 14, 2021
@lukeholder lukeholder added ℹ️ status: need more info When waiting for user to supply database or more information. and removed New labels Feb 15, 2021
@lukeholder
Copy link
Member

@oadslug Could you add the order ID to the order reference format? the reference is searchable.

@oadslug
Copy link
Author

oadslug commented Feb 16, 2021

@lukeholder I'm not sure I understand the question Luke. Can you clarify? (Then again I haven't finished my coffee yet—might make sense in an hour or so ;) Currently the client tries to enter their 'Invoice Number' (which is set to the 'Order ID') in the search field in the CMS, and does not get any results.

@peteeveleigh
Copy link
Contributor

@oadslug Orders have IDs (which is basically the Craft element ID and thus not sequential) as well as an Order Reference (which can be made sequential).

Commerce lets you specify the format for your Order Reference under Commerce->System Settings->General Settings.

It's possible to use Twig in the format so what Luke is suggesting is including the Order ID in that reference as it is already searchable.

So you could have the reference format as something like {{object.id}}/{{number[:7]}}

@oadslug
Copy link
Author

oadslug commented Feb 18, 2021

@fantasticmachine Understood. Thank you. Much appreciated. When I first set up the commerce site that functionality did not exist, so not the first thing I think of. Thanks again.

@shaunmolloy
Copy link

shaunmolloy commented May 6, 2021

@lukeholder I came across this when looking at why I couldn't search by the
order id field. Then dug into the order element.

protected static function defineSearchableAttributes(): array
{
return [
'billingFirstName',
'billingLastName',
'billingFullName',
'billingPhone',
'email',
'number',
'shippingFirstName',
'shippingLastName',
'shippingFullName',
'shippingPhone',
'shortNumber',
'transactionReference',
'username',
'reference',
'skus',
];
}

Is there a good reason why id is excluded? It'd be handy to have it
and looks to be a simple enough change if you want me to create a PR?

@lukeholder
Copy link
Member

@shaunmolloy What is the use-case for searching by ID? Isn't the order reference enough? You can always put the ID into the reference.

@lukeholder
Copy link
Member

This will be solved in Craft 4 when we add the element index condition builder

@shaunmolloy
Copy link

@shaunmolloy What is the use-case for searching by ID? Isn't the order reference enough? You can always put the ID into the reference.

I'd be happy to do that on a new site, but I wouldn't fancy chancing
changing the reference on a live site 😅

This will be solved in Craft 4 when we add the element index condition builder

Great stuff. Is there a date in mind for when v4 be stable? Is there a roadmap?

@lukeholder
Copy link
Member

You can track the feature here: craftcms/cms#1630

If you want to add it for your site you can use the Element::EVENT_REGISTER_SEARCHABLE_ATTRIBUTES event to add the ID, but remember you will need to re-save all order elements to add the ID to the search index.

My guess is you are trying to find the order by ID as a developer, and store administrators are not really needing to search by ID. Is that the case?

@lukeholder
Copy link
Member

Another reference: craftcms/cms#7062

@shaunmolloy
Copy link

For the site in mind, the order id is passed to a finance gateway and
referenced in order emails, so it may not be the best idea for us to
change that now to short reference.

My guess is you are trying to find the order by ID as a developer, and store administrators are not really needing to search by ID. Is that the case?

It's easy for us devs to find orders as we can just place the id in the
URL like mentioned in craftcms/cms#7062 (comment).

The client on the other hand can have a hard time finding orders,
so I prepared a list of searchable fields to help them.

When doing this I found that for products you can only search by
sku and for customers it works differently so you cannot use field
types in the search.

If you want to add it for your site you can use the Element::EVENT_REGISTER_SEARCHABLE_ATTRIBUTES event to add the ID, but remember you will need to re-save all order elements to add the ID to the search index.

Thanks! I've took a note of that in a task.

I've just seen the milestone in Github for v4.

@lukeholder
Copy link
Member

Thanks. Closing this here for now. please follow craftcms/cms#7062

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 enhancement Ideas and suggestions ℹ️ status: need more info When waiting for user to supply database or more information.
Projects
None yet
Development

No branches or pull requests

4 participants