本文整理匯總了PHP中Magento\Quote\Api\CartRepositoryInterface::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP CartRepositoryInterface::delete方法的具體用法?PHP CartRepositoryInterface::delete怎麽用?PHP CartRepositoryInterface::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Quote\Api\CartRepositoryInterface
的用法示例。
在下文中一共展示了CartRepositoryInterface::delete方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadCustomerQuote
/**
* Load data for customer quote and merge with current quote
*
* @return $this
*/
public function loadCustomerQuote()
{
if (!$this->_customerSession->getCustomerId()) {
return $this;
}
$this->_eventManager->dispatch('load_customer_quote_before', ['checkout_session' => $this]);
try {
$customerQuote = $this->quoteRepository->getForCustomer($this->_customerSession->getCustomerId());
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
$customerQuote = $this->quoteFactory->create();
}
$customerQuote->setStoreId($this->_storeManager->getStore()->getId());
if ($customerQuote->getId() && $this->getQuoteId() != $customerQuote->getId()) {
if ($this->getQuoteId()) {
$this->quoteRepository->save($customerQuote->merge($this->getQuote())->collectTotals());
}
$this->setQuoteId($customerQuote->getId());
if ($this->_quote) {
$this->quoteRepository->delete($this->_quote);
}
$this->_quote = $customerQuote;
} else {
$this->getQuote()->getBillingAddress();
$this->getQuote()->getShippingAddress();
$this->getQuote()->setCustomer($this->_customerSession->getCustomerDataObject())->setTotalsCollectedFlag(false)->collectTotals();
$this->quoteRepository->save($this->getQuote());
}
return $this;
}
示例2: testDelete
public function testDelete()
{
$this->quoteMock->expects($this->once())->method('delete');
$this->quoteMock->expects($this->exactly(1))->method('getId')->willReturn(1);
$this->quoteMock->expects($this->exactly(1))->method('getCustomerId')->willReturn(2);
$this->model->delete($this->quoteMock);
}