本文整理汇总了PHP中Magento\Quote\Model\QuoteRepository::getActiveForCustomer方法的典型用法代码示例。如果您正苦于以下问题:PHP QuoteRepository::getActiveForCustomer方法的具体用法?PHP QuoteRepository::getActiveForCustomer怎么用?PHP QuoteRepository::getActiveForCustomer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Quote\Model\QuoteRepository
的用法示例。
在下文中一共展示了QuoteRepository::getActiveForCustomer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActiveForCustomer
/**
* {@inheritdoc}
*/
public function getActiveForCustomer($customerId, array $sharedStoreIds = array())
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getActiveForCustomer');
if (!$pluginInfo) {
return parent::getActiveForCustomer($customerId, $sharedStoreIds);
} else {
return $this->___callPlugins('getActiveForCustomer', func_get_args(), $pluginInfo);
}
}
示例2: testGetActiveForCustomer
public function testGetActiveForCustomer()
{
$cartId = 17;
$customerId = 23;
$this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock);
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
$this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock);
$this->quoteMock->expects($this->never())->method('setSharedStoreIds');
$this->quoteMock->expects($this->once())->method('loadByCustomer')->with($customerId)->willReturn($this->storeMock);
$this->quoteMock->expects($this->exactly(2))->method('getId')->willReturn($cartId);
$this->quoteMock->expects($this->exactly(2))->method('getIsActive')->willReturn(1);
$this->assertEquals($this->quoteMock, $this->model->getActiveForCustomer($customerId));
$this->assertEquals($this->quoteMock, $this->model->getActiveForCustomer($customerId));
}
示例3: deleteByIdForCustomer
/**
* {@inheritdoc}
*/
public function deleteByIdForCustomer($customerId, $itemId)
{
$cart = $this->quoteRepository->getActiveForCustomer($customerId);
return $this->deleteById($cart->getId(), $itemId);
}
示例4: getQuote
/**
* Get checkout quote instance by current session
*
* @return Quote
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function getQuote()
{
$this->_eventManager->dispatch('custom_quote_process', ['checkout_session' => $this]);
if ($this->_quote === null) {
$quote = $this->quoteRepository->create();
if ($this->getQuoteId()) {
try {
if ($this->_loadInactive) {
$quote = $this->quoteRepository->get($this->getQuoteId());
} else {
$quote = $this->quoteRepository->getActive($this->getQuoteId());
}
/**
* If current currency code of quote is not equal current currency code of store,
* need recalculate totals of quote. It is possible if customer use currency switcher or
* store switcher.
*/
if ($quote->getQuoteCurrencyCode() != $this->_storeManager->getStore()->getCurrentCurrencyCode()) {
$quote->setStore($this->_storeManager->getStore());
$this->quoteRepository->save($quote->collectTotals());
/*
* We mast to create new quote object, because collectTotals()
* can to create links with other objects.
*/
$quote = $this->quoteRepository->get($this->getQuoteId());
}
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
$this->setQuoteId(null);
}
}
if (!$this->getQuoteId()) {
if ($this->_customerSession->isLoggedIn() || $this->_customer) {
$customerId = $this->_customer ? $this->_customer->getId() : $this->_customerSession->getCustomerId();
try {
$quote = $this->quoteRepository->getActiveForCustomer($customerId);
$this->setQuoteId($quote->getId());
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
}
} else {
$quote->setIsCheckoutCart(true);
$this->_eventManager->dispatch('checkout_quote_init', ['quote' => $quote]);
}
}
if ($this->getQuoteId()) {
if ($this->_customer) {
$quote->setCustomer($this->_customer);
} elseif ($this->_customerSession->isLoggedIn()) {
$quote->setCustomer($this->customerRepository->getById($this->_customerSession->getCustomerId()));
}
}
$quote->setStore($this->_storeManager->getStore());
$this->_quote = $quote;
}
$remoteAddress = $this->_remoteAddress->getRemoteAddress();
if ($remoteAddress) {
$this->_quote->setRemoteIp($remoteAddress);
$xForwardIp = $this->request->getServer('HTTP_X_FORWARDED_FOR');
$this->_quote->setXForwardedFor($xForwardIp);
}
return $this->_quote;
}
示例5: getCartForCustomer
/**
* {@inheritdoc}
*/
public function getCartForCustomer($customerId)
{
return $this->quoteRepository->getActiveForCustomer($customerId);
}