Skip to content

Instantly share code, notes, and snippets.

@SergeR
Last active September 19, 2023 15:10
Show Gist options
  • Save SergeR/738fe6bb58398beaf60b to your computer and use it in GitHub Desktop.
Save SergeR/738fe6bb58398beaf60b to your computer and use it in GitHub Desktop.
Пример действия с заказом
/**
* @param array $order
* @return array|NULL
* @throws waException
*/
private function deleteOrder($order)
{
$this->workflow = new shopWorkflow();
$actions = $this->workflow->getStateById($order['state_id'])->getActions(NULL, TRUE);
if (!isset($actions['delete'])) {
$status = $this->workflow->getStateById($order['state_id'])->getName();
throw new waException("Failed to delete order {$order['id']}. Action 'delete' is not available for order status '$status'");
}
$delete_action = $this->workflow->getActionById('delete');
if (!$delete_action) {
throw new waException("Failed to delete order {$order['id']}. getActionById('delete') fail.");
}
return $delete_action->run($order['id']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment