diff --git a/fragmentTypes.json b/fragmentTypes.json index 8775e5ba3..9152cc87a 100644 --- a/fragmentTypes.json +++ b/fragmentTypes.json @@ -416,9 +416,6 @@ { "name": "ProductMedia" }, - { - "name": "ProductImage" - }, { "name": "PageType" } diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index 73f61bb54..089462db2 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -6292,6 +6292,18 @@ "context": "product label", "string": "Published" }, + "src_dot_products_dot_components_dot_ProductVariantCheckoutSettings_dot_checkoutLimits": { + "context": "title", + "string": "Checkout limits" + }, + "src_dot_products_dot_components_dot_ProductVariantCheckoutSettings_dot_checkoutLimitsDescription": { + "context": "input helper text", + "string": "Your customer won't be allowed to buy bigger quantity per checkout than shown here." + }, + "src_dot_products_dot_components_dot_ProductVariantCheckoutSettings_dot_checkoutLineLimit": { + "context": "input label", + "string": "Limit quantity per checkout (optional)" + }, "src_dot_products_dot_components_dot_ProductVariantCreateDialog_dot_description": { "context": "create product variants", "string": "How would you like to create variants:" @@ -7185,6 +7197,18 @@ "context": "site settings section name", "string": "Site Settings" }, + "src_dot_siteSettings_dot_components_dot_SiteCheckoutSettingsCard_dot_checkoutLimits": { + "context": "title", + "string": "Checkout limits" + }, + "src_dot_siteSettings_dot_components_dot_SiteCheckoutSettingsCard_dot_checkoutLimitsDescription": { + "context": "input helper text", + "string": "This number defines quantity of items in checkout line that can be bought. You can override this setting per variant. Leaving this setting empty mean that there is no limits." + }, + "src_dot_siteSettings_dot_components_dot_SiteCheckoutSettingsCard_dot_checkoutLineLimit": { + "context": "input label", + "string": "Checkout line limit" + }, "src_dot_siteSettings_dot_components_dot_SiteCheckoutSettingsCard_dot_reservedStock": { "context": "title", "string": "Reserved stock" @@ -8054,6 +8078,10 @@ "context": "event", "string": "Invoice deleted" }, + "src_dot_webhooks_dot_components_dot_WebhookEvents_dot_1368438665": { + "context": "event", + "string": "Shipping methods for checkout listed" + }, "src_dot_webhooks_dot_components_dot_WebhookEvents_dot_1436364351": { "context": "section header", "string": "Events" diff --git a/schema.graphql b/schema.graphql index 323900d1d..114b985b2 100644 --- a/schema.graphql +++ b/schema.graphql @@ -2427,6 +2427,7 @@ enum GiftCardEventsEnum { input GiftCardFilterInput { isActive: Boolean + metadata: [MetadataFilter] tag: String tags: [String] products: [ID] @@ -3916,7 +3917,7 @@ type Mutation { checkoutLineDelete(checkoutId: ID, lineId: ID, token: UUID): CheckoutLineDelete checkoutLinesAdd(checkoutId: ID, lines: [CheckoutLineInput]!, token: UUID): CheckoutLinesAdd checkoutLinesUpdate(checkoutId: ID, lines: [CheckoutLineInput]!, token: UUID): CheckoutLinesUpdate - checkoutRemovePromoCode(checkoutId: ID, promoCode: String!, token: UUID): CheckoutRemovePromoCode + checkoutRemovePromoCode(checkoutId: ID, promoCode: String, promoCodeId: ID, token: UUID): CheckoutRemovePromoCode checkoutPaymentCreate(checkoutId: ID, input: PaymentInput!, token: UUID): CheckoutPaymentCreate checkoutShippingAddressUpdate(checkoutId: ID, shippingAddress: AddressInput!, token: UUID): CheckoutShippingAddressUpdate checkoutShippingMethodUpdate(checkoutId: ID, shippingMethodId: ID!, token: UUID): CheckoutShippingMethodUpdate @deprecated(reason: "This field will be removed in Saleor 4.0. Use `checkoutDeliveryMethodUpdate` instead.") @@ -5548,7 +5549,7 @@ type ProductType implements Node & ObjectWithMetadata { kind: ProductTypeKindEnum! products(channel: String, before: String, after: String, first: Int, last: Int): ProductCountableConnection @deprecated(reason: "This field will be removed in Saleor 4.0. Use the top-level `products` query with the `productTypes` filter.") taxType: TaxType - variantAttributes(variantSelection: VariantAttributeScope): [Attribute] @deprecated(reason: "This field will be removed in Saleor 4.0. use `assignedVariantAttributes` instead.") + variantAttributes(variantSelection: VariantAttributeScope): [Attribute] @deprecated(reason: "This field will be removed in Saleor 4.0. Use `assignedVariantAttributes` instead.") assignedVariantAttributes(variantSelection: VariantAttributeScope): [AssignedVariantAttribute] productAttributes: [Attribute] availableAttributes(filter: AttributeFilterInput, before: String, after: String, first: Int, last: Int): AttributeCountableConnection @@ -5655,6 +5656,7 @@ type ProductVariant implements Node & ObjectWithMetadata { sku: String product: Product! trackInventory: Boolean! + quantityLimitPerCustomer: Int weight: Weight privateMetadata: [MetadataItem]! metadata: [MetadataItem]! @@ -5670,7 +5672,7 @@ type ProductVariant implements Node & ObjectWithMetadata { translation(languageCode: LanguageCodeEnum!): ProductVariantTranslation digitalContent: DigitalContent stocks(address: AddressInput, countryCode: CountryCode): [Stock] - quantityAvailable(address: AddressInput, countryCode: CountryCode): Int! + quantityAvailable(address: AddressInput, countryCode: CountryCode): Int preorder: PreorderData } @@ -5687,6 +5689,7 @@ input ProductVariantBulkCreateInput { trackInventory: Boolean weight: WeightScalar preorder: PreorderSettingsInput + quantityLimitPerCustomer: Int stocks: [StockInput!] channelListings: [ProductVariantChannelListingAddInput!] } @@ -5742,6 +5745,7 @@ input ProductVariantCreateInput { trackInventory: Boolean weight: WeightScalar preorder: PreorderSettingsInput + quantityLimitPerCustomer: Int product: ID! stocks: [StockInput!] } @@ -5765,6 +5769,7 @@ input ProductVariantInput { trackInventory: Boolean weight: WeightScalar preorder: PreorderSettingsInput + quantityLimitPerCustomer: Int } type ProductVariantPreorderDeactivate { @@ -6139,14 +6144,10 @@ enum ShippingErrorCode { type ShippingMethod implements Node & ObjectWithMetadata { id: ID! - name: String! - description: JSONString - minimumOrderWeight: Weight - maximumOrderWeight: Weight - maximumDeliveryDays: Int - minimumDeliveryDays: Int privateMetadata: [MetadataItem]! metadata: [MetadataItem]! + name: String! + description: JSONString type: ShippingMethodTypeEnum translation(languageCode: LanguageCodeEnum!): ShippingMethodTranslation channelListings: [ShippingMethodChannelListing!] @@ -6155,6 +6156,10 @@ type ShippingMethod implements Node & ObjectWithMetadata { minimumOrderPrice: Money postalCodeRules: [ShippingMethodPostalCodeRule] excludedProducts(before: String, after: String, first: Int, last: Int): ProductCountableConnection + minimumOrderWeight: Weight + maximumOrderWeight: Weight + maximumDeliveryDays: Int + minimumDeliveryDays: Int } type ShippingMethodChannelListing implements Node { @@ -6384,6 +6389,7 @@ type Shop { automaticFulfillmentDigitalProducts: Boolean reserveStockDurationAnonymousUser: Int reserveStockDurationAuthenticatedUser: Int + limitQuantityPerCheckout: Int defaultDigitalMaxDownloads: Int defaultDigitalUrlValidDays: Int companyAddress: Address @@ -6445,6 +6451,7 @@ input ShopSettingsInput { customerSetPasswordUrl: String reserveStockDurationAnonymousUser: Int reserveStockDurationAuthenticatedUser: Int + limitQuantityPerCheckout: Int } type ShopSettingsTranslate { @@ -6577,6 +6584,7 @@ type Stock implements Node { quantity: Int! id: ID! quantityAllocated: Int! + quantityReserved: Int! } enum StockAvailability { @@ -7285,6 +7293,7 @@ enum WebhookEventTypeEnum { PAYMENT_PROCESS PAYMENT_REFUND PAYMENT_VOID + SHIPPING_LIST_METHODS_FOR_CHECKOUT TRANSLATION_CREATED TRANSLATION_UPDATED } @@ -7330,6 +7339,7 @@ enum WebhookSampleEventTypeEnum { PAYMENT_PROCESS PAYMENT_REFUND PAYMENT_VOID + SHIPPING_LIST_METHODS_FOR_CHECKOUT TRANSLATION_CREATED TRANSLATION_UPDATED } @@ -7366,7 +7376,7 @@ enum WeightUnitsEnum { scalar _Any -union _Entity = App | Address | User | Group | ProductVariant | Product | ProductType | Collection | Category | ProductMedia | ProductImage | PageType +union _Entity = App | Address | User | Group | ProductVariant | Product | ProductType | Collection | Category | ProductMedia | PageType type _Service { sdl: String diff --git a/src/fragments/products.ts b/src/fragments/products.ts index 06ec0dc41..4282dc605 100644 --- a/src/fragments/products.ts +++ b/src/fragments/products.ts @@ -245,6 +245,7 @@ export const productFragmentDetails = gql` channelListings { ...ChannelListingProductVariantFragment } + quantityLimitPerCustomer } productType { id @@ -380,6 +381,7 @@ export const fragmentVariant = gql` weight { ...WeightFragment } + quantityLimitPerCustomer } `; diff --git a/src/fragments/shop.ts b/src/fragments/shop.ts index 155aace7a..f4886903c 100644 --- a/src/fragments/shop.ts +++ b/src/fragments/shop.ts @@ -43,5 +43,6 @@ export const shopFragment = gql` name reserveStockDurationAnonymousUser reserveStockDurationAuthenticatedUser + limitQuantityPerCheckout } `; diff --git a/src/fragments/types/FulfillmentFragment.ts b/src/fragments/types/FulfillmentFragment.ts index 93d141f74..59b419027 100644 --- a/src/fragments/types/FulfillmentFragment.ts +++ b/src/fragments/types/FulfillmentFragment.ts @@ -17,7 +17,7 @@ export interface FulfillmentFragment_lines_orderLine_variant_preorder { export interface FulfillmentFragment_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: FulfillmentFragment_lines_orderLine_variant_preorder | null; } diff --git a/src/fragments/types/OrderDetailsFragment.ts b/src/fragments/types/OrderDetailsFragment.ts index 34153cfb5..373f1a924 100644 --- a/src/fragments/types/OrderDetailsFragment.ts +++ b/src/fragments/types/OrderDetailsFragment.ts @@ -214,7 +214,7 @@ export interface OrderDetailsFragment_fulfillments_lines_orderLine_variant_preor export interface OrderDetailsFragment_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDetailsFragment_fulfillments_lines_orderLine_variant_preorder | null; } @@ -316,7 +316,7 @@ export interface OrderDetailsFragment_lines_variant_preorder { export interface OrderDetailsFragment_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDetailsFragment_lines_variant_preorder | null; } diff --git a/src/fragments/types/OrderLineFragment.ts b/src/fragments/types/OrderLineFragment.ts index 278012474..c090da65b 100644 --- a/src/fragments/types/OrderLineFragment.ts +++ b/src/fragments/types/OrderLineFragment.ts @@ -17,7 +17,7 @@ export interface OrderLineFragment_variant_preorder { export interface OrderLineFragment_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineFragment_variant_preorder | null; } diff --git a/src/fragments/types/Product.ts b/src/fragments/types/Product.ts index f8ba2bb0c..798e0dd47 100644 --- a/src/fragments/types/Product.ts +++ b/src/fragments/types/Product.ts @@ -311,6 +311,7 @@ export interface Product_variants { trackInventory: boolean; preorder: Product_variants_preorder | null; channelListings: Product_variants_channelListings[] | null; + quantityLimitPerCustomer: number | null; } export interface Product_weight { diff --git a/src/fragments/types/ProductVariant.ts b/src/fragments/types/ProductVariant.ts index a86e0765a..7ac0f3402 100644 --- a/src/fragments/types/ProductVariant.ts +++ b/src/fragments/types/ProductVariant.ts @@ -356,4 +356,5 @@ export interface ProductVariant { trackInventory: boolean; preorder: ProductVariant_preorder | null; weight: ProductVariant_weight | null; + quantityLimitPerCustomer: number | null; } diff --git a/src/fragments/types/ShopFragment.ts b/src/fragments/types/ShopFragment.ts index d27d401c8..b6a3e83a5 100644 --- a/src/fragments/types/ShopFragment.ts +++ b/src/fragments/types/ShopFragment.ts @@ -52,4 +52,5 @@ export interface ShopFragment { name: string; reserveStockDurationAnonymousUser: number | null; reserveStockDurationAuthenticatedUser: number | null; + limitQuantityPerCheckout: number | null; } diff --git a/src/orders/types/FulfillOrder.ts b/src/orders/types/FulfillOrder.ts index 07c8bb58e..ebfbd7e04 100644 --- a/src/orders/types/FulfillOrder.ts +++ b/src/orders/types/FulfillOrder.ts @@ -223,7 +223,7 @@ export interface FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine_va export interface FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -325,7 +325,7 @@ export interface FulfillOrder_orderFulfill_order_lines_variant_preorder { export interface FulfillOrder_orderFulfill_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: FulfillOrder_orderFulfill_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderCancel.ts b/src/orders/types/OrderCancel.ts index dec0f674e..7990635bf 100644 --- a/src/orders/types/OrderCancel.ts +++ b/src/orders/types/OrderCancel.ts @@ -221,7 +221,7 @@ export interface OrderCancel_orderCancel_order_fulfillments_lines_orderLine_vari export interface OrderCancel_orderCancel_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderCancel_orderCancel_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderCancel_orderCancel_order_lines_variant_preorder { export interface OrderCancel_orderCancel_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderCancel_orderCancel_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderCapture.ts b/src/orders/types/OrderCapture.ts index 3ffc5fc72..53d1e0ee8 100644 --- a/src/orders/types/OrderCapture.ts +++ b/src/orders/types/OrderCapture.ts @@ -221,7 +221,7 @@ export interface OrderCapture_orderCapture_order_fulfillments_lines_orderLine_va export interface OrderCapture_orderCapture_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderCapture_orderCapture_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderCapture_orderCapture_order_lines_variant_preorder { export interface OrderCapture_orderCapture_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderCapture_orderCapture_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderConfirm.ts b/src/orders/types/OrderConfirm.ts index 8fe0ba86d..fc5795723 100644 --- a/src/orders/types/OrderConfirm.ts +++ b/src/orders/types/OrderConfirm.ts @@ -221,7 +221,7 @@ export interface OrderConfirm_orderConfirm_order_fulfillments_lines_orderLine_va export interface OrderConfirm_orderConfirm_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderConfirm_orderConfirm_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderConfirm_orderConfirm_order_lines_variant_preorder { export interface OrderConfirm_orderConfirm_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderConfirm_orderConfirm_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderDetails.ts b/src/orders/types/OrderDetails.ts index 7714caf75..3e43fa044 100644 --- a/src/orders/types/OrderDetails.ts +++ b/src/orders/types/OrderDetails.ts @@ -214,7 +214,7 @@ export interface OrderDetails_order_fulfillments_lines_orderLine_variant_preorde export interface OrderDetails_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDetails_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -316,7 +316,7 @@ export interface OrderDetails_order_lines_variant_preorder { export interface OrderDetails_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDetails_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderDiscountAdd.ts b/src/orders/types/OrderDiscountAdd.ts index 74ccee1bf..55a90670d 100644 --- a/src/orders/types/OrderDiscountAdd.ts +++ b/src/orders/types/OrderDiscountAdd.ts @@ -221,7 +221,7 @@ export interface OrderDiscountAdd_orderDiscountAdd_order_fulfillments_lines_orde export interface OrderDiscountAdd_orderDiscountAdd_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDiscountAdd_orderDiscountAdd_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderDiscountAdd_orderDiscountAdd_order_lines_variant_preorder export interface OrderDiscountAdd_orderDiscountAdd_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDiscountAdd_orderDiscountAdd_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderDiscountDelete.ts b/src/orders/types/OrderDiscountDelete.ts index af2fa44e6..86dbf2f0f 100644 --- a/src/orders/types/OrderDiscountDelete.ts +++ b/src/orders/types/OrderDiscountDelete.ts @@ -221,7 +221,7 @@ export interface OrderDiscountDelete_orderDiscountDelete_order_fulfillments_line export interface OrderDiscountDelete_orderDiscountDelete_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDiscountDelete_orderDiscountDelete_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderDiscountDelete_orderDiscountDelete_order_lines_variant_pre export interface OrderDiscountDelete_orderDiscountDelete_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDiscountDelete_orderDiscountDelete_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderDiscountUpdate.ts b/src/orders/types/OrderDiscountUpdate.ts index a0eaf8c94..091f2f604 100644 --- a/src/orders/types/OrderDiscountUpdate.ts +++ b/src/orders/types/OrderDiscountUpdate.ts @@ -221,7 +221,7 @@ export interface OrderDiscountUpdate_orderDiscountUpdate_order_fulfillments_line export interface OrderDiscountUpdate_orderDiscountUpdate_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDiscountUpdate_orderDiscountUpdate_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderDiscountUpdate_orderDiscountUpdate_order_lines_variant_pre export interface OrderDiscountUpdate_orderDiscountUpdate_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDiscountUpdate_orderDiscountUpdate_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderDraftCancel.ts b/src/orders/types/OrderDraftCancel.ts index 9f89c7632..4806d0287 100644 --- a/src/orders/types/OrderDraftCancel.ts +++ b/src/orders/types/OrderDraftCancel.ts @@ -221,7 +221,7 @@ export interface OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orde export interface OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderDraftCancel_draftOrderDelete_order_lines_variant_preorder export interface OrderDraftCancel_draftOrderDelete_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDraftCancel_draftOrderDelete_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderDraftFinalize.ts b/src/orders/types/OrderDraftFinalize.ts index 2c6e3120f..82ac5c4ff 100644 --- a/src/orders/types/OrderDraftFinalize.ts +++ b/src/orders/types/OrderDraftFinalize.ts @@ -221,7 +221,7 @@ export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_ export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderDraftFinalize_draftOrderComplete_order_lines_variant_preor export interface OrderDraftFinalize_draftOrderComplete_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDraftFinalize_draftOrderComplete_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderDraftUpdate.ts b/src/orders/types/OrderDraftUpdate.ts index 2a8300d9f..373c61aa1 100644 --- a/src/orders/types/OrderDraftUpdate.ts +++ b/src/orders/types/OrderDraftUpdate.ts @@ -221,7 +221,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orde export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_lines_variant_preorder export interface OrderDraftUpdate_draftOrderUpdate_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderDraftUpdate_draftOrderUpdate_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderFulfillmentApprove.ts b/src/orders/types/OrderFulfillmentApprove.ts index 9e8ed8f68..8a234f4c8 100644 --- a/src/orders/types/OrderFulfillmentApprove.ts +++ b/src/orders/types/OrderFulfillmentApprove.ts @@ -221,7 +221,7 @@ export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillme export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentApprove_orderFulfillmentApprove_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_var export interface OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentApprove_orderFulfillmentApprove_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderFulfillmentCancel.ts b/src/orders/types/OrderFulfillmentCancel.ts index ba1da9afc..a1b585e79 100644 --- a/src/orders/types/OrderFulfillmentCancel.ts +++ b/src/orders/types/OrderFulfillmentCancel.ts @@ -221,7 +221,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillment export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_lines_varia export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentCancel_orderFulfillmentCancel_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderFulfillmentRefundProducts.ts b/src/orders/types/OrderFulfillmentRefundProducts.ts index 182c6bef9..779af3f8b 100644 --- a/src/orders/types/OrderFulfillmentRefundProducts.ts +++ b/src/orders/types/OrderFulfillmentRefundProducts.ts @@ -24,7 +24,7 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_f export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_fulfillment_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_fulfillment_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_o export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -425,7 +425,7 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_o export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderFulfillmentUpdateTracking.ts b/src/orders/types/OrderFulfillmentUpdateTracking.ts index 2d19068f4..840e5dcb1 100644 --- a/src/orders/types/OrderFulfillmentUpdateTracking.ts +++ b/src/orders/types/OrderFulfillmentUpdateTracking.ts @@ -221,7 +221,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderLineDelete.ts b/src/orders/types/OrderLineDelete.ts index 7ea6b0838..bb2007ce5 100644 --- a/src/orders/types/OrderLineDelete.ts +++ b/src/orders/types/OrderLineDelete.ts @@ -221,7 +221,7 @@ export interface OrderLineDelete_orderLineDelete_order_fulfillments_lines_orderL export interface OrderLineDelete_orderLineDelete_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineDelete_orderLineDelete_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderLineDelete_orderLineDelete_order_lines_variant_preorder { export interface OrderLineDelete_orderLineDelete_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineDelete_orderLineDelete_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderLineDiscountRemove.ts b/src/orders/types/OrderLineDiscountRemove.ts index 59058061e..2dae38359 100644 --- a/src/orders/types/OrderLineDiscountRemove.ts +++ b/src/orders/types/OrderLineDiscountRemove.ts @@ -221,7 +221,7 @@ export interface OrderLineDiscountRemove_orderLineDiscountRemove_order_fulfillme export interface OrderLineDiscountRemove_orderLineDiscountRemove_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineDiscountRemove_orderLineDiscountRemove_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderLineDiscountRemove_orderLineDiscountRemove_order_lines_var export interface OrderLineDiscountRemove_orderLineDiscountRemove_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineDiscountRemove_orderLineDiscountRemove_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderLineDiscountUpdate.ts b/src/orders/types/OrderLineDiscountUpdate.ts index ddeb79353..e076e2425 100644 --- a/src/orders/types/OrderLineDiscountUpdate.ts +++ b/src/orders/types/OrderLineDiscountUpdate.ts @@ -221,7 +221,7 @@ export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order_fulfillme export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineDiscountUpdate_orderLineDiscountUpdate_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order_lines_var export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineDiscountUpdate_orderLineDiscountUpdate_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderLineUpdate.ts b/src/orders/types/OrderLineUpdate.ts index ae8549a9b..b404685e9 100644 --- a/src/orders/types/OrderLineUpdate.ts +++ b/src/orders/types/OrderLineUpdate.ts @@ -221,7 +221,7 @@ export interface OrderLineUpdate_orderLineUpdate_order_fulfillments_lines_orderL export interface OrderLineUpdate_orderLineUpdate_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineUpdate_orderLineUpdate_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderLineUpdate_orderLineUpdate_order_lines_variant_preorder { export interface OrderLineUpdate_orderLineUpdate_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLineUpdate_orderLineUpdate_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderLinesAdd.ts b/src/orders/types/OrderLinesAdd.ts index fd7d9c51e..848f4838b 100644 --- a/src/orders/types/OrderLinesAdd.ts +++ b/src/orders/types/OrderLinesAdd.ts @@ -221,7 +221,7 @@ export interface OrderLinesAdd_orderLinesCreate_order_fulfillments_lines_orderLi export interface OrderLinesAdd_orderLinesCreate_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLinesAdd_orderLinesCreate_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderLinesAdd_orderLinesCreate_order_lines_variant_preorder { export interface OrderLinesAdd_orderLinesCreate_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderLinesAdd_orderLinesCreate_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderMarkAsPaid.ts b/src/orders/types/OrderMarkAsPaid.ts index d1826a30b..59d75134a 100644 --- a/src/orders/types/OrderMarkAsPaid.ts +++ b/src/orders/types/OrderMarkAsPaid.ts @@ -221,7 +221,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderL export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_lines_variant_preorder { export interface OrderMarkAsPaid_orderMarkAsPaid_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderMarkAsPaid_orderMarkAsPaid_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderRefund.ts b/src/orders/types/OrderRefund.ts index 4ee35d05d..6ce53d5da 100644 --- a/src/orders/types/OrderRefund.ts +++ b/src/orders/types/OrderRefund.ts @@ -221,7 +221,7 @@ export interface OrderRefund_orderRefund_order_fulfillments_lines_orderLine_vari export interface OrderRefund_orderRefund_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderRefund_orderRefund_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderRefund_orderRefund_order_lines_variant_preorder { export interface OrderRefund_orderRefund_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderRefund_orderRefund_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderShippingMethodUpdate.ts b/src/orders/types/OrderShippingMethodUpdate.ts index 321a4f307..5307c7f84 100644 --- a/src/orders/types/OrderShippingMethodUpdate.ts +++ b/src/orders/types/OrderShippingMethodUpdate.ts @@ -283,7 +283,7 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order_fulfillment export interface OrderShippingMethodUpdate_orderUpdateShipping_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderShippingMethodUpdate_orderUpdateShipping_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -385,7 +385,7 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_order_lines_varia export interface OrderShippingMethodUpdate_orderUpdateShipping_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderShippingMethodUpdate_orderUpdateShipping_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderUpdate.ts b/src/orders/types/OrderUpdate.ts index ffc739ca5..ba63331b5 100644 --- a/src/orders/types/OrderUpdate.ts +++ b/src/orders/types/OrderUpdate.ts @@ -221,7 +221,7 @@ export interface OrderUpdate_orderUpdate_order_fulfillments_lines_orderLine_vari export interface OrderUpdate_orderUpdate_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderUpdate_orderUpdate_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderUpdate_orderUpdate_order_lines_variant_preorder { export interface OrderUpdate_orderUpdate_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderUpdate_orderUpdate_order_lines_variant_preorder | null; } diff --git a/src/orders/types/OrderVoid.ts b/src/orders/types/OrderVoid.ts index 083e3fa69..e2e31e2c0 100644 --- a/src/orders/types/OrderVoid.ts +++ b/src/orders/types/OrderVoid.ts @@ -221,7 +221,7 @@ export interface OrderVoid_orderVoid_order_fulfillments_lines_orderLine_variant_ export interface OrderVoid_orderVoid_order_fulfillments_lines_orderLine_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderVoid_orderVoid_order_fulfillments_lines_orderLine_variant_preorder | null; } @@ -323,7 +323,7 @@ export interface OrderVoid_orderVoid_order_lines_variant_preorder { export interface OrderVoid_orderVoid_order_lines_variant { __typename: "ProductVariant"; id: string; - quantityAvailable: number; + quantityAvailable: number | null; preorder: OrderVoid_orderVoid_order_lines_variant_preorder | null; } diff --git a/src/products/components/ProductVariantCheckoutSettings/ProductVariantCheckoutSettings.tsx b/src/products/components/ProductVariantCheckoutSettings/ProductVariantCheckoutSettings.tsx new file mode 100644 index 000000000..fed20d0b9 --- /dev/null +++ b/src/products/components/ProductVariantCheckoutSettings/ProductVariantCheckoutSettings.tsx @@ -0,0 +1,58 @@ +import { Card, CardContent, TextField } from "@material-ui/core"; +import CardTitle from "@saleor/components/CardTitle"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; +import { FormChange } from "@saleor/hooks/useForm"; +import { getFormErrors } from "@saleor/utils/errors"; +import React from "react"; +import { useIntl } from "react-intl"; + +import { messages } from "./messages"; + +interface ProductVariantCheckoutSettingsProps { + data: { + quantityLimitPerCustomer: number | null; + }; + disabled: boolean; + errors: ProductErrorFragment[]; + onChange: FormChange; +} + +const ProductVariantCheckoutSettings: React.FC = props => { + const { data, disabled, errors, onChange } = props; + + const intl = useIntl(); + + const formErrors = getFormErrors(["quantityLimitPerCustomer"], errors); + + return ( + + + + + + + ); +}; + +ProductVariantCheckoutSettings.displayName = "ProductVariantCheckoutSettings"; +export default ProductVariantCheckoutSettings; diff --git a/src/products/components/ProductVariantCheckoutSettings/index.ts b/src/products/components/ProductVariantCheckoutSettings/index.ts new file mode 100644 index 000000000..081c2f10f --- /dev/null +++ b/src/products/components/ProductVariantCheckoutSettings/index.ts @@ -0,0 +1,2 @@ +export { default } from "./ProductVariantCheckoutSettings"; +export * from "./ProductVariantCheckoutSettings"; diff --git a/src/products/components/ProductVariantCheckoutSettings/messages.ts b/src/products/components/ProductVariantCheckoutSettings/messages.ts new file mode 100644 index 000000000..914ab32db --- /dev/null +++ b/src/products/components/ProductVariantCheckoutSettings/messages.ts @@ -0,0 +1,17 @@ +import { defineMessages } from "react-intl"; + +export const messages = defineMessages({ + checkoutLimits: { + defaultMessage: "Checkout limits", + description: "title" + }, + checkoutLineLimit: { + defaultMessage: "Limit quantity per checkout (optional)", + description: "input label" + }, + checkoutLimitsDescription: { + defaultMessage: + "Your customer won't be allowed to buy bigger quantity per checkout than shown here.", + description: "input helper text" + } +}); diff --git a/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx b/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx index b3c343193..c7f116b63 100644 --- a/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx +++ b/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx @@ -27,6 +27,7 @@ import { defineMessages, useIntl } from "react-intl"; import { ProductVariantCreateData_product } from "../../types/ProductVariantCreateData"; import ProductShipping from "../ProductShipping/ProductShipping"; import ProductStocks from "../ProductStocks"; +import ProductVariantCheckoutSettings from "../ProductVariantCheckoutSettings/ProductVariantCheckoutSettings"; import ProductVariantNavigation from "../ProductVariantNavigation"; import ProductVariantPrice from "../ProductVariantPrice"; import ProductVariantCreateForm, { @@ -216,6 +217,13 @@ const ProductVariantCreatePage: React.FC = ({ onAttributeSelectBlur={onAttributeSelectBlur} /> + + = ({ onChange={handlers.changeChannels} /> + + + ({ } ], id: "var1", + quantityLimitPerCustomer: 300, media: [ { __typename: "ProductMedia", diff --git a/src/products/mutations.ts b/src/products/mutations.ts index 0445c3cb0..f43c1eb27 100644 --- a/src/products/mutations.ts +++ b/src/products/mutations.ts @@ -337,6 +337,7 @@ export const variantUpdateMutation = gql` $id: ID! $attributes: [AttributeValueInput!] $sku: String + $quantityLimitPerCustomer: Int $trackInventory: Boolean! $stocks: [StockInput!]! $preorder: PreorderSettingsInput @@ -354,6 +355,7 @@ export const variantUpdateMutation = gql` trackInventory: $trackInventory preorder: $preorder weight: $weight + quantityLimitPerCustomer: $quantityLimitPerCustomer } ) { errors { diff --git a/src/products/types/ProductDetails.ts b/src/products/types/ProductDetails.ts index 66e3dfe62..1eaff44a9 100644 --- a/src/products/types/ProductDetails.ts +++ b/src/products/types/ProductDetails.ts @@ -311,6 +311,7 @@ export interface ProductDetails_product_variants { trackInventory: boolean; preorder: ProductDetails_product_variants_preorder | null; channelListings: ProductDetails_product_variants_channelListings[] | null; + quantityLimitPerCustomer: number | null; } export interface ProductDetails_product_weight { diff --git a/src/products/types/ProductUpdate.ts b/src/products/types/ProductUpdate.ts index 328fbefa3..2909e0309 100644 --- a/src/products/types/ProductUpdate.ts +++ b/src/products/types/ProductUpdate.ts @@ -318,6 +318,7 @@ export interface ProductUpdate_productUpdate_product_variants { trackInventory: boolean; preorder: ProductUpdate_productUpdate_product_variants_preorder | null; channelListings: ProductUpdate_productUpdate_product_variants_channelListings[] | null; + quantityLimitPerCustomer: number | null; } export interface ProductUpdate_productUpdate_product_weight { diff --git a/src/products/types/ProductVariantDetails.ts b/src/products/types/ProductVariantDetails.ts index 4aa1a0461..1439e1ba8 100644 --- a/src/products/types/ProductVariantDetails.ts +++ b/src/products/types/ProductVariantDetails.ts @@ -356,6 +356,7 @@ export interface ProductVariantDetails_productVariant { trackInventory: boolean; preorder: ProductVariantDetails_productVariant_preorder | null; weight: ProductVariantDetails_productVariant_weight | null; + quantityLimitPerCustomer: number | null; } export interface ProductVariantDetails { diff --git a/src/products/types/SimpleProductUpdate.ts b/src/products/types/SimpleProductUpdate.ts index d4c0ed5b0..c0bbe46ef 100644 --- a/src/products/types/SimpleProductUpdate.ts +++ b/src/products/types/SimpleProductUpdate.ts @@ -318,6 +318,7 @@ export interface SimpleProductUpdate_productUpdate_product_variants { trackInventory: boolean; preorder: SimpleProductUpdate_productUpdate_product_variants_preorder | null; channelListings: SimpleProductUpdate_productUpdate_product_variants_channelListings[] | null; + quantityLimitPerCustomer: number | null; } export interface SimpleProductUpdate_productUpdate_product_weight { @@ -717,6 +718,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant { trackInventory: boolean; preorder: SimpleProductUpdate_productVariantUpdate_productVariant_preorder | null; weight: SimpleProductUpdate_productVariantUpdate_productVariant_weight | null; + quantityLimitPerCustomer: number | null; } export interface SimpleProductUpdate_productVariantUpdate { @@ -1079,6 +1081,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant { trackInventory: boolean; preorder: SimpleProductUpdate_productVariantStocksCreate_productVariant_preorder | null; weight: SimpleProductUpdate_productVariantStocksCreate_productVariant_weight | null; + quantityLimitPerCustomer: number | null; } export interface SimpleProductUpdate_productVariantStocksCreate { @@ -1440,6 +1443,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant { trackInventory: boolean; preorder: SimpleProductUpdate_productVariantStocksDelete_productVariant_preorder | null; weight: SimpleProductUpdate_productVariantStocksDelete_productVariant_weight | null; + quantityLimitPerCustomer: number | null; } export interface SimpleProductUpdate_productVariantStocksDelete { @@ -1802,6 +1806,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant { trackInventory: boolean; preorder: SimpleProductUpdate_productVariantStocksUpdate_productVariant_preorder | null; weight: SimpleProductUpdate_productVariantStocksUpdate_productVariant_weight | null; + quantityLimitPerCustomer: number | null; } export interface SimpleProductUpdate_productVariantStocksUpdate { diff --git a/src/products/types/VariantCreate.ts b/src/products/types/VariantCreate.ts index 29058c958..14c7a70ff 100644 --- a/src/products/types/VariantCreate.ts +++ b/src/products/types/VariantCreate.ts @@ -363,6 +363,7 @@ export interface VariantCreate_productVariantCreate_productVariant { trackInventory: boolean; preorder: VariantCreate_productVariantCreate_productVariant_preorder | null; weight: VariantCreate_productVariantCreate_productVariant_weight | null; + quantityLimitPerCustomer: number | null; } export interface VariantCreate_productVariantCreate { diff --git a/src/products/types/VariantUpdate.ts b/src/products/types/VariantUpdate.ts index 0c3654ef2..93e69aa92 100644 --- a/src/products/types/VariantUpdate.ts +++ b/src/products/types/VariantUpdate.ts @@ -363,6 +363,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant { trackInventory: boolean; preorder: VariantUpdate_productVariantUpdate_productVariant_preorder | null; weight: VariantUpdate_productVariantUpdate_productVariant_weight | null; + quantityLimitPerCustomer: number | null; } export interface VariantUpdate_productVariantUpdate { @@ -725,6 +726,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant { trackInventory: boolean; preorder: VariantUpdate_productVariantStocksUpdate_productVariant_preorder | null; weight: VariantUpdate_productVariantStocksUpdate_productVariant_weight | null; + quantityLimitPerCustomer: number | null; } export interface VariantUpdate_productVariantStocksUpdate { @@ -811,6 +813,7 @@ export interface VariantUpdateVariables { id: string; attributes?: AttributeValueInput[] | null; sku?: string | null; + quantityLimitPerCustomer?: number | null; trackInventory: boolean; stocks: StockInput[]; preorder?: PreorderSettingsInput | null; diff --git a/src/products/views/ProductVariant.tsx b/src/products/views/ProductVariant.tsx index c1eb7f37f..c5c2680c5 100644 --- a/src/products/views/ProductVariant.tsx +++ b/src/products/views/ProductVariant.tsx @@ -278,6 +278,7 @@ export const ProductVariant: React.FC = ({ id: variantId, removeStocks: data.removeStocks, sku: data.sku, + quantityLimitPerCustomer: data.quantityLimitPerCustomer || null, stocks: data.updateStocks.map(mapFormsetStockToStockInput), trackInventory: data.trackInventory, preorder: data.isPreorder diff --git a/src/siteSettings/components/SiteCheckoutSettingsCard/SiteCheckoutSettingsCard.tsx b/src/siteSettings/components/SiteCheckoutSettingsCard/SiteCheckoutSettingsCard.tsx index 1843f8dd9..2dd7f38e2 100644 --- a/src/siteSettings/components/SiteCheckoutSettingsCard/SiteCheckoutSettingsCard.tsx +++ b/src/siteSettings/components/SiteCheckoutSettingsCard/SiteCheckoutSettingsCard.tsx @@ -27,7 +27,8 @@ const SiteCheckoutSettingsCard: React.FC = ({ const formErrors = getFormErrors( [ "reserveStockDurationAuthenticatedUser", - "reserveStockDurationAnonymousUser" + "reserveStockDurationAnonymousUser", + "limitQuantityPerCheckout" ], errors ); @@ -84,6 +85,30 @@ const SiteCheckoutSettingsCard: React.FC = ({ }} /> + + + + ); }; diff --git a/src/siteSettings/components/SiteCheckoutSettingsCard/messages.ts b/src/siteSettings/components/SiteCheckoutSettingsCard/messages.ts index 6e8f6f62e..1fd74c06c 100644 --- a/src/siteSettings/components/SiteCheckoutSettingsCard/messages.ts +++ b/src/siteSettings/components/SiteCheckoutSettingsCard/messages.ts @@ -5,6 +5,10 @@ export const messages = defineMessages({ defaultMessage: "Reserved stock", description: "title" }, + checkoutLimits: { + defaultMessage: "Checkout limits", + description: "title" + }, reservedStockDescription: { defaultMessage: "Set up time amount that stock in checkout is reserved for the customer. You can set separate values for authenticated and anonymous customers.", @@ -18,9 +22,18 @@ export const messages = defineMessages({ defaultMessage: "Stock reservation for anonymous user (in minutes)", description: "input label" }, + checkoutLineLimit: { + defaultMessage: "Checkout line limit", + description: "input label" + }, stockWillNotBeReserved: { defaultMessage: "Leaving this setting empty will mean that stock won’t be reserved", description: "input helper text" + }, + checkoutLimitsDescription: { + defaultMessage: + "This number defines quantity of items in checkout line that can be bought. You can override this setting per variant. Leaving this setting empty mean that there is no limits.", + description: "input helper text" } }); diff --git a/src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx b/src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx index d8c2bdf37..b738220c0 100644 --- a/src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx +++ b/src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx @@ -42,6 +42,7 @@ export interface SiteSettingsPageFormData name: string; reserveStockDurationAnonymousUser: number; reserveStockDurationAuthenticatedUser: number; + limitQuantityPerCheckout: number; } export interface SiteSettingsPageProps { @@ -118,7 +119,8 @@ const SiteSettingsPage: React.FC = props => { name: shop?.name || "", reserveStockDurationAnonymousUser: shop?.reserveStockDurationAnonymousUser, reserveStockDurationAuthenticatedUser: - shop?.reserveStockDurationAuthenticatedUser + shop?.reserveStockDurationAuthenticatedUser, + limitQuantityPerCheckout: shop?.limitQuantityPerCheckout }; return ( diff --git a/src/siteSettings/fixtures.ts b/src/siteSettings/fixtures.ts index 623bbf3b2..443c97999 100644 --- a/src/siteSettings/fixtures.ts +++ b/src/siteSettings/fixtures.ts @@ -38,5 +38,6 @@ export const shop: SiteSettings_shop = { }, name: "Saleor e-commerce", reserveStockDurationAnonymousUser: 10, - reserveStockDurationAuthenticatedUser: 10 + reserveStockDurationAuthenticatedUser: 10, + limitQuantityPerCheckout: 50 }; diff --git a/src/siteSettings/types/ShopSettingsUpdate.ts b/src/siteSettings/types/ShopSettingsUpdate.ts index 990d7ca2c..56d8c1089 100644 --- a/src/siteSettings/types/ShopSettingsUpdate.ts +++ b/src/siteSettings/types/ShopSettingsUpdate.ts @@ -60,6 +60,7 @@ export interface ShopSettingsUpdate_shopSettingsUpdate_shop { name: string; reserveStockDurationAnonymousUser: number | null; reserveStockDurationAuthenticatedUser: number | null; + limitQuantityPerCheckout: number | null; } export interface ShopSettingsUpdate_shopSettingsUpdate { diff --git a/src/siteSettings/types/SiteSettings.ts b/src/siteSettings/types/SiteSettings.ts index 716cd2294..41977fd52 100644 --- a/src/siteSettings/types/SiteSettings.ts +++ b/src/siteSettings/types/SiteSettings.ts @@ -52,6 +52,7 @@ export interface SiteSettings_shop { name: string; reserveStockDurationAnonymousUser: number | null; reserveStockDurationAuthenticatedUser: number | null; + limitQuantityPerCheckout: number | null; } export interface SiteSettings { diff --git a/src/siteSettings/views/index.tsx b/src/siteSettings/views/index.tsx index 9d25c2401..afbde9999 100644 --- a/src/siteSettings/views/index.tsx +++ b/src/siteSettings/views/index.tsx @@ -84,7 +84,9 @@ export const SiteSettings: React.FC = () => { reserveStockDurationAnonymousUser: data.reserveStockDurationAnonymousUser || null, reserveStockDurationAuthenticatedUser: - data.reserveStockDurationAuthenticatedUser || null + data.reserveStockDurationAuthenticatedUser || null, + limitQuantityPerCheckout: + data.limitQuantityPerCheckout || null }, isCloudInstance: IS_CLOUD_INSTANCE } diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index c4d1dd740..acd82d4a5 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -27251,6 +27251,42 @@ exports[`Storyshots Views / Apps / Webhooks / Create webhook default 1`] = ` +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +