1

We our developing a Drupal 8 Commerce website that does not need anything to do with addresses

  • The products are all virtual: membership and event tickets.
  • The billing is using PayPal express which takes care of billing address.

Therefore we don't want to prompt the customer to fill in an address, or store an address, or give them an "addresses" tab on their profile. Please can anyone advise how to configure this scenario?

So far we have considered:

  1. Edit the commerce flow. The BillingInformation pane gets included via PaymentInformation. If we remove PaymentInformation it does suppress the prompt for address and suppress the creation of a profile, but unfortunately it seems to stop the payment step from working properly.

  2. Edit the customer profile form display to disable the address field. This does suppress the prompt for an address, but we find that an empty profile is created for every order.

  3. Delete the customer profile type. We didn't try it yet because it seems likely to break the site as the Commerce core code has various hard-coded references to that profile type.

As an secondary question, we'd also prefer not to enter an address for the store as it does not have a physical address. However the address seems to be mandatory and does not allow country=none. We have entered a dummy value which seems to work as so far we haven't seen it used. Can we trust the dummy address will never be used, and if so, would it be reasonable to say that the address ought to be an optional field?

1
  • How about settings standard dummy values and adjust css to display:none it all related pages?
    – Justme
    Jun 21, 2018 at 7:42

2 Answers 2

4

The store address is used for calculating taxes. It doesn't have to be a physical store address, enter the address the business entity is registered to.

On the store edit form select a single "Allowed billing country". That will hide the country selector on all of your address fields.

Then go to admin/config/people/profiles/manage/customer/fields/profile.customer.address and under "Field overrides" select "Hidden" for each field. That will hide the other address subfields.

You need to be on the latest Commerce release for this to work.

(And yes, an empty profile with just the country code will be created for each order. There is no way around that currently)

5
  • Many thanks @Bojan. This seems similar to #2 that we tried as described in the question - it works fairly well except the profiles. I'll leave the question open for a while in case anyone has success customising PaymentInformation. I plan to raise a Feature Issue on Drupal.org - please comment if you don't want that.
    – AdamS
    Jun 25, 2018 at 20:06
  • 1
    There's already one: drupal.org/project/commerce/issues/2905028 Jun 26, 2018 at 11:10
  • Thanks for the link. I see an unwanted empty "Payment information" box (whether using the patch or using the above method). I hid it by overriding wrapper_element = "container". If logged in, the whole "Order information" step is unnecessary. When I altered the flow to try and work around that I hit a bug drupal.org/project/commerce/issues/2981922. So it's sort of working but a bit awkward at the moment.
    – AdamS
    Jun 26, 2018 at 21:22
  • 1
    Please open new issues. Looks like we'll have to keep working on this. Not collecting billing addresses is a new use case for Commerce 2.x, so this is fresh territory for us. Jul 6, 2018 at 14:46
  • Thanks @Bojan - I already raised issues for all the problems I know about and they are linked in the answer below.
    – AdamS
    Jul 9, 2018 at 8:22
2

Credit: many thanks to @Bojan for the information in his answer, please join me in +1 to him. I created this new answer to explain some details more clearly and add some new factors that I have discovered.

1) To avoid the empty profile:

  • EITHER apply the "highly experimental" patch from this issue
  • OR derive your own class that extends PaymentInformation and cut out everything relating to profiles. However in that case you will hit this issue.

2) If there is just one payment method, this leads to an unwanted empty "Payment information" pane. One way to fix that is to alter the checkout pane and set wrapper_element = "container".

3) If there is just one payment method, then when logged in, the whole "Order information" step is not necessary. One way to fix that is to edit the checkout flow and move "Payment information" to the review step. However you will then hit this bug and need to apply the patch.

1
  • Good answer. I encountered the PaymentInformation issue, as the issue describes though, you need to extend the class without the annotation and use the appropriate hook to tell Drupal about the class in which overrides PaymentInformation. It's rather simple from there to, as you say, cut out everything related to profiles and or customise said to meet your business requirements. On point 3, I've found best way to tame the checkout process is to create your own checkout flow extending CheckoutFlowWithPanesBase then build panes/render arrays to suit without all the "gotcha" scenarios.
    – Adam
    Feb 18, 2020 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.