Jogex Posted April 13, 2019 Share Posted April 13, 2019 Hi, I'm going crazy trying to figure out how to properly get an order from the GetOrders call. We have a webhook running on accepted orders, and there are some jobs that only runs on a few select products. So we need to stop orders that shouldn't dispatch these jobs. This is the current logic. An order is accepted A webhook runs the API call GetOrders({orderId}) on the order. We loop through $order->lineitems->lineitem Each lineitem contains a relid. Previously we have taken this, and done a DB lookup on tblcustomfieldsvalues and joined the tblproducts table, which would give us a product name and ID. Then we match the product ID with a list of accepted product IDs. Currently, I'm stuck at step 4. It's been working well for a while, but after we removed some custom fields on the products (not sure if that's the actual cause) it's started returning an empty queryset. I'm not kidding... The relid does not exist in the tblcustomfieldsvalues table AT ALL. So I figured using the API would solve my issues since it's obviously somehow getting the product ID and name when browsing the order. From what I gather, the ID in "/clientsservices.php?userid=1&id=99" is the relid right? But from the looks of it, the API result does not contain the product ID. Which I find odd, as the API call for products (GetProducts) accepts a product ID (pid). It's kind of useless right now without that ID. I'm hoping I'm missing something obvious here. Any help would be greatly appreciated. Also, I hope I posted this in the correct section of the community. With kind regards 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted April 15, 2019 Share Posted April 15, 2019 The relid in the lineitem should be the service / domain for that line item and the only time there the relid in the line item will match up to an entry in tblcustomfieldsvalues is when that service has any custom fields saved. Though you are correct, the getorders doesn't return the product ID but rather the product text (that helps much WHMCS). As such, you need to go the round about way and get the service either by internal classes (WHMCS/User/Service) or by API (getclientproducts). Then get the package / product id from that. 0 Quote Link to comment Share on other sites More sharing options...
Jogex Posted April 15, 2019 Author Share Posted April 15, 2019 35 minutes ago, steven99 said: The relid in the lineitem should be the service / domain for that line item and the only time there the relid in the line item will match up to an entry in tblcustomfieldsvalues is when that service has any custom fields saved. Though you are correct, the getorders doesn't return the product ID but rather the product text (that helps much WHMCS). As such, you need to go the round about way and get the service either by internal classes (WHMCS/User/Service) or by API (getclientproducts). Then get the package / product id from that. Thanks for the reply 😄 Yeah the API ecosystem has its flaws it seems. I ended up scaping the entire API integration and will rely on basic SQL queries again. I managed to find the proper relation between an invoice and the product SELECT tblhosting.id as 'rel_id', tblhosting.orderid as 'order_oid', tblproducts.name as 'product_name', tblproducts.id as 'product_id', tblhosting.userid as 'user_id' FROM tblhosting INNER JOIN tblproducts on tblhosting.packageid = tblproducts.id WHERE tblhosting.id = ? Who would have thought the PACKAGE id refers to the PRODUCT id? 😂 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.