예제 #1
0
 public function testGetStoreIdNoId()
 {
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $storeMock->expects($this->once())->method('getId')->will($this->returnValue(null));
     $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
     $result = $this->quote->getStoreId();
     $this->assertNull($result);
 }
예제 #2
0
 /**
  * @param \Magento\Sales\Model\Quote $quote
  * @return \Magento\Payment\Model\MethodInterface[]
  */
 public function getAvailableMethods(\Magento\Sales\Model\Quote $quote = null)
 {
     $store = $quote ? $quote->getStoreId() : null;
     $methods = array();
     $specification = $this->methodSpecificationFactory->create(array(AbstractMethod::CHECK_ZERO_TOTAL));
     foreach ($this->paymentHelper->getStoreMethods($store, $quote) as $method) {
         if ($this->_canUseMethod($method, $quote) && $specification->isApplicable($method, $quote)) {
             $method->setInfoInstance($quote->getPayment());
             $methods[] = $method;
         }
     }
     return $methods;
 }
예제 #3
0
파일: Quote.php 프로젝트: aiesh/magento2
 /**
  * Get reserved order id
  *
  * @param \Magento\Sales\Model\Quote $quote
  * @return string
  */
 public function getReservedOrderId($quote)
 {
     $storeId = (int) $quote->getStoreId();
     return $this->_config->getEntityType(\Magento\Sales\Model\Order::ENTITY)->fetchNewIncrementId($storeId);
 }
예제 #4
0
 /**
  * Check is allowed Guest Checkout
  * Use config settings and observer
  *
  * @param \Magento\Sales\Model\Quote $quote
  * @param int|Store $store
  * @return bool
  */
 public function isAllowedGuestCheckout(\Magento\Sales\Model\Quote $quote, $store = null)
 {
     if ($store === null) {
         $store = $quote->getStoreId();
     }
     $guestCheckout = $this->_scopeConfig->isSetFlag(self::XML_PATH_GUEST_CHECKOUT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
     if ($guestCheckout == true) {
         $result = new \Magento\Framework\Object();
         $result->setIsAllowed($guestCheckout);
         $this->_eventManager->dispatch('checkout_allow_guest', array('quote' => $quote, 'store' => $store, 'result' => $result));
         $guestCheckout = $result->getIsAllowed();
     }
     return $guestCheckout;
 }
예제 #5
0
 /**
  * Fetch base quote data and map it to DTO fields
  *
  * @param Quote $quote
  * @return array
  */
 public function map(Quote $quote)
 {
     return [Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), Cart::UPDATED_AT => $quote->getUpdatedAt(), Cart::CONVERTED_AT => $quote->getConvertedAt(), Cart::IS_ACTIVE => $quote->getIsActive(), Cart::IS_VIRTUAL => $quote->getIsVirtual(), Cart::ITEMS_COUNT => $quote->getItemsCount(), Cart::ITEMS_QUANTITY => $quote->getItemsQty(), Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), Cart::ORIG_ORDER_ID => $quote->getOrigOrderId()];
 }
예제 #6
0
파일: Cc.php 프로젝트: aiesh/magento2
 /**
  * Check whether there are CC types set in configuration
  *
  * @param \Magento\Sales\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     return $this->getConfigData('cctypes', $quote ? $quote->getStoreId() : null) && parent::isAvailable($quote);
 }
예제 #7
0
 /**
  * Fetch base quote data and map it to DTO fields
  *
  * @param Quote $quote
  * @return array
  */
 public function map(Quote $quote)
 {
     $this->cartBuilder->populateWithArray([Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), Cart::UPDATED_AT => $quote->getUpdatedAt(), Cart::CONVERTED_AT => $quote->getConvertedAt(), Cart::IS_ACTIVE => $quote->getIsActive(), Cart::IS_VIRTUAL => $quote->getIsVirtual(), Cart::ITEMS_COUNT => $quote->getItemsCount(), Cart::ITEMS_QUANTITY => $quote->getItemsQty(), Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), Cart::ORIG_ORDER_ID => $quote->getOrigOrderId()]);
     $this->customerBuilder->populateWithArray($this->customerMapper->map($quote));
     $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote));
     $items = [];
     foreach ($quote->getAllItems() as $item) {
         $items[] = $this->itemTotalsMapper->extractDto($item);
     }
     $this->totalsBuilder->setItems($items);
     $this->cartBuilder->setCustomer($this->customerBuilder->create());
     $this->cartBuilder->setTotals($this->totalsBuilder->create());
     $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote));
     return $this->cartBuilder->create();
 }
예제 #8
0
 /**
  * Retrieve store Id (From Quote)
  *
  * @return int
  */
 public function getStoreId()
 {
     return (int) $this->_quote->getStoreId();
 }
예제 #9
0
 /**
  * Check whether payment method can be used
  *
  * TODO: payment method instance is not supposed to know about quote
  *
  * @param \Magento\Sales\Model\Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     $checkResult = new \StdClass();
     $isActive = (bool) (int) $this->getConfigData('active', $quote ? $quote->getStoreId() : null);
     $checkResult->isAvailable = $isActive;
     $checkResult->isDeniedInConfig = !$isActive;
     // for future use in observers
     $this->_eventManager->dispatch('payment_method_is_active', array('result' => $checkResult, 'method_instance' => $this, 'quote' => $quote));
     return $checkResult->isAvailable;
 }