I'm using QuickBooks SDK to sync orders between QuickBooks and my Volusion site. For that, I've created 6 different kinds of requests and it is executed by some priority. Below you can see my requests.
$Queue->enqueue(QUICKBOOKS_IMPORT_ITEM, QB_PRIORITY_ITEM);
$Queue->enqueue(QUICKBOOKS_IMPORT_SALESORDER, QB_PRIORITY_SALESORDER);
$Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, QB_PRIORITY_ADD_CUSTOMER);
$Queue->enqueue(QUICKBOOKS_ADD_INVENTORYITEM, QB_PRIORITY_ADD_ITEM);
$Queue->enqueue(QUICKBOOKS_ADD_SALESORDER,QB_PRIORITY_ADD_SALESORDER);
$Queue->enqueue(QUICKBOOKS_IMPORT_CUSTOMER, QB_PRIORITY_CUSTOMER);
And priorities for these requests are as follows
define('QB_PRIORITY_CUSTOMER', 1);
define('QB_PRIORITY_ITEM', 2);
define('QB_PRIORITY_SALESORDER', 3);
define('QB_PRIORITY_ADD_CUSTOMER', 4);
define('QB_PRIORITY_ADD_ITEM', 5);
define('QB_PRIORITY_ADD_SALESORDER', 6);
So as per my knowledge requests should follow these priorities. Suppose priority for QUICKBOOKS_IMPORT_CUSTOMER request is 1 so it should be the first one to be executed no matter if it's placed at last. As one can see I have that request at the end of all the requests(first code block) even though it's at the end it is executing first so it's fine.
Now one can see there is QUICKBOOKS_ADD_INVENTORYITEM request whose priority is 5. But the problem is it's not executing when I run the web connector(I'm using this to sync data between QB and Volusion) for the first time.
When I run web connector for the consequent time, execution starts from that method (QUICKBOOKS_ADD_INVENTORYITEM) and then the rest of the method is executing. I don't know why this is happening. I cleared database 3 times and tried to sync again but it's not working.
So please help me. I'm using QuickBooks Desktop Enterprise 19 and web connector 2.3
The parameters you're passing to the function are incorrect. If you look at the function signature:
You can see that the 3rd parameter is the priority:
public function enqueue($action, $ident = null, $priority = 0, $extra = null, $user = null, $qbxml = null, $replace = true)
While you're trying to pass in your priority as the 2nd parameter:
$Queue->enqueue(QUICKBOOKS_IMPORT_ITEM, QB_PRIORITY_ITEM);
Fix your code:
$Queue->enqueue(QUICKBOOKS_IMPORT_ITEM, null, QB_PRIORITY_ITEM);
Also, note that higher priorities run first. e.g. this statement that you made is incorrect. In your example, the sales order would run first because it has the highest priority:
Suppose priority for QUICKBOOKS_IMPORT_CUSTOMER request is 1 so it should be the first one to be executed no matter if it's placed at last.