0

I'm using Commerce Stock to track the amount of product stock we're currently carrying. That said, Commerce Stock only seems to let me track product in increments of 1? Is it possible for me to change the unit stock is tracked in? For example, grams? E.g. If my user purchases 10 grams, it should subtract 10 from the total 100 grams in stock.

1 Answer 1

0

One way of achieving this is to let Commerce Stock behave in its usual way, but to override the output on user interface, which should be pretty easy using the right hook. In other words, the custom code could just multiple stock quantity by 10 and, for example, instead of 1 output 10. So total 10 items would become 100 instead, if one item purchased then it would subtract just 1 on backend to output the remaining 9, but your function would just output 90 instead.

3
  • I'm confused by this answer lol. Rather than multiplying things by 10, is there not a way to do this? E.g. simply changing the unit of stock measurement?
    – Brittany
    Commented Mar 24, 2018 at 0:08
  • When you change the ways Drupal Commerce work then you will have to deal with all the effected results of changes. However, your use case is quite simple to leave everything on backend in tact, but to change how users see units just on UI frontend. It's just of lesser blood method.
    – AltaGrade
    Commented Mar 24, 2018 at 3:54
  • Just change the units to grams? Unless you need to track fractions of a gram. Commented Jun 26, 2018 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.