本文整理汇总了PHP中Magento\Quote\Model\Quote::getIsVirtual方法的典型用法代码示例。如果您正苦于以下问题:PHP Quote::getIsVirtual方法的具体用法?PHP Quote::getIsVirtual怎么用?PHP Quote::getIsVirtual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Quote\Model\Quote
的用法示例。
在下文中一共展示了Quote::getIsVirtual方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateQuoteAddress
/**
* Update quote address
*
* @param Quote $quote
* @param array $details
* @return void
*/
private function updateQuoteAddress(Quote $quote, array $details)
{
if (!$quote->getIsVirtual()) {
$this->updateShippingAddress($quote, $details);
}
$this->updateBillingAddress($quote, $details);
}
示例2: _beforeToHtml
/**
* Retrieve payment method and assign additional template values
*
* @return $this
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
protected function _beforeToHtml()
{
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
$this->setPaymentMethodTitle($methodInstance->getTitle());
$this->setShippingRateRequired(true);
if ($this->_quote->getIsVirtual()) {
$this->setShippingRateRequired(false);
} else {
// prepare shipping rates
$this->_address = $this->_quote->getShippingAddress();
$groups = $this->_address->getGroupedAllShippingRates();
if ($groups && $this->_address) {
$this->setShippingRateGroups($groups);
// determine current selected code & name
foreach ($groups as $code => $rates) {
foreach ($rates as $rate) {
if ($this->_address->getShippingMethod() == $rate->getCode()) {
$this->_currentShippingRate = $rate;
break 2;
}
}
}
}
$canEditShippingAddress = $this->_quote->getMayEditShippingAddress() && $this->_quote->getPayment()->getAdditionalInformation(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_BUTTON) == 1;
// misc shipping parameters
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_controllerPath}/saveShippingMethod"))->setCanEditShippingAddress($canEditShippingAddress)->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod());
}
$this->setEditUrl($this->getUrl("{$this->_controllerPath}/edit"))->setPlaceOrderUrl($this->getUrl("{$this->_controllerPath}/placeOrder"));
return parent::_beforeToHtml();
}
示例3: populateQuoteAddress
/**
* @param \Magento\Quote\Model\Quote $quote
* @param array $details
* @return $this
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function populateQuoteAddress($quote, $details)
{
// import shipping address
$exportedShippingAddress = isset($details['shippingAddress']) ? $details['shippingAddress'] : null;
if (!$quote->getIsVirtual()) {
$shippingAddress = $quote->getShippingAddress();
if ($exportedShippingAddress) {
$this->importAddressData($shippingAddress, $exportedShippingAddress);
}
// PayPal doesn't provide detailed shipping info: prefix, suffix
$shippingAddress->setLastname($details['lastName']);
$shippingAddress->setFirstname($details['firstName']);
$shippingAddress->setEmail($details['email']);
$shippingAddress->setCollectShippingRates(true);
}
$exportedBillingAddress = isset($details['billingAddress']) ? $details['billingAddress'] : null;
$billingAddress = $quote->getBillingAddress();
if ($exportedBillingAddress) {
$this->importBillingAddressData($billingAddress, $exportedBillingAddress);
$billingAddress->setFirstname($details['firstName']);
$billingAddress->setLastname($details['lastName']);
$billingAddress->setEmail($details['email']);
} elseif ($billingAddress->getEmail() == null) {
$this->importAddressData($billingAddress, $exportedShippingAddress);
$billingAddress->setFirstname($details['firstName']);
$billingAddress->setLastname($details['lastName']);
$billingAddress->setEmail($details['email']);
}
return $this;
}
示例4: _ignoreAddressValidation
/**
* Make sure addresses will be saved without validation errors
*
* @return void
*/
private function _ignoreAddressValidation()
{
$this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
if (!$this->_quote->getIsVirtual()) {
$this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
if (!$this->_config->getValue('requireBillingAddress') && !$this->_quote->getBillingAddress()->getEmail()) {
$this->_quote->getBillingAddress()->setSameAsBilling(1);
}
}
}
示例5: disabledQuoteAddressValidation
/**
* Make sure addresses will be saved without validation errors
*
* @param Quote $quote
* @return void
*/
protected function disabledQuoteAddressValidation(Quote $quote)
{
$billingAddress = $quote->getBillingAddress();
$billingAddress->setShouldIgnoreValidation(true);
if (!$quote->getIsVirtual()) {
$shippingAddress = $quote->getShippingAddress();
$shippingAddress->setShouldIgnoreValidation(true);
if (!$billingAddress->getEmail()) {
$billingAddress->setSameAsBilling(1);
}
}
}
示例6: 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);
}
}
}
}
示例7: execute
/**
* Execute operation
*
* @param string $shippingMethod
* @param Quote $quote
* @return void
* @throws \InvalidArgumentException
*/
public function execute($shippingMethod, Quote $quote)
{
if (empty($shippingMethod)) {
throw new \InvalidArgumentException('The "shippingMethod" field does not exists.');
}
if (!$quote->getIsVirtual()) {
$shippingAddress = $quote->getShippingAddress();
if ($shippingMethod !== $shippingAddress->getShippingMethod()) {
$this->disabledQuoteAddressValidation($quote);
$shippingAddress->setShippingMethod($shippingMethod);
$shippingAddress->setCollectShippingRates(true);
$quote->collectTotals();
$this->quoteRepository->save($quote);
}
}
}
示例8: getTaxContainer
/**
* {@inheritdoc}
*/
public function getTaxContainer()
{
return $this->_salesModel->getIsVirtual() ? $this->_salesModel->getBillingAddress() : $this->_salesModel->getShippingAddress();
}