Back to PhocacartOrderStatus class

Method changeStatusInOrderTable

public static
changeStatusInOrderTable
(mixed $orderId, mixed $statusId)

Method changeStatusInOrderTable - Source code

/* Usually
 * - order is saved - the status id in order table is set while saving order (libraries/order/order.php)
 * - status is changed in administration - the status id in order table is set while changing status (models/phocacarteditstatus.php)
 * - BUT e.g. if payment method returns status, the status in order needs to be changed - by this function
 *
 * method changeStatus - in fact check all possible conditions and cares about notify (send email)
 * method changeStatusInOrderTable - changes the status directly in order table
 *
 * Mostly changeStatus is called when the status is changed in order table (saving order, changing status)
 * but sometimes e.g. when Payment method set the response, we need to change the status with help of this function
 * in order table as in fact when making payment response nothing happen to order table - only status is changed
 * Payment method runs both scripts: changeStatus - to send notify emails, set stock, etc. and changeStatusInOrderTable to check the status in table
 */
public static function changeStatusInOrderTable($orderId, $statusId)
{
    $db = Factory::getDBO();
    $query = ' UPDATE #__phocacart_orders SET status_id = ' . (int) $statusId . ' WHERE id = ' . (int) $orderId;
    $db->setQuery($query);
    $db->execute();
    // Set invoice data in case status can set invoice ID
    PhocacartOrder::storeOrderReceiptInvoiceId((int) $orderId, false, (int) $statusId, array('I'));
    return true;
}