Skip to content

Instantly share code, notes, and snippets.

  • Save CB9TOIIIA/4df176ceffea46d285cae1de520d37e4 to your computer and use it in GitHub Desktop.
Save CB9TOIIIA/4df176ceffea46d285cae1de520d37e4 to your computer and use it in GitHub Desktop.
Изменение цены всего заказа в зависимости от количества заказанных товаров
class JBCartElementModifierOrderPriceColdiscount extends JBCartElementModifierOrderPrice
{
public function getRate()
{
$orderSum = $this->_order->getTotalForItems(); // сумма за все товары (без доставки и прочего)
$discount = 0;
if ($orderSum->compare('100rub', '=')) { // сравниваем c ценой 100 рублей
$discount = '2'; // скидка 2 руб, если сумма равна
}
if ($orderSum->compare('150rub', '=')) { // сравниваем c ценой 150 рублей
$discount = '8'; // скидка 8 руб
}
// и.т.д любые свое условия
return $this->_order->val($discount)->negative();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment