本文整理匯總了PHP中Magento\Quote\Model\Quote::getCustomer方法的典型用法代碼示例。如果您正苦於以下問題:PHP Quote::getCustomer方法的具體用法?PHP Quote::getCustomer怎麽用?PHP Quote::getCustomer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Quote\Model\Quote
的用法示例。
在下文中一共展示了Quote::getCustomer方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _involveNewCustomer
/**
* Involve new customer to system
*
* @return $this
*/
protected function _involveNewCustomer()
{
$customer = $this->_quote->getCustomer();
$confirmationStatus = $this->_accountManagement->getConfirmationStatus($customer->getId());
if ($confirmationStatus === AccountManagement::ACCOUNT_CONFIRMATION_REQUIRED) {
$this->_messageManager->addSuccess(__('Thank you for registering with Main Website Store.'));
} else {
$this->getCustomerSession()->regenerateId();
$this->getCustomerSession()->loginById($customer->getId());
}
return $this;
}
示例2: _involveNewCustomer
/**
* Involve new customer to system
*
* @return $this
*/
protected function _involveNewCustomer()
{
$customer = $this->_quote->getCustomer();
$confirmationStatus = $this->_accountManagement->getConfirmationStatus($customer->getId());
if ($confirmationStatus === AccountManagement::ACCOUNT_CONFIRMATION_REQUIRED) {
$url = $this->_customerUrl->getEmailConfirmationUrl($customer->getEmail());
$this->_messageManager->addSuccess(__('Account confirmation is required. Please check your email for confirmation link. To resend confirmation email please <a href="%1">click here</a>.', $url));
} else {
$this->getCustomerSession()->regenerateId();
$this->getCustomerSession()->loginById($customer->getId());
}
return $this;
}
示例3: testSetCustomerAddressData
/**
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function testSetCustomerAddressData()
{
$customerId = 1;
$addressMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false, true, true, ['getId']);
$addressMock->expects($this->any())->method('getId')->will($this->returnValue(null));
$addresses = [$addressMock];
$customerMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false);
$customerResultMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false);
$this->customerRepositoryMock->expects($this->once())->method('getById')->will($this->returnValue($customerMock));
$customerMock->expects($this->once())->method('getAddresses')->will($this->returnValue($addresses));
$result = $this->quote->setCustomerAddressData([$addressMock]);
$this->assertInstanceOf('Magento\\Quote\\Model\\Quote', $result);
$this->assertEquals($customerResultMock, $this->quote->getCustomer());
}
示例4: populateCustomerInfo
/**
* Populate customer model
*
* @param Quote $quote
* @return void
*/
public function populateCustomerInfo(QuoteEntity $quote)
{
$customer = $quote->getCustomer();
if (!$customer->getId()) {
$customer = $this->accountManagement->createAccountWithPasswordHash($customer, $quote->getPasswordHash());
$quote->setCustomer($customer);
} else {
$this->customerRepository->save($customer);
}
if (!$quote->getBillingAddress()->getId() && $customer->getDefaultBilling()) {
$quote->getBillingAddress()->importCustomerAddressData($this->customerAddressRepository->getById($customer->getDefaultBilling()));
$quote->getBillingAddress()->setCustomerAddressId($customer->getDefaultBilling());
}
if (!$quote->getShippingAddress()->getSameAsBilling() && !$quote->getBillingAddress()->getId() && $customer->getDefaultShipping()) {
$quote->getShippingAddress()->importCustomerAddressData($this->customerAddressRepository->getById($customer->getDefaultShipping()));
$quote->getShippingAddress()->setCustomerAddressId($customer->getDefaultShipping());
}
}
示例5: testSetCustomerAddressData
/**
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function testSetCustomerAddressData()
{
$customerId = 1;
$addressMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false, true, true, ['getId']);
$addressMock->expects($this->any())->method('getId')->will($this->returnValue(null));
$addresses = [$addressMock];
$customerMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false);
$customerResultMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false);
$requestMock = $this->getMock('\\Magento\\Framework\\DataObject');
$this->extensibleDataObjectConverterMock->expects($this->any())->method('toFlatArray')->will($this->returnValue(['customer_id' => $customerId]));
$this->customerRepositoryMock->expects($this->any())->method('getById')->will($this->returnValue($customerMock));
$this->customerDataFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerMock));
$this->customerRepositoryMock->expects($this->once())->method('save')->will($this->returnValue($customerMock));
$customerMock->expects($this->any())->method('getAddresses')->will($this->returnValue($addresses));
$this->objectFactoryMock->expects($this->once())->method('create')->with($this->equalTo(['customer_id' => $customerId]))->will($this->returnValue($requestMock));
$result = $this->quote->setCustomerAddressData([$addressMock]);
$this->assertInstanceOf('Magento\\Quote\\Model\\Quote', $result);
$this->assertEquals($customerResultMock, $this->quote->getCustomer());
}
示例6: configureTaxCalculation
private function configureTaxCalculation()
{
// this prevents customer session initialization (which affects cookies)
// see Mage_Tax_Model_Calculation::getCustomer()
$this->calculation->setCustomer($this->quote->getCustomer());
}
示例7: _isAvailableRatePay
/**
* @param Quote|\Magento\Quote\Api\Data\CartInterface $quote
*
* @return bool
*/
protected function _isAvailableRatePay($quote)
{
$dob = $quote->getCustomer()->getDob();
$minAge = (int) $this->getConfigData('min_age');
if ($minAge <= 0) {
$this->_logger->debug(__METHOD__ . ':warning min-age not set for ratepay');
return false;
}
//we only need to check the dob if it's set. Else we ask for dob on payment selection page.
if ($dob) {
$dobObject = new \DateTime($dob);
$currentYear = date('Y');
$currentMonth = date('m');
$currentDay = date('d');
$ageCheckDate = $currentYear - $minAge . '-' . $currentMonth . '-' . $currentDay;
$ageCheckObject = new \DateTime($ageCheckDate);
if ($ageCheckObject < $dobObject) {
return false;
}
}
if ($quote->hasVirtualItems()) {
return false;
}
if ($this->getConfigData('billing_shipping_address_identical') && !$this->compareAddresses($quote)) {
return false;
}
$currencies = explode(',', $this->getConfigData('currency'));
if (!in_array($quote->getQuoteCurrencyCode(), $currencies)) {
return false;
}
if (strlen($this->getConfigData('shippingcountry'))) {
$countries = explode(',', $this->getConfigData('shippingcountry'));
if (!in_array($quote->getShippingAddress()->getCountry(), $countries)) {
return false;
}
}
if (strlen($this->getConfigData('max_basket_size'))) {
if ($quote->getItemsQty() > $this->getConfigData('max_basket_size')) {
return false;
}
}
if (strlen($this->getConfigData('min_basket_size'))) {
if ($quote->getItemsQty() < $this->getConfigData('min_basket_size')) {
return false;
}
}
return parent::isAvailable($quote);
}