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

When customer is set for quote order is still a guest order #38540

Open
Genaker opened this issue Mar 22, 2024 · 13 comments · May be fixed by #39320
Open

When customer is set for quote order is still a guest order #38540

Genaker opened this issue Mar 22, 2024 · 13 comments · May be fixed by #39320
Assignees
Labels
Area: Order Component: Quote Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@Genaker
Copy link

Genaker commented Mar 22, 2024

if ($this->_customer) {
$this->setCustomerId($this->_customer->getId());
}

if ($this->_customer) {
$this->setCustomerId($this->_customer->getId());
}

You need to change it to

if ($this->_customer) {
$this->setCustomerId($this->_customer->getId());
$this->setCustomerIsGuest(0);
}

or incapsulate this logic into setCustomerId() method

Additional Information:
This issue is caused when checking out from a guest cart programmatically, when you assign a customer to the cart before submitting it to place the order, the quote remains as guest even though a customer has been assigned.

Copy link

m2-assistant bot commented Mar 22, 2024

Hi @Genaker. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@Genaker
Copy link
Author

Genaker commented Mar 22, 2024

there is test cases:

$customer = $this->customerRepository->getById($customerId);

        $output->writeln('is order for guest : ' . $quote->getCustomerIsGuest());
        $output->writeln("Customer ID:" . $customer->getId());
        // Assign the customer to the quote
        $quote->assignCustomer($customer);
        $quote->setCustomerId($customer->getId());
        $output->writeln('is order for guest after assign customer and set customer ID : ' . $quote->getCustomerIsGuest());


        $output->writeln('is order for guest after set setCustomerIsGuest : ' . $quote->getCustomerIsGuest());

output 👍

image

the same issue for quote/cart or for order doesn't matte.
please fix this issue in the core.

@engcom-Dash engcom-Dash self-assigned this Mar 22, 2024
Copy link

m2-assistant bot commented Mar 22, 2024

Hi @engcom-Dash. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

@engcom-Dash engcom-Dash removed their assignment Mar 22, 2024
@engcom-Dash engcom-Dash added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Mar 22, 2024
@engcom-Bravo engcom-Bravo added the Reported on 2.4.x Indicates original Magento version for the Issue report. label Mar 22, 2024
@engcom-November engcom-November self-assigned this Mar 22, 2024
Copy link

m2-assistant bot commented Mar 22, 2024

Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-November
Copy link
Contributor

Hello @Genaker,

Thank you for the report and contribution!

Tried to verify this issue on 2.4-develop, but in our case it is not reproducible.
Signed in as a customer, and added the product to cart, but customer_is_guest was 0.

Please take a look at the screenshot below:
image

Please let us know if any preconditions are required for the issue to be reproduced, and also if we are missing anything.

Thank you.

@engcom-November engcom-November added the Issue: needs update Additional information is require, waiting for response label Mar 22, 2024
@Genaker
Copy link
Author

Genaker commented Mar 22, 2024

You should submit an order not through the front but by code: it is not a front issue

        $quoteMaskedHash = //Real cart with the items mask 
        $quoteId = $this->getQuoteIdFromMaskedHash($quoteMaskedHash);

        $customerId = //SomeCustomerID
        $quote = $this->quoteRepository->get($quoteId);
        $customer = $this->customerRepository->getById($customerId);

        // Assign the customer to the quote there quote must be not guest 
        $quote->assignCustomer($customer);

        $billingAddress = [
            'firstname' => 'John',
            'lastname' => 'Doe',
            'email' => '[email protected]',
            'street' => '123 Main St',
            'city' => 'Anytown',
            'country_id' => 'US',
            'region' => 'NY',
            'postcode' => '12345',
            'telephone' => '1234567890',
            'save_in_address_book' => 0
        ];

        $quote->getBillingAddress()->addData($billingAddress);

        $shippingAddress = [
            'firstname' => 'John',
            'lastname' => 'Doe',
            'email' => '[email protected]',
            'street' => '123 Main St',
            'city' => 'Anytown',
            'country_id' => 'US',
            'region' => 'NY',
            'postcode' => '12345',
            'telephone' => '1234567890',
            'save_in_address_book' => 0
        ];

        $quote->getShippingAddress()->addData($shippingAddress);

        $shippingAddress = $quote->getShippingAddress();
        $shippingAddress->setCollectShippingRates(true)
            ->collectShippingRates()
            ->setShippingMethod('freeshipping_freeshipping'); // For Free Shipping

        $quote->setPaymentMethod('checkmo'); // For Check / Money order
        $quote->setInventoryProcessed(false); // Prevents inventory decrement

        $quote->getPayment()->importData(['method' => 'checkmo']);

        // Attempt to save the quote and create an order from it
        $quote->collectTotals()->save();

        ///Quote is still guest 

@engcom-November
Copy link
Contributor

Hello @Genaker,

Thank you for the quick response!

Verified this issue on 2.4-develop.
When checking out from a guest quote programmatically, after assigning a customer to the quote, customer_is_guest remains 1.

Please take a look at the screenshot below:
image
The value of customer_is_guest should have been 0, but it remains 1.
Hence confirming this issue.

Please find the custom module used to reproduce this issue.
I38540V.zip

Thank you.

@engcom-November engcom-November added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Quote Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Order labels Mar 25, 2024
@m2-community-project m2-community-project bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Mar 25, 2024
@m2-community-project m2-community-project bot added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: needs update Additional information is require, waiting for response labels Mar 25, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-11689 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Mar 25, 2024

✅ Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@github-jira-sync-bot
Copy link

❌ You don't have permission to export this issue.

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Mar 26, 2024
@shmVan
Copy link
Contributor

shmVan commented Jul 11, 2024

@magento I am working on this

shmVan added a commit to shmVan/magento2 that referenced this issue Jul 12, 2024
…order

- fix Module Magento\Quote: added $this->setCustomerIsGuest(false) if isset customer Quote for function beforeSave().
@engcom-Hotel engcom-Hotel moved this to Pull Request In Progress in High Priority Backlog Aug 19, 2024
shmVan added a commit to shmVan/magento2 that referenced this issue Nov 3, 2024
…order

- The object $this->_customer always exists. Added a check for the existence of $this->getCustomerId() / If it is true  $this->setCustomerIsGuest(false);
@shmVan
Copy link
Contributor

shmVan commented Nov 3, 2024

@magento I am working on this

@Genaker
Copy link
Author

Genaker commented Nov 3, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Order Component: Quote Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: Pull Request In Progress
7 participants