Created
April 3, 2020 10:35
-
-
Save sashabeep/87fe528cdd48cb4d4390bb3a3c5653db to your computer and use it in GitHub Desktop.
Commerce - Paid delivery when sum < N
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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