Commerce Stock integration

Created on 5 May 2021, over 3 years ago
Updated 17 October 2024, 2 months ago

Problem/Motivation

Since I installed the module and configured it completely, I noticed that the button on the product page no longer shows whether a product is "Out of stock", although the product stock is 0, but the button "add to cart" works :( is it a bug or have I configured something incorrectly?

Steps to reproduce

product page > product stock: 0 > product page: " Add to cart" ? :(

Feature request
Status

Active

Version

1.0

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇭Switzerland Lukas von Blarer

    luksak made their first commit to this issue’s fork.

  • 🇨🇭Switzerland Lukas von Blarer

    I took a first stab at this.

    There is an incompatibility with commerce_stock_enforcement. There are errors when clicking one of the actions in the success dialog. The happen because the form state is missing, but we're still extending the AddToCartForm. Here is the error:

    TypeError: commerce_stock_enforcement_get_context(): Argument #1 ($entity) must be of type Drupal\commerce\PurchasableEntityInterface, null given, called in /app/web/modules/contrib/commerce_stock/modules/enforcement/commerce_stock_enforcement.module on line 160 in commerce_stock_enforcement_get_context() (line 317 of modules/contrib/commerce_stock/modules/enforcement/commerce_stock_enforcement.module).

    So I tried to still call parent::buildForm(), but hide the elements. That works for me so far.

    I haven't looked into the "Out of stock" button behaviour of commerce_stock so far. I'm using a quite customized add to cart form.

Production build 0.71.5 2024