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

Fix shipping address can use for billing #10130

Merged

Conversation

tufahu
Copy link
Contributor

@tufahu tufahu commented Jul 3, 2017

Description

Fix bug on checkout process, when billing address is empty at quote and magento tries to use shipping address as billing address. Currently it ignores the property of address canUseForBilling.

Use current shipping address as billing address only if address is marked as canUseForBilling
@ishakhsuvarov
Copy link
Contributor

Hi @tufahu
Could you please specify more precise steps to reproduce the issue you are fixing with this PR?
Thanks

@tufahu
Copy link
Contributor Author

tufahu commented Jul 4, 2017

Hi @ishakhsuvarov!

The base functionality has no problem with this implementation, because base address classes have canUseForBilling is hardcoded with value true.

refs:
https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js#L101
https://github.com/magento/magento2/blob/develop/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js#L94

So every time magento, handle all address can be used for billing too.

I've written a magento shipping module (shipping to pickup points) where I add a new address at checkout process to quote. These are only shipping adresses (gasoil stations etc), what i want is to customer cannot select address as billing too, and customer have to set a different billing address.

The current implementation ignores this. If i set canUseForBilling false on address, magento add the choice for customer to tick [x] billing and shipping is the same which is wrong.

@tufahu
Copy link
Contributor Author

tufahu commented Jul 4, 2017

And if you read the default code part

        if (!quote.billingAddress()) {
            selectBillingAddressAction(quote.shippingAddress());
        }

If there is no billing address -> set shipping Address as Billing Address
I guess it is not 100%. Seems better with my patch.

        if (!quote.billingAddress() && quote.shippingAddress().canUseForBilling()) {
            selectBillingAddressAction(quote.shippingAddress());
        }

If there is no billing address -> set shipping Address as Billing Address if this Shipping Address Can be used for Billing

@ishakhsuvarov
Copy link
Contributor

If there is no billing address -> set shipping Address as Billing Address if this Shipping Address Can be used for Billing

@tufahu What happens with the billing address controls in this case? Is it handled properly by default? I'm afraid we may get into the case where customer attempts to place an order with no billing address at all and will get an exception from the API call.

I'll check out the branch and do some testing to get the better grip of the idea.
Thanks!

@ishakhsuvarov ishakhsuvarov self-assigned this Jul 5, 2017
@ishakhsuvarov ishakhsuvarov added this to the July 2017 milestone Jul 5, 2017
@ishakhsuvarov ishakhsuvarov requested review from omiroshnichenko and removed request for omiroshnichenko July 5, 2017 10:30
@magento-team magento-team merged commit 7da5405 into magento:develop Jul 18, 2017
magento-team pushed a commit that referenced this pull request Jul 18, 2017
[EngCom] Public Pull Requests

 - MAGETWO-70817: remove redundant else and use strict check #10271
 - MAGETWO-70787: update phpserver to support versioned static urls #10250
 - MAGETWO-70764: Fix overwrite default value image/file with NULL #10253
 - MAGETWO-70761: Show values that are duplicate in attribute error msg #10213
 - MAGETWO-70758: Fix for #4530 $product->getRatingSummary() always returns null […] #10248
 - MAGETWO-70706: simplify product lists #2 #9019
 - MAGETWO-70669: Fix fatal errors with deleteOptionsAndSelections #7711
 - MAGETWO-70464: Fix shipping address can use for billing #10130
 - MAGETWO-69913: magento/magento2 #9196 - Products ordered report doesn't show simple (child) products of configurable products #9908
@tufahu
Copy link
Contributor Author

tufahu commented Nov 16, 2017

Sorry i've missed to answer to this thread. It is handled properly by default, without any problems. Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants