dongqi8863 2016-05-18 04:58
浏览 127

WooCommerce购物车订单限制基于产品类别数量,重量和不同的产品

I'm stumped at the moment as I've looked everywhere online as to how to limit the amount of products in your cart based on the quantity of the product category, the total weight of the cart and the amount of different products in the cart for Woocommerce in WordPress. Below are the rules I need to implement that restricts the customer from buying x amount of this, etc.

  • Vitamins: have a limit of 3 for each item
    I can do this as I have these plugins installed WooCommerce Advanced Product Quantities and Woocommerce Min/Max Quantities. But they can't help me with the others as they don't limit the quantity based on category only per product i.e. Formula Milk, cart max 6 but it allows 6 per product making it 12 if you order 2 products)
  • Formula Milk: Maximum quantity of 6.
  • Adult Milk Powder: Maximum quantity of 8.
  • Wash Supplies: Maximum 3 different items. Total quantity cannot exceed more than 10 pieces and a maximum weight of 3.5kg.
  • Food: Total quantity cannot exceed more than 18 pieces and a maximum weight of 4kg.
  • Cosmetic: Cannot exceed a maximum weight of 1kg. A single item has a maximum of 3 pieces
  • Mixed Items: In the cart you cannot have more than 7 different items, each item's maximum quantity is 6 pieces. Total quantity cannot exceed more than 12 pieces and a maximum weight of 3.5kg.
    Lower quantities will stay the same i.e. Vitamins stays at 3, food is limited to 6 from 18, and the total sum of all item quantities in the cart is limited to 12. So you can have as a maximum:
    • Product #1: 1 Food
    • Product #2: 2 Vitamin #1
    • Product #3: 3 Vitamin #2
    • Product #4: 3 Cosmetic #1
    • Product #5: 1 Cosmetic #2
    • Product #6: 1 Milk Formula
    • Product #7: 1 Adult Milk Powder
  • Max 7 different products, total quantity of 12 and max weight of 3.5kg. This last rule will override a couple of the other rules.

If any of these rules are breached then a wc_notice should show up and state what is wrong, and stop them from adding to cart/proceeding to checkout.

So this is my dilemma, I know how to read the custom jquery when provided but I don't know how I can do this, and my wordpress php knowledge is limited so I don't know how to create actions but can again sort of read and understand it.

Any help is appreciated, if you find a plugin that will do something like this too please let me know. Thanks for your time and sorry about the length of the question.

Kind Regards

--

Edit:

I've thought maybe I can use this code in some way but instead of minimum convert it to maximum.

Woocommerce: Set minimum Order if Cart contains some Products / Category

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ogg dd trandata 报错
    • ¥15 高缺失率数据如何选择填充方式
    • ¥50 potsgresql15备份问题
    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错