Helper/Cart.php
public function getHints($cartReference = null, $checkoutType = 'admin')
    {
        /** @var Quote */
        $quote = $cartReference ?
            $this->getQuoteById($cartReference) :
            $this->checkoutSession->getQuote();

        $hints = ['prefill' => []];

        /**
         * Update hints from address data
         *
         * @param Address $address
         */
        $prefillHints = function ($address) use (&$hints, $quote) {

            if (!$address) {
                return;
            }

            $prefill = [
                'firstName'    => $address->getFirstname(),
                'lastName'     => $address->getLastname(),
                'email'        => $address->getEmail() ?: $quote->getCustomerEmail(),
                'phone'        => $address->getTelephone(),
                'addressLine1' => $address->getStreetLine(1),
                'addressLine2' => $address->getStreetLine(2),
                'city'         => $address->getCity(),
                'state'        => $address->getRegion(),
                'zip'          => $address->getPostcode(),
                'country'      => $address->getCountryId(),
            ];

            foreach ($prefill as $name => $value) {
                if (empty($value)) {
                    unset($prefill[$name]);
                }
            }

            $hints['prefill'] = array_merge($hints['prefill'], $prefill);
        };

        // Logged in customes.
        // Merchant scope and prefill.
        if ($this->customerSession->isLoggedIn()) {
            $customer = $this->customerSession->getCustomer();

            $signRequest = [
                'merchant_user_id' => $customer->getId(),
            ];
            $signResponse = $this->getSignResponse($signRequest)->getResponse();

            if ($signResponse) {
                $hints['merchant_user_id'] = $signResponse->merchant_user_id;
                $hints['signature'] = $signResponse->signature;
                $hints['nonce'] = $signResponse->nonce;
            }

            if ($quote->isVirtual()) {
                $prefillHints($customer->getDefaultBillingAddress());
            } else {
                $prefillHints($customer->getDefaultShippingAddress());
            }

            $hints['prefill']['email'] = $customer->getEmail();
        }

        // Quote shipping / billing address.
        // If assigned it takes precedence over logged in user default address.
        if ($quote->isVirtual()) {
            $prefillHints($quote->getBillingAddress());
        } else {
            $prefillHints($quote->getShippingAddress());
        }

        if ($checkoutType === 'admin') {
            $hints['virtual_terminal_mode'] = true;
        }

        return $hints;
    }
public function getHints($cartReference = null, $checkoutType = 'admin')
    {
        /** @var Quote */
        $quote = $cartReference ?
            $this->getQuoteById($cartReference) :
            $this->checkoutSession->getQuote();

        $hints = ['prefill' => []];

        /**
         * Update hints from address data
         *
         * @param Address $address
         */
        $prefillHints = function ($address) use (&$hints, $quote) {

            if (!$address) {
                return;
            }

            $prefill = [
                'firstName'    => $address->getFirstname(),
                'lastName'     => $address->getLastname(),
                'email'        => $address->getEmail() ?: $quote->getCustomerEmail(),
                'phone'        => $address->getTelephone(),
                'addressLine1' => $address->getStreetLine(1),
                'addressLine2' => $address->getStreetLine(2),
                'city'         => $address->getCity(),
                'state'        => $address->getRegion(),
                'zip'          => $address->getPostcode(),
                'country'      => $address->getCountryId(),
            ];

            foreach ($prefill as $name => $value) {
                if (empty($value)) {
                    unset($prefill[$name]);
                }
            }

            $hints['prefill'] = array_merge($hints['prefill'], $prefill);
        };

        // Logged in customes.
        // Merchant scope and prefill.
        if ($this->customerSession->isLoggedIn()) {
            $customer = $this->customerSession->getCustomer();

            $signRequest = [
                'merchant_user_id' => $customer->getId(),
            ];
            $signResponse = $this->getSignResponse($signRequest)->getResponse();

            if ($signResponse) {
                $hints['merchant_user_id'] = $signResponse->merchant_user_id;
                $hints['signature'] = $signResponse->signature;
                $hints['nonce'] = $signResponse->nonce;
            }

            if ($quote->isVirtual()) {
                $prefillHints($customer->getDefaultBillingAddress());
            } else {
                $prefillHints($customer->getDefaultShippingAddress());
            }

            $hints['prefill']['email'] = $customer->getEmail();
        }

        // Quote shipping / billing address.
        // If assigned it takes precedence over logged in user default address.
        if ($quote->isVirtual()) {
            $prefillHints($quote->getBillingAddress());
        } else {
            $prefillHints($quote->getShippingAddress());
        }

        if ($checkoutType === 'admin') {
            $hints['virtual_terminal_mode'] = true;
        }

        return $hints;
    }
public function getHints ( $ cartReference = null , $ checkoutType = 'admin' ) { /** @var Quote */ $ quote = $ cartReference ? $ this -> getQuoteById ( $ cartReference ) : $ this -> checkoutSession -> getQuote ( ) ; $ hints = [ 'prefill' => [ ] ] ; /**
         * Update hints from address data
         *
         * @param Address $address
         */ $ prefillHints = function ( $ address ) use ( & $ hints , $ quote ) { if ( ! $ address ) { return ; } $ prefill = [ 'firstName' => $ address -> getFirstname ( ) , 'lastName' => $ address -> getLastname ( ) , 'email' => $ address -> getEmail ( ) ? : $ quote -> getCustomerEmail ( ) , 'phone' => $ address -> getTelephone ( ) , 'addressLine1' => $ address -> getStreetLine ( 1 ) , 'addressLine2' => $ address -> getStreetLine ( 2 ) , 'city' => $ address -> getCity ( ) , 'state' => $ address -> getRegion ( ) , 'zip' => $ address -> getPostcode ( ) , 'country' => $ address -> getCountryId ( ) , ] ; foreach ( $ prefill as $ name => $ value ) { if ( empty ( $ value ) ) { unset ( $ prefill [ $ name ] ) ; } } $ hints [ 'prefill' ] = array_merge ( $ hints [ 'prefill' ] , $ prefill ) ; } ; // Logged in customes. // Merchant scope and prefill. if ( $ this -> customerSession -> isLoggedIn ( ) ) { $ customer = $ this -> customerSession -> getCustomer ( ) ; $ signRequest = [ 'merchant_user_id' => $ customer -> getId ( ) , ] ; $ signResponse = $ this -> getSignResponse ( $ signRequest ) -> getResponse ( ) ; if ( $ signResponse ) { $ hints [ 'merchant_user_id' ] = $ signResponse -> merchant_user_id ; $ hints [ 'signature' ] = $ signResponse -> signature ; $ hints [ 'nonce' ] = $ signResponse -> nonce ; } if ( $ quote -> isVirtual ( ) ) { $ prefillHints ( $ customer -> getDefaultBillingAddress ( ) ) ; } else { $ prefillHints ( $ customer -> getDefaultShippingAddress ( ) ) ; } $ hints [ 'prefill' ] [ 'email' ] = $ customer -> getEmail ( ) ; } // Quote shipping / billing address. // If assigned it takes precedence over logged in user default address. if ( $ quote -> isVirtual ( ) ) { $ prefillHints ( $ quote -> getBillingAddress ( ) ) ; } else { $ prefillHints ( $ quote -> getShippingAddress ( ) ) ; } if ( $ checkoutType === 'admin' ) { $ hints [ 'virtual_terminal_mode' ] = true ; } return $ hints ; }
Get the hints data for checkout

@param string $cartReference            (immutable) quote id
@param string $checkoutType             'cart' | 'admin' Default to `admin`

@return array
@throws NoSuchEntityException
Get the hints data for checkout