-
-
Save Sentinel-7/8da1a531a63e05326033121f3d8ad33a to your computer and use it in GitHub Desktop.
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
//плагин на событие msOnBeforeAddToCart. | |
$cartArray = $cart->get(); // Массив корзины | |
$cartStatus = $cart->status(); // Состояние корзины | |
$totalCount = $cartStatus['total_count']; // Общее количество товаров в корзине | |
foreach ($cartArray as &$cartProduct) { // Обрабатываем все товары корзины | |
if ($product = $modx->getObject('msProduct', $cartProduct['id'])) { // Получаем объект товара по его ID в корзине | |
$quanity = $product->get('count_prod)'; | |
$cartQuantity = $cartProduct["count"]; | |
if($cartQuantity > $quanity){ | |
$cartProduct['count'] = $quanity; | |
$modx->event->output('Вы пытаетесь положитель больше товаров чем есть в наличии'); | |
} | |
} | |
} | |
$cart->set($cartArray); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment