An agent basket is created by an agent on behalf of the customer in comparison to a storefront basket which is created by the customer e.g. in the storefront. An agent basket can be created with BasketMgr.createAgentBasket().
It will return null
for the following reasons:
- No reservation for the basket was done
- Reservation is outdated meaning the timestamp is in the past
Please note that the expiry timestamp will not always be valid for the whole basket. It will not be valid for new items added or items whose quantity has changed after the reservation was done.
If the tax is rounded on group level, the tax is applied to the summed-up tax basis for each tax rate.
Temporary baskets are separate from shopper storefront and agent baskets, and are intended for use to perform calculations or create an order without disturbing a shopper's open storefront basket. A temporary basket can be created with BasketMgr.createTemporaryBasket().
Releases all inventory previously reserved for this basket.
Reserves inventory for all items in this basket for 10 minutes.
Reserves inventory for all items in this basket for a specified amount of minutes.
Reserves inventory for all items in this basket for a specified amount of minutes.
Possible values are LineItemCtnr.BUSINESS_TYPE_B2C or LineItemCtnr.BUSINESS_TYPE_B2B.
It will return null
for the following reasons:
- No reservation for the basket was done
- Reservation is outdated meaning the timestamp is in the past
Please note that the expiry timestamp will not always be valid for the whole basket. It will not be valid for new items added or items whose quantity has changed after the reservation was done.
null
An agent basket is created by an agent on behalf of the customer in comparison to a storefront basket which is created by the customer e.g. in the storefront. An agent basket can be created with BasketMgr.createAgentBasket().
true
if the basket was created by an agent otherwise false
If the tax is rounded on group level, the tax is applied to the summed-up tax basis for each tax rate.
true
if the Basket was calculated with grouped taxation
Temporary baskets are separate from shopper storefront and agent baskets, and are intended for use to perform calculations or create an order without disturbing a shopper's open storefront basket. A temporary basket can be created with BasketMgr.createTemporaryBasket().
true
if the basket is temporary otherwise false
Releases all inventory previously reserved for this basket.
The method implements its own transaction handling. Calling the method from inside a transaction is disallowed and results in an exception being thrown. This behavior differs when calling the method from an OCAPI hook. OCAPI hooks handle transactions themselves, so in this case there is also no need to do any transaction handling, but to ensure the shortest possible locking of the inventory this method should only be called as the last step in the OCAPI hook.
Reserves inventory for all items in this basket for 10 minutes. Any reservations created by previous calls of this method will be reset to 10 minutes.
The method can be used to reserve basket items before checkout to ensure that inventory is still available at the time an order is created from the basket using OrderMgr.createOrder(Basket). If all or some basket items are not reserved before creating an order, OrderMgr.createOrder(Basket) will validate item availability and will fail if any item is unavailable. Calling this method in the same request as OrderMgr.createOrder(Basket) is unnecessary and discouraged for performance reasons.
The maximum quantity that can be reserved at one time is equal to the ATS (Available To Sell) quantity. (See ProductInventoryRecord.getATS().)
When using B2C Commerce inventory, reserving basket inventory does not reduce ATS. In this case, converting the basket to an order reduces ATS by the reserved amount. For example, consider a product with an ATS quantity of 5 and no reservations. If a basket reserves a quantity of 3, then other baskets still see an ATS of 5 but can only reserve a quantity of 2.
When using Omnichannel Inventory, reserving basket inventory reduces ATS. In this case, converting the basket to an order doesn't reduce ATS. In the previous example, after the first basket reserved a quantity of 3, other baskets would see an ATS of 2.
Reservations can only be made for products with an inventory record. The reservation of product bundles is controlled by the Use Bundle Inventory Only setting on the inventory list. The setting allows inventory to be reserved for just the bundle or for the bundle and its bundled products.
The following conditions must be met for the method to succeed:
- an inventory list must be assigned to the current site
- all products in the basket must exist, and must not be of type Master or ProductSet
- each product line item must have a valid quantity
- each product must have an inventory record, or the inventory list must define that products without inventory record are available by default
- the reservation must succeed for each item as described above.
The method implements its own transaction handling. Calling the method from inside a transaction is disallowed and results in an exception being thrown. This behavior differs when calling the method from an OCAPI hook. OCAPI hooks handle transactions themselves, so in this case there is also no need to do any transaction handling, but to ensure the shortest possible locking of the inventory this method should only be called as the last step in the OCAPI hook.
If the reservation fails with an ERROR status, existing valid reservations for the basket will remain unchanged but no new reservations will be made. This might lead to a partially reserved basket.
Behaves same as reserveInventory( null, false );
.
This method must not be used with
- the CreateOrder2 pipelet, or
- OrderMgr.createOrder(Basket), or
- OrderMgr.createOrder(Basket, String)
Reserves inventory for all items in this basket for a specified amount of minutes. Any reservations created by previous calls of this method will be reset to that amount of minutes.
The method can be used to reserve basket items before checkout to ensure that inventory is still available at the time an order is created from the basket using OrderMgr.createOrder(Basket). If all or some basket items are not reserved before creating an order, OrderMgr.createOrder(Basket) will validate item availability and will fail if any item is unavailable. Calling this method in the same request as OrderMgr.createOrder(Basket) is unnecessary and discouraged for performance reasons.
The maximum quantity that can be reserved at one time is equal to the ATS (Available To Sell) quantity. (See ProductInventoryRecord.getATS().)
When using B2C Commerce inventory, reserving basket inventory does not reduce ATS. In this case, converting the basket to an order reduces ATS by the reserved amount. For example, consider a product with an ATS quantity of 5 and no reservations. If a basket reserves a quantity of 3, then other baskets still see an ATS of 5 but can only reserve a quantity of 2.
When using Omnichannel Inventory, reserving basket inventory reduces ATS. In this case, converting the basket to an order doesn't reduce ATS. In the previous example, after the first basket reserved a quantity of 3, other baskets would see an ATS of 2.
Reservations can only be made for products with an inventory record. The reservation of product bundles is controlled by the Use Bundle Inventory Only setting on the inventory list. The setting allows inventory to be reserved for just the bundle or for the bundle and its bundled products.
The following conditions must be met for the method to succeed:
- an inventory list must be assigned to the current site
- all products in the basket must exist, and must not be of type Master or ProductSet
- each product line item must have a valid quantity
- each product must have an inventory record, or the inventory list must define that products without inventory record are available by default
- the reservation must succeed for each item as described above.
The method implements its own transaction handling. Calling the method from inside a transaction is disallowed and results in an exception being thrown. This behavior differs when calling the method from an OCAPI hook. OCAPI hooks handle transactions themselves, so in this case there is also no need to do any transaction handling, but to ensure the shortest possible locking of the inventory this method should only be called as the last step in the OCAPI hook.
getInventoryReservationExpiry() can be used to determine when the expiration will expire.
If the reservation fails with an ERROR status, existing valid reservations for the basket will remain unchanged but no new reservations will be made. This might lead to a partially reserved basket.
Behaves same as reserveInventory( reservationDurationInMinutes, false );
.
This method must not be used with
- the CreateOrder2 pipelet, or
- OrderMgr.createOrder(Basket), or
- OrderMgr.createOrder(Basket, String)
Reserves inventory for all items in this basket for a specified amount of minutes. Any reservations created by previous calls of this method will be reset to that amount of minutes.
The method can be used to reserve basket items before checkout to ensure that inventory is still available at the time an order is created from the basket using OrderMgr.createOrder(Basket). If all or some basket items are not reserved before creating an order, OrderMgr.createOrder(Basket) will validate item availability and will fail if any item is unavailable. Calling this method in the same request as OrderMgr.createOrder(Basket) is unnecessary and discouraged for performance reasons.
The maximum quantity that can be reserved at one time is equal to the ATS (Available To Sell) quantity. (See ProductInventoryRecord.getATS().)
When using B2C Commerce inventory, reserving basket inventory does not reduce ATS. In this case, converting the basket to an order reduces ATS by the reserved amount. For example, consider a product with an ATS quantity of 5 and no reservations. If a basket reserves a quantity of 3, then other baskets still see an ATS of 5 but can only reserve a quantity of 2.
When using Omnichannel Inventory, reserving basket inventory reduces ATS. In this case, converting the basket to an order doesn't reduce ATS. In the previous example, after the first basket reserved a quantity of 3, other baskets would see an ATS of 2.
Reservations can only be made for products with an inventory record. The reservation of product bundles is controlled by the Use Bundle Inventory Only setting on the inventory list. The setting allows inventory to be reserved for just the bundle or for the bundle and its bundled products.
The following conditions must be met for the method to succeed:
- an inventory list must be assigned to the current site
- all products in the basket must exist, and must not be of type Master or ProductSet
- each product line item must have a valid quantity
- each product must have an inventory record, or the inventory list must define that products without inventory record are available by default
- the reservation must succeed for each item as described above or
removeIfNotAvailable
is set totrue
The method implements its own transaction handling. Calling the method from inside a transaction is disallowed and results in an exception being thrown. This behavior differs when calling the method from an OCAPI hook. OCAPI hooks handle transactions themselves, so in this case there is also no need to do any transaction handling, but to ensure the shortest possible locking of the inventory this method should only be called as the last step in the OCAPI hook.
getInventoryReservationExpiry() can be used to determine when the expiration will expire.
If the reservation fails with an ERROR status, existing valid reservations for the basket will remain unchanged but no new reservations will be made. This might lead to a partially reserved basket.
If the reservation succeeds with an OK status and removeIfNotAvailable
is true
, basket
line items quantities might have been changed or line items might have been removed. The returned
Status object will contain information about the changes. Possible values for
StatusItem.getCode() are:
- BUNDLE_REMOVED - a bundle item was removed completely
- ITEM_REMOVED - a product line item was removed completely
- ITEM_QUANTITY_REDUCED - the quantity of a line item was reduced
This method must not be used with
- the CreateOrder2 pipelet, or
- OrderMgr.createOrder(Basket), or
- OrderMgr.createOrder(Basket, String)
true
is specified it will not fail if not the full quantity of the items can be reserved. Item quantity will be reduced to the quantity that could be reserved. Item will be removed if not at least quantity 1 for the item could be reserved. Different to that if a bundle line item cannot be reserved completely it will be removed including dependent line item (bundled items).
removeIfNotAvailable
is true, status might contain status items (Status.getItems()) for each item that needed to be changed or removed. In the worst case this could result in an empty basket and no items reserved. A Status instance with - Status.ERROR will be returned if removeIfNotAvailable
is false and not all items could be reserved fully or any unexpected error occurred.
Possible values are LineItemCtnr.BUSINESS_TYPE_B2C or LineItemCtnr.BUSINESS_TYPE_B2B.
Possible values are LineItemCtnr.CHANNEL_TYPE_STOREFRONT, LineItemCtnr.CHANNEL_TYPE_CALLCENTER, LineItemCtnr.CHANNEL_TYPE_MARKETPLACE, LineItemCtnr.CHANNEL_TYPE_DSS, LineItemCtnr.CHANNEL_TYPE_STORE, LineItemCtnr.CHANNEL_TYPE_PINTEREST, LineItemCtnr.CHANNEL_TYPE_TWITTER, LineItemCtnr.CHANNEL_TYPE_FACEBOOKADS, LineItemCtnr.CHANNEL_TYPE_SUBSCRIPTIONS, LineItemCtnr.CHANNEL_TYPE_ONLINERESERVATION, LineItemCtnr.CHANNEL_TYPE_INSTAGRAMCOMMERCE, LineItemCtnr.CHANNEL_TYPE_GOOGLE, LineItemCtnr.CHANNEL_TYPE_YOUTUBE, LineItemCtnr.CHANNEL_TYPE_TIKTOK, LineItemCtnr.CHANNEL_TYPE_SNAPCHAT, LineItemCtnr.CHANNEL_TYPE_WHATSAPP The value for LineItemCtnr.CHANNEL_TYPE_CUSTOMERSERVICECENTER is also available, but it can not be set by the scripting API, it is set only internally.
Use Session.setCurrency(Currency) to set the currency for the session. To reflect the session currency change to the basket you need to update the basket with this method. This ensures that any upcoming basket recalculation, which is based on the session currency, matches the basket currency.
... if (basket.getBillingAddress().getCountryCode() == 'DE'){ var newCurrency : Currency = Currency.getCurrency('EUR'); session.setCurrency( newCurrency ); basket.updateCurrency(); } customBasketRecalculate(); ...