It would be nice to be able to use the shipping address as a condition on the order entity as well. For example Payment methods could be restricted using this. This was my use case since we don't want to have a manual "Invoice" payment method available globally, but only in the orgin country.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lukas von Blarer created an issue. See original summary.

Lukas von Blarer’s picture

Status: Active » Needs review
FileSize
1.72 KB

Here is a first patch.

Currently the condition can only take the first shipment into account.

flocondetoile’s picture

attached the same patch with some small improvements:

- removed unused declarations
- typo fix about $order vs $shipment
- prevent a fatal error if order's shipments are empty.

dwkitchen’s picture

Updating to align with #3170419: Move all Shipping Conditions to the Shipping Category

Needs test before acceptance - can probably be replicated from commerce/modules/order/tests/src/Unit/Plugin/Commerce/Condition/OrderBillingAddressTest.php

khiminrm’s picture

khiminrm’s picture

added missed ShipmentAddressOrder.php file in #5

khiminrm’s picture

Status: Needs work » Needs review
jsacksick’s picture

I've been thinking about this... And actually, we could provide this from Commerce directly.

The problem is, we already have a condition for the shipment, that adds a "Shipping address" condition under the "Customer" category (which means, on the shipping methods admin, we'll end up with a duplicate "Shipping address" condition.

Commerce could offer an OrderShippingAddress plugin (or eventually reuse the same plugin for both the billing & the shipping address, using a deriver.

Commerce has a collectProfiles() method on orders, that is what we should be using, and not get the address from the first shipment.

jsacksick’s picture

Component: Documentation » Order
SocialNicheGuru’s picture

So I better understand the "Shipping address" condition under Customer applies to the billing address?

Without the patch I get the following:
I am currently trying to restrict to a zip code.
If the billing zipcode that I enter is in the allowed zip code but the shipping zip code is not in the allowed, shipping is still allowed.

jsacksick’s picture

Status: Needs work » Needs review
FileSize
10.99 KB

I worked on the new condition. The problem is... I'm no longer sur why we actually need this :), since the Commerce shipping module provides a condition already?

jsacksick’s picture

Refreshed my memory, commerce_shipping provides a condition that works for shipments.

SocialNicheGuru’s picture

Under customer there is a shipping address condition.
Is that shipping condition applied to a customer, a person who has already purchased and has a saved shipping address on file? Can it be applied to anonymous users?

I do not know enough about the Customer shipping condition to know why this patch is needed. Or why the current customer shipping condition cannot provide a solution to what the person who posted this issue wanted.

Can anyone provide a little more guidance?

  • jsacksick committed f87fcac on 8.x-2.x
    Issue #3067035 by khiminrm, flocondetoile, jsacksick, Lukas von Blarer,...
jsacksick’s picture

Status: Needs review » Fixed

Went ahead and committed the patch.

  • jsacksick committed 36a5793 on 3.0.x
    Issue #3067035 by khiminrm, flocondetoile, jsacksick, Lukas von Blarer,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.