Answers:
您需要编写自定义模块,并且必须使用此事件(sales_quote_item_qty_set_after)。
在这种情况下,您需要-检查当前登录的用户,并获取客户在当月购买的所有物品。-检查产品的数量,如果数量超出最大数量,则需要抛出期望值
throw new \Magento\Framework\Exception\CouldNotSaveException( __('The most you may purchase is %1.',$_qty));您还可以将消息添加到项目itlef
$quoteItem->getQuote()->addErrorInfo(
        'stock',
        'cataloginventory',
        \Magento\CatalogInventory\Helper\Data::ERROR_QTY,
        __('Please correct the quantity for some products.')
        );其中$ quoteItem来自此代码
$quoteItem = $observer->getEvent()->getItem();我之前有过类似的逻辑,这项工作对我来说