0

Drupal Commerce Stock displays the correct number of stock. For example:

Product Name, Price: $ 1.00, Stock: 20.

I would like to change the stock levels to 1, 2, 3, 4 and 4+. So if the stock level is 5 or more, the displayed stock will be 4+. What's the best way to do this?

1 Answer 1

0

If you want to display the stock of a product with 4+ when it's >5, assuming that you've got stock a field attached to the product and exposed to the node display (default behavior) you can use hook_entity_view_alter or hook_node_view_alter to alter the #markup of $build['product:field_stock']

0

Your Answer

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

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