Esempio n. 1
0
 /**
  * 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);
             }
         }
     }
 }