Skip to content

4. Technical Design

NoorulBhoelai edited this page Feb 16, 2018 · 12 revisions

User Story 1:

As a Merchant I want all placed GuestOrders automatically be linked to an existing Customer(/ShadowCustomer) based on the email address of the order.

Proposed Solution:

  • Use the \Magento\Quote\Model\QuoteManagement::submit function Before plugin and link the GuestOrder to the Customer by first fetching the Quote customer e-mail address and find existing Customers. If RESULT FOUND, invoke setCustomer() and setCustomerId() with found Customer data.
  • Apply $quote->setCustomerIsGuest(false)

Proposed Solution for Integration Test:

Use the following Magento Data Fixtures:

  • Use the tddwizard quote/customer to order fixture.

User Story 2:

As a Merchant I want all placed GuestOrders that can’t be automatically linked to a Customer/ShadowCustomer (because it doesn’t exist) automatically create a ShadowCustomer.

Proposed Solution:

  • Use the \Magento\Quote\Model\QuoteManagement::submit function Before plugin and link the GuestOrder to the Customer by first fetching the Quote customer e-mail address and find existing Customers. If RESULT NOT FOUND, invoke setCustomer() and setCustomerId() after creating an account for the guest.
  • Apply $quote->setCustomerIsGuest(false)

Proposed Solution for Integration Test:

Use the following Magento Data Fixtures:

  • Create issue for tddwizard and test manually in the frontend by creating a GuestOrder.

User Story 3:

As a Merchant I want all historic GuestOrders to be linked to Customers / Create new ShadowCustomers based on the above criteria.

Proposed Solution:

  • Create cronjob with schedule_generate_every 15 minutes, with a limit GuestOrders search of X (configurable setting)
  • Lookup all orders in \Magento\Sales\Api\OrderRepositoryInterface::getList() where getCustomerIsGuest is false.
  • Loop through each order and apply the same logic as in Story 1/2 with a BeforeSave plugin for \Magento\Sales\Api\OrderRepositoryInterface::save
  • (Should we create a helper class and function for the try/catch account creation??)

Proposed Solution for Integration Test:

Use the following Magento Data Fixtures:

  • create customer fixture (with e-mail address: [email protected])
  • Fetch orders: Magento/Sales/_files/order_list.php (set one order with customer e-mail address to [email protected]

User Story 4:

As a Visitor I shouldn’t know that a ShadowCustomer is being created: I shouldn’t receive email communication about it.

User Story 5:

As a Visitor I shouldn’t know that a GuestOrder is being converted to a ShadowCustomerOrder: Order email communication should be as if I have placed a GuestOrder.

Proposed Solution:

  • Set $this->_registry->registry("skip_confirmation_if_email") to false.
  • ``/**
    • Check whether confirmation may be skipped when registering using certain email address

    • @return bool */ protected function canSkipConfirmation() { if (!$this->getId()) { return false; }

      /* If an email was used to start the registration process and it is the same email as the one used to register, then this can skip confirmation. */ $skipConfirmationIfEmail = $this->_registry->registry("skip_confirmation_if_email"); if (!$skipConfirmationIfEmail) { return false; }

      return strtolower($skipConfirmationIfEmail) === strtolower($this->getEmail()); }``

Proposed Solution for Integration Test:

  • Use the tddwizard quote/customer to order fixture. In the test you should use the assertFalse function with $this->_registry->registry("skip_confirmation_if_email")
Clone this wiki locally