Skip to content

Instantly share code, notes, and snippets.

@sashabeep
Created April 3, 2020 10:35
Show Gist options
  • Save sashabeep/87fe528cdd48cb4d4390bb3a3c5653db to your computer and use it in GitHub Desktop.
Save sashabeep/87fe528cdd48cb4d4390bb3a3c5653db to your computer and use it in GitHub Desktop.
Commerce - Paid delivery when sum < N
$title = 'Доставка курьером';
$price = ci()->currency->convertToActive(100);
switch ($modx->Event->name) {
case 'OnRegisterDelivery': {
$params['rows']['fixed'] = [
'title' => $title,
'price' => $price,
];
$params['rows']['sam'] = [
'title' => "Самовывоз",
'price' => ci()->currency->convertToActive(0),
];
break;
}
case 'OnCollectSubtotals': {
$processor = $modx->commerce->loadProcessor();
if ($processor->getCurrentDelivery() == 'fixed' && intval($params['total']) < 350) {
$params['total'] += $price;
$params['rows']['fixed'] = [
'title' => $title,
'price' => $price,
];
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment