Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

graphQl-509: save_in_address_book has no impact on Address Book #873

Merged
merged 15 commits into from
Oct 13, 2019

Conversation

kisroman
Copy link
Contributor

@kisroman kisroman commented Aug 30, 2019

Copy link
Contributor

@lenaorobei lenaorobei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address static build failure.

@kisroman kisroman requested a review from paliarush as a code owner September 16, 2019 08:40

$customerId = $context->getUserId();
// need to save address only for registered user and if save_in_address_book = true
if (0 !== $customerId && !empty($addressInput['save_in_address_book'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please throw an exception for guests.

Copy link
Contributor Author

@kisroman kisroman Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we don't need it in this place. We have this exception in case $customerAddressId !== null

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can move this code to the top of the method.

if (false === $context->getExtensionAttributes()->getIsCustomer()) {
    throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
}

This will simplify the complexity.
And if value is expected to be boolean, please use strict comparison.

(bool)$addressInput['save_in_address_book'] === false

Copy link
Contributor Author

@kisroman kisroman Oct 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lenaorobei, Seems like we can't as with if (null === $customerAddressId) we are creating billing address for guest.
Array may don't have "save_in_address_book". So we will need double check: for isset and (bool)$addressInput['save_in_address_book'] === true. Can't we just leave only check for empty()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of PHP type casting please use isset + === true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@lenaorobei lenaorobei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider refactoring createBillingAddress and createShippingAddress methods.

@magento-engcom-team
Copy link
Contributor

Hi @lenaorobei, thank you for the review.
ENGCOM-6056 has been created to process this Pull Request

@magento-engcom-team magento-engcom-team merged commit f3e8ca5 into magento:2.3-develop Oct 13, 2019
@ghost
Copy link

ghost commented Oct 13, 2019

Hi @kisroman, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

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

Successfully merging this pull request may close these issues.

3 participants