Loading...
Skip navigation
Please note that this documentation is for the most recent version of this extension. It may not be relevant for older versions. Related documentation can be found in the documentation directory of the extension.

Stock handling

The Shop-Extension provides a simple stock logic for products.

First of all, you need to activate the stock-fields in your product by configuring the product-type. Afterwards you'll find the following fields in all products of the related product-type:

  • In stock
  • Stock amount
  • Allow backorders

If you enable the field In stock, the logic for decreasing the stock-amount is enabled. The field Stock amount defines how many of this product can still be ordered.With the setting Allow backorders you can specify that the stock amount can also become negative. You thus allow backorders and, if necessary, inform your customer of a longer shipping time.

Usage in Fluid

In Fluid the following properties can be used on the product:

  • {product.inStock} returns true if the stock logic is enabled for the product.

  • {product.stockAmount} returns the current stock amount of the product as an integer.

  • {product.stockAmountAsString} returns the current stock amount of the product as a string.

  • {product.stockAllowBackorders} returns true if backorders are allowed for this product.

  • {product.isBuyable} returns true if the product can be ordered.

    flowchart TD
        A(["{product.isBuyable}"]) --> B{isDigitalProduct}
        B -- Yes --> T1([return true<br/>Digital product: always buyable])
        B -- No --> C{isStockAllowBackorders}
        C -- No --> D{getStockAmount > 0}
        D -- Yes --> T2([return true<br/>Stock available])
        D -- No --> E{isInStock}
        E -- No --> T3([return true<br/>Stock logic disabled])
        E -- Yes --> F([return false<br/>No stock & stock logic enabled])
        C -- Yes --> T4([return true<br/>Backorders enabled: always buyable])
    

Stock handling in basket-checkouts

If you're using the regular basket and checkout, the stock-amount will be checked in first instance in basket-view. If the user tries to order an amount, which isn't available anymore, the basket-view automatically reduces to the maximium available amount. This check and, if necessary, reduction happens in every step of the checkout.

When finishing the checkout (at the moment the buyer clicks on "Confirm and Order"), the DecreaseStockAmountsEventListener is executed via BasketOrderController->orderAction.

It checks first if the product is a digital-product - digital-products will be skipped, because they don't have a stock-amount. Afterwards it checks if the setting In stock is enabled - if true, the event-listener will decrease the stock-amount on the product according to the ordered quantity.

Stock handling in Stripe subscriptions

The stock handling in Stripe subscriptions works a bit differently. It only takes effect if you have assigned a Stripe price ID to a product.

Usecase: You create regular products with assigned Stripe price-id and enables the subsciption-buttons, and disables the basket-button. This way you can use your products as subscription-items.

The logic listens to the StripeSubscriptionCreatedEvent and catches it in the StripeSubscriptionCreatedDecreaseStockAmountsEventListener. This event uses the Stripe subscription-object to identify all subscription-items. Each subscription-item contains the price-id and the quantity to decrease.On a new subscription it iterates through all subscription-items, tries to find a related Product record and if this record has an enabled In stock field it decreases the subscription-item quantity.

Contact request

You can contact us at any time

Stop! Playing in the meantime?
Stop! Playing in the meantime?
Stop! Playing in the meantime?

Stop! Playing in the meantime?

Break the highscore

Press Start
Contact request
Screenreader label
Security question
O6S_________HTT______
5______I____Z_T___ZGZ
XY2___EZF___7SB______
__O____E____8_8___ADJ
IB8_________S2F______