本文整理汇总了PHP中Magento\Quote\Model\Quote::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Quote::getId方法的具体用法?PHP Quote::getId怎么用?PHP Quote::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Quote\Model\Quote
的用法示例。
在下文中一共展示了Quote::getId方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @inheritdoc
*/
public function setUp()
{
parent::setUp();
$this->quote = $this->_objectManager->create('Magento\\Quote\\Model\\Quote');
$this->checkoutSession = $this->_objectManager->get('Magento\\Checkout\\Model\\Session');
$this->quote->load('test01', 'reserved_order_id');
$this->checkoutSession->setQuoteId($this->quote->getId());
$this->checkoutSession->setCartWasUpdated(false);
}
示例2: setQuote
/**
* Set Quote object to Collection
*
* @param \Magento\Quote\Model\Quote $quote
* @return $this
*/
public function setQuote($quote)
{
$this->_quote = $quote;
$quoteId = $quote->getId();
if ($quoteId) {
$this->addFieldToFilter('quote_id', $quote->getId());
} else {
$this->_totalRecords = 0;
$this->_setIsLoaded(true);
}
return $this;
}
示例3: testSetMethodWithoutShippingAddress
/**
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
*/
public function testSetMethodWithoutShippingAddress()
{
$this->quote->load('test_order_with_simple_product_without_address', 'reserved_order_id');
$serviceInfo = $this->getServiceInfo();
$requestData = ['cartId' => $this->quote->getId(), 'carrierCode' => 'flatrate', 'methodCode' => 'flatrate'];
try {
$this->_webApiCall($serviceInfo, $requestData);
} catch (\SoapFault $e) {
$message = $e->getMessage();
} catch (\Exception $e) {
$message = json_decode($e->getMessage())->message;
}
$this->assertEquals('Shipping address is not set', $message);
}
示例4: getQuote
/**
* Retrieve quote model object
*
* @return \Magento\Quote\Model\Quote
*/
public function getQuote()
{
if ($this->_quote === null) {
$this->_quote = $this->quoteFactory->create();
if ($this->getStoreId()) {
if (!$this->getQuoteId()) {
$this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId());
$this->_quote->setIsActive(false);
$this->_quote->setStoreId($this->getStoreId());
$this->quoteRepository->save($this->_quote);
$this->setQuoteId($this->_quote->getId());
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
} else {
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
$this->_quote->setStoreId($this->getStoreId());
}
if ($this->getCustomerId() && $this->getCustomerId() != $this->_quote->getCustomerId()) {
$customer = $this->customerRepository->getById($this->getCustomerId());
$this->_quote->assignCustomer($customer);
$this->quoteRepository->save($this->_quote);
}
}
$this->_quote->setIgnoreOldQty(true);
$this->_quote->setIsSuperMode(true);
}
return $this->_quote;
}
示例5: testGetListForMyCart
/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
*/
public function testGetListForMyCart()
{
$this->markTestSkipped('Will be fixed after MAGETWO-35573');
$this->_markTestAsRestOnly();
$this->quote->load('test_order_1', 'reserved_order_id');
/** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */
$customerTokenService = $this->objectManager->create('Magento\\Integration\\Api\\CustomerTokenServiceInterface');
$token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password');
/** @var \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagementService */
$shippingMethodManagementService = $this->objectManager->create('Magento\\Quote\\Api\\ShippingMethodManagementInterface');
$shippingMethodManagementService->set($this->quote->getId(), 'flatrate', 'flatrate');
$serviceInfo = ['rest' => ['resourcePath' => '/V1/carts/mine/shipping-methods', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, 'token' => $token]];
$result = $this->_webApiCall($serviceInfo, []);
$this->assertNotEmpty($result);
$this->assertCount(1, $result);
$shippingMethod = $shippingMethodManagementService->get($this->quote->getId());
$expectedData = [ShippingMethodInterface::KEY_CARRIER_CODE => $shippingMethod->getCarrierCode(), ShippingMethodInterface::KEY_METHOD_CODE => $shippingMethod->getMethodCode(), ShippingMethodInterface::KEY_CARRIER_TITLE => $shippingMethod->getCarrierTitle(), ShippingMethodInterface::KEY_METHOD_TITLE => $shippingMethod->getMethodTitle(), ShippingMethodInterface::KEY_SHIPPING_AMOUNT => $shippingMethod->getAmount(), ShippingMethodInterface::KEY_BASE_SHIPPING_AMOUNT => $shippingMethod->getBaseAmount(), ShippingMethodInterface::KEY_AVAILABLE => $shippingMethod->getAvailable(), ShippingMethodInterface::KEY_ERROR_MESSAGE => null, ShippingMethodInterface::KEY_PRICE_EXCL_TAX => $shippingMethod->getPriceExclTax(), ShippingMethodInterface::KEY_PRICE_INCL_TAX => $shippingMethod->getPriceInclTax()];
$this->assertEquals($expectedData, $result[0]);
}
示例6: testSetMethodWithoutShippingAddress
/**
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
*/
public function testSetMethodWithoutShippingAddress()
{
$this->quote->load('test_order_with_simple_product_without_address', 'reserved_order_id');
$serviceInfo = $this->getServiceInfo();
$cartId = $this->quote->getId();
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
$quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Quote\\Model\\QuoteIdMaskFactory')->create();
$quoteIdMask->load($cartId);
//Use masked cart Id
$cartId = $quoteIdMask->getMaskedId();
$requestData = ['cartId' => $cartId, 'carrierCode' => 'flatrate', 'methodCode' => 'flatrate'];
try {
$this->_webApiCall($serviceInfo, $requestData);
} catch (\SoapFault $e) {
$message = $e->getMessage();
} catch (\Exception $e) {
$message = json_decode($e->getMessage())->message;
}
$this->assertEquals('Shipping address is not set', $message);
}
示例7: setShippingOptions
/**
* Set shipping options to api
* @param \Magento\Paypal\Model\Cart $cart
* @param \Magento\Quote\Model\Quote\Address|null $address
* @return void
*/
private function setShippingOptions(PaypalCart $cart, Address $address = null)
{
// for included tax always disable line items (related to paypal amount rounding problem)
$this->_api->setIsLineItemsEnabled($this->_config->getValue(PaypalConfig::TRANSFER_CART_LINE_ITEMS));
// add shipping options if needed and line items are available
$cartItems = $cart->getAllItems();
if ($this->_config->getValue(PaypalConfig::TRANSFER_CART_LINE_ITEMS) && $this->_config->getValue(PaypalConfig::TRANSFER_SHIPPING_OPTIONS) && !empty($cartItems)) {
if (!$this->_quote->getIsVirtual()) {
$options = $this->_prepareShippingOptions($address, true);
if ($options) {
$this->_api->setShippingOptionsCallbackUrl($this->_coreUrl->getUrl('*/*/shippingOptionsCallback', ['quote_id' => $this->_quote->getId()]))->setShippingOptions($options);
}
}
}
}
示例8: testPopulateBeforeSaveData
public function testPopulateBeforeSaveData()
{
/** Preconditions */
$customerId = 1;
$customerAddressId = 1;
$this->_address->setQuote($this->_quote);
$this->assertNotEquals($customerId, $this->_address->getCustomerId(), "Precondition failed: Customer ID was not set.");
$this->assertNotEquals(1, $this->_address->getQuoteId(), "Precondition failed: Quote ID was not set.");
$this->assertNotEquals($customerAddressId, $this->_address->getCustomerAddressId(), "Precondition failed: Customer address ID was not set.");
/** @var \Magento\Customer\Api\Data\AddressInterfaceFactory $addressFactory */
$addressFactory = Bootstrap::getObjectManager()->create('Magento\\Customer\\Api\\Data\\AddressInterfaceFactory');
$customerAddressData = $addressFactory->create()->setId($customerAddressId);
$this->_address->setCustomerAddressData($customerAddressData);
$this->_address->save();
$this->assertEquals($customerId, $this->_address->getCustomerId());
$this->assertEquals($this->_quote->getId(), $this->_address->getQuoteId());
$this->assertEquals($customerAddressId, $this->_address->getCustomerAddressId());
}
示例9: collect
/**
* @param \Magento\Quote\Model\Quote $quote
* @return void
*/
public function collect(\Magento\Quote\Model\Quote $quote)
{
if ($this->customerSession->isLoggedIn()) {
$customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
if ($defaultShipping = $customer->getDefaultShipping()) {
$address = $this->addressRepository->getById($defaultShipping);
if ($address) {
/** @var \Magento\Quote\Api\Data\EstimateAddressInterface $estimatedAddress */
$estimatedAddress = $this->estimatedAddressFactory->create();
$estimatedAddress->setCountryId($address->getCountryId());
$estimatedAddress->setPostcode($address->getPostcode());
$estimatedAddress->setRegion((string) $address->getRegion()->getRegion());
$estimatedAddress->setRegionId($address->getRegionId());
$this->shippingMethodManager->estimateByAddress($quote->getId(), $estimatedAddress);
$this->quoteRepository->save($quote);
}
}
}
}
示例10: setQuote
/**
* Declare quote model object
*
* @param \Magento\Quote\Model\Quote $quote
* @return $this
*/
public function setQuote(\Magento\Quote\Model\Quote $quote)
{
$this->_quote = $quote;
$this->setQuoteId($quote->getId());
$this->setStoreId($quote->getStoreId());
return $this;
}
示例11: delete
/**
* Delete quote
*
* @param Quote $quote
* @return void
*/
public function delete(Quote $quote)
{
$quoteId = $quote->getId();
$customerId = $quote->getCustomerId();
$quote->delete();
unset($this->quotesById[$quoteId]);
unset($this->quotesByCustomerId[$customerId]);
}
示例12: replaceQuote
/**
* @param Quote $quote
* @return $this
*/
public function replaceQuote($quote)
{
$this->_quote = $quote;
$this->setQuoteId($quote->getId());
return $this;
}
示例13: start
/**
* Reserve order ID for specified quote and start checkout on PayPal
*
* @param string $returnUrl
* @param string $cancelUrl
* @param bool|null $button
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function start($returnUrl, $cancelUrl, $button = null)
{
$this->_quote->collectTotals();
if (!$this->_quote->getGrandTotal()) {
throw new \Magento\Framework\Exception\LocalizedException(__('PayPal can\'t process orders with a zero balance due. ' . 'To finish your purchase, please go through the standard checkout process.'));
}
$this->_quote->reserveOrderId();
$this->quoteRepository->save($this->_quote);
// prepare API
$this->_getApi();
$solutionType = $this->_config->getMerchantCountry() == 'DE' ? \Magento\Paypal\Model\Config::EC_SOLUTION_TYPE_MARK : $this->_config->getValue('solutionType');
$this->_api->setAmount($this->_quote->getBaseGrandTotal())->setCurrencyCode($this->_quote->getBaseCurrencyCode())->setInvNum($this->_quote->getReservedOrderId())->setReturnUrl($returnUrl)->setCancelUrl($cancelUrl)->setSolutionType($solutionType)->setPaymentAction($this->_config->getValue('paymentAction'));
if ($this->_giropayUrls) {
list($successUrl, $cancelUrl, $pendingUrl) = $this->_giropayUrls;
$this->_api->addData(['giropay_cancel_url' => $cancelUrl, 'giropay_success_url' => $successUrl, 'giropay_bank_txn_pending_url' => $pendingUrl]);
}
if ($this->_isBml) {
$this->_api->setFundingSource('BML');
}
$this->_setBillingAgreementRequest();
if ($this->_config->getValue('requireBillingAddress') == PaypalConfig::REQUIRE_BILLING_ADDRESS_ALL) {
$this->_api->setRequireBillingAddress(1);
}
// suppress or export shipping address
if ($this->_quote->getIsVirtual()) {
if ($this->_config->getValue('requireBillingAddress') == PaypalConfig::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
$this->_api->setRequireBillingAddress(1);
}
$this->_api->setSuppressShipping(true);
} else {
$address = $this->_quote->getShippingAddress();
$isOverridden = 0;
if (true === $address->validate()) {
$isOverridden = 1;
$this->_api->setAddress($address);
}
$this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDDEN, $isOverridden);
$this->_quote->getPayment()->save();
}
// add line items
/** @var $cart \Magento\Payment\Model\Cart */
$cart = $this->_cartFactory->create(['salesModel' => $this->_quote]);
$this->_api->setPaypalCart($cart)->setIsLineItemsEnabled($this->_config->getValue('lineItemsEnabled'));
// add shipping options if needed and line items are available
$cartItems = $cart->getAllItems();
if ($this->_config->getValue('lineItemsEnabled') && $this->_config->getValue('transferShippingOptions') && !empty($cartItems)) {
if (!$this->_quote->getIsVirtual()) {
$options = $this->_prepareShippingOptions($address, true);
if ($options) {
$this->_api->setShippingOptionsCallbackUrl($this->_coreUrl->getUrl('*/*/shippingOptionsCallback', ['quote_id' => $this->_quote->getId()]))->setShippingOptions($options);
}
}
}
$this->_config->exportExpressCheckoutStyleSettings($this->_api);
/* Temporary solution. @TODO: do not pass quote into Nvp model */
$this->_api->setQuote($this->_quote);
$this->_api->callSetExpressCheckout();
$token = $this->_api->getToken();
$this->_redirectUrl = $button ? $this->_config->getExpressCheckoutStartUrl($token) : $this->_config->getPayPalBasicStartUrl($token);
$payment = $this->_quote->getPayment();
$payment->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
// Set flag that we came from Express Checkout button
if (!empty($button)) {
$payment->setAdditionalInformation(self::PAYMENT_INFO_BUTTON, 1);
} elseif ($payment->hasAdditionalInformation(self::PAYMENT_INFO_BUTTON)) {
$payment->unsAdditionalInformation(self::PAYMENT_INFO_BUTTON);
}
$payment->save();
return $token;
}
示例14: assertQuoteCollectionNotContains
private function assertQuoteCollectionNotContains(Quote $expected)
{
$message = sprintf('The quote with ID "%s" is contained in the quote collection, but was expected to be absent', $expected->getId());
$this->assertNotContains($expected->getId(), $this->quoteCollection->getAllIds(), $message);
}