0

I am using drupal commerce in my site its working fine. I need to stop increase product quantity when user click "add to cart" same product second time. In my case user can add multiple products in cart but not same products. and user can increase quantity via quantity fields not a click on add to cart.

I used this rule its working.But I have mention in my question, when I increase quantity from cart page then quantity should be increase.. but this rule restricting me to increase quantity.

> { "rules_restrict_quantity_to_1" : { 
>     "LABEL" : "Restrict quantity to 1",
>     "PLUGIN" : "reaction rule",
>     "REQUIRES" : [ "rules", "entity" ],
>     "ON" : [ "commerce_order_presave" ],
>     "IF" : [
>       { "user_has_role" : {
>           "account" : [ "site:current-user" ],
>           "roles" : { "value" : { "1" : "1" } }
>         }
>       }
>     ],
>     "DO" : [
>       { "LOOP" : {
>           "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
>           "ITEM" : { "list_item" : "Current list item" },
>           "DO" : [ { "data_set" : { "data" : [ "list-item:quantity" ], "value" : "1" } } ]
>         }
>       }
>     ]   }

}

marked as duplicate by Clive May 4 '16 at 13:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I need to do this functionality for all user not only anonymous user. – jsh May 4 '16 at 14:12
  • you can use the same logic for any user role – oksana-c May 4 '16 at 14:17
  • But in my case user can add multiple products in cart but not same products. and user can increase quantity via quantity fields not a click on add to cart. – jsh May 4 '16 at 14:25
  • 2
    then you have to update your question with those details and explain why the solution linked does not satisfy your use case – oksana-c May 4 '16 at 14:29
  • 1
    @jsh Still a duplicate - the second part of David's answer is what you're looking for – Clive May 4 '16 at 15:15

Browse other questions tagged or ask your own question.