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

order.shippingMethod returns null #598

Closed
sjelfull opened this issue Dec 6, 2018 · 1 comment
Closed

order.shippingMethod returns null #598

sjelfull opened this issue Dec 6, 2018 · 1 comment

Comments

@sjelfull
Copy link
Contributor

sjelfull commented Dec 6, 2018

Description

When placing an order with a custom shipping method, Commerce will try to look up the shipping method from the database when order.shippingMethod is called.

This crashes the order details screen, among other things.

The shipping method is available from getAvailableShippingMethods()

Steps to reproduce

  1. Place order with custom shipping method
  2. Go to order details screen or call order.shippingMethod
@sjelfull
Copy link
Contributor Author

Replacing the existing method with this one on craft\commerce\elements\Order fixes this:

/**
 * @return ShippingMethod|null
 */
public function getShippingMethod()
{
    $shippingMethods = Plugin::getInstance()->getShippingMethods()->getAvailableShippingMethods($this);

    return $shippingMethods[$this->shippingMethodHandle] ?? null;
}

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