Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the list of shipping-method from api/basket/shipping-methods/ #360

Open
gmaOCR opened this issue Oct 22, 2024 · 0 comments
Open

Comments

@gmaOCR
Copy link

gmaOCR commented Oct 22, 2024

An empty basket returns directly the "NoShippingRequired" function:

    def get_shipping_methods(self, basket, shipping_addr=None, **kwargs):
        """
        Return a list of all applicable shipping method instances for a given
        basket, address etc.
        """
        if not basket.is_shipping_required():
            # Special case! Baskets that don't require shipping get a special
            # shipping method.

            return [NoShippingRequired()]

The previous method basket.is_shipping_required() calls in AbstractBasket:

    def is_shipping_required(self):
        """
        Test whether the basket contains physical products that require
        shipping.
        """
        for line in self.all_lines():
            if line.product.is_shipping_required:
                return True
        return False

I suggest:

def is_shipping_required(self):
    """
    Test whether the basket contains physical products that require
    shipping.
    """
    if not self.all_lines():
        return True  
    for line in self.all_lines():
        if line.product.is_shipping_required:
            return True
    return False

We will be able to have the shipping list and only the case with all products WITHOUT shipping requirements will return the default "no shipping required"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant