本文整理汇总了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);
}