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

Query the orders related to a customer? #94

Open
Darpan-laravel opened this issue Oct 26, 2022 · 1 comment
Open

Query the orders related to a customer? #94

Darpan-laravel opened this issue Oct 26, 2022 · 1 comment

Comments

@Darpan-laravel
Copy link

Darpan-laravel commented Oct 26, 2022

Hi, I was trying to query orders related to a specific customer. But what I have found is that, in order fields received through order api, in the billing section under it, there is an email field under billing which matches with the email field of the customer fields received through customer api and THIS IS THE ONLY LINK. There is a 'customer_id' field in the order params but most of the times it is 0 (I believe 0 is for guests in WooCommerce?). [Moreover, the billing field you get is in the format (in order api),
[
{
"id": 7337, //order_id
"billing": {
"email": "cuccagna@gmail.com",
},
}
]

So, I am trying the below query on the basis of the results I got,
(I am using the data received through api directly, not saving those in database)

$customeremail = $request->email;
$order_of_the_customer = order:where('to->billing->email', $customeremail)->get();
Or,
$order_of_the_customer = order::whereJsonContains('to', [['billing' => ['email' => $customeremail ]]])->get();

But NONE OF THESE WORKS!!. Can someone help me? Seems like no queries using where condition is working.. (even simple queries, it always results in all the results (which is 10 per page)) (only order::find($id) works efficiently)

@Darpan-laravel
Copy link
Author

Anyone here has found any way to fetch the orders related to a particular customer ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant