Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update changelog for shipping methods, code style tweaks (#9180)
Krzysztof Kulig6b7dd82a9f7e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ccb92994c0..eb1370aeb4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -53,6 +53,8 @@ All notable, unreleased changes to this project will be documented in this file.`CheckoutAddPromoCode`, `CheckoutPaymentCreate` will raise a ValidationError when product in the checkout isunavailable - #8978 by @IKarbowiak- Fix disabled warehouses appearing as valid click and collect points when checkout contains only preorders - #9052 by @rafalp+- Add support for providing shipping methods by Saleor Apps - #7975 by @bogdal:+ - Add `SHIPPING_LIST_METHODS_FOR_CHECKOUT` sync webhook- Fix crash when Avalara plugin was used together with Webhooks plugin for shipping methods - #9121 by @rafalp- Allow fetching unpublished pages by app with manage pages permission - #9181 by @IKarbowiak@@ -87,6 +89,8 @@ unavailable - #8978 by @IKarbowiak- Rename checkout interfaces: `CheckoutTaxedPricesData` instead of `TaxedPricesData`and `CheckoutPricesData` instead of `PricesData`- Sign JWT tokens with RS256 instead of HS256 - #7990 by @korycins+- Add support for filtering available shipping methods by Saleor Apps - #8399 by @kczan, @stnatic+ - Introduce `ShippingMethodData` interface as a root object type for ShippingMethod object- Limit number of user addresses - #9173 by @IKarbowiak#### GraphQL Schema@@ -120,6 +124,10 @@ unavailable - #8978 by @IKarbowiak- `ShippingPriceInput` was extended with `description` field- Extended `shippingPriceUpdate`, `shippingPriceCreate` mutation to add/edit description- Input field in `shippingPriceTranslate` changed to `ShippingPriceTranslationInput`+- Split `ShippingMethod` into `ShippingMethod` and `ShippingMethodType` (#8399):+ - `ShippingMethod` is used to represent methods offered for checkouts and orders+ - `ShippingMethodType` is used to manage shipping method configurations in Saleor+ - Deprecate `availableShippingMethods` on `Order` and `Checkout`. Use `shippingMethods` and refer to the `active` field instead#### Saleor Apps@@ -130,6 +138,7 @@ unavailable - #8978 by @IKarbowiak- Remove triggering a webhook event `PRODUCT_UPDATED` when calling `ProductVariantCreate` mutation. Use `PRODUCT_VARIANT_CREATED` instead - #6963 by @piotrgrundas- Make `order` property of invoice webhook payload contain order instead of order lines - #7081 by @pdblaszczyk- Affected webhook events: `INVOICE_REQUESTED`, `INVOICE_SENT`, `INVOICE_DELETED`+- Added `CHECKOUT_FILTER_SHIPPING_METHODS`, `ORDER_FILTER_SHIPPING_METHODS` sync webhooks - #8399 by @kczan, @stnatic#### Pluginsdiff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 5c6f1c2c1a..6243520be0 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -39,6 +39,7 @@ from ...core.permissions import AccountPermissionsfrom ...core.tracing import traced_atomic_transactionfrom ...core.transactions import transaction_with_commit_on_errorsfrom ...order import models as order_models+from ...plugins.webhook.utils import APP_ID_PREFIXfrom ...product import models as product_modelsfrom ...product.models import ProductChannelListingfrom ...shipping import interface as shipping_interface@@ -1227,7 +1228,7 @@ class CheckoutShippingMethodUpdate(BaseMutation):if id_ is None:return None- possible_types = ("ShippingMethod", "app")+ possible_types = ("ShippingMethod", APP_ID_PREFIX)type_, id_ = from_global_id_or_error(id_)str_type = str(type_)@@ -1553,7 +1554,7 @@ class CheckoutDeliveryMethodUpdate(BaseMutation):if id_ is None:return None- possible_types = ("Warehouse", "ShippingMethod", "app")+ possible_types = ("Warehouse", "ShippingMethod", APP_ID_PREFIX)type_, id_ = from_global_id_or_error(id_)str_type = str(type_)diff --git a/saleor/graphql/order/utils.py b/saleor/graphql/order/utils.pyindex d0fa901147..632b757ab3 100644--- a/saleor/graphql/order/utils.py+++ b/saleor/graphql/order/utils.py@@ -37,6 +37,7 @@ def get_shipping_method_availability_error(manager: "PluginsManager",):"""Validate whether shipping method is still available for the order."""+ is_valid = Falseif method:valid_methods_ids = {m.id@@ -48,8 +49,6 @@ def get_shipping_method_availability_error(if m.active}is_valid = method.id in valid_methods_ids- else:- is_valid = Falseif not is_valid:return ValidationError(diff --git a/saleor/graphql/shipping/types.py b/saleor/graphql/shipping/types.pyindex 0791dfbdab..2c526579ed 100644--- a/saleor/graphql/shipping/types.py+++ b/saleor/graphql/shipping/types.py@@ -345,7 +345,7 @@ class ShippingMethod(graphene.ObjectType):class Meta:interfaces = [relay.Node, ObjectWithMetadata]description = (- "Shipping methods that can be used as means of shipping"+ "Shipping methods that can be used as means of shipping ""for orders and checkouts.")diff --git a/saleor/plugins/webhook/shipping.py b/saleor/plugins/webhook/shipping.pyindex 9f8e4868e6..9941000f23 100644--- a/saleor/plugins/webhook/shipping.py+++ b/saleor/plugins/webhook/shipping.py@@ -129,7 +129,7 @@ def get_excluded_shipping_methods_from_response(try:raw_id = method_data["id"]typename, _id = graphene.Node.from_global_id(raw_id)- if typename == "app":+ if typename == APP_ID_PREFIX:method_id = raw_idelif typename == "ShippingMethod":method_id = _iddiff --git a/saleor/shipping/interface.py b/saleor/shipping/interface.pyindex 7fada20ce7..21f233e794 100644--- a/saleor/shipping/interface.py+++ b/saleor/shipping/interface.py@@ -7,6 +7,7 @@ from measurement.measures import Weightfrom prices import Moneyfrom ..graphql.core.utils import from_global_id_or_error+from ..plugins.webhook.utils import APP_ID_PREFIX@dataclass@@ -37,7 +38,7 @@ class ShippingMethodData:except graphql.error.base.GraphQLError:passelse:- return str_type == "app"+ return str_type == APP_ID_PREFIXreturn False