Adds order article to basket (method normally used while recalculating order)

@param \OxidEsales\Eshop\Application\Model\OrderArticle $oOrderArticle order article to store in basket

@return \OxidEsales\Eshop\Application\Model\BasketItem
976137
public function addOrderArticleToBasket($oOrderArticle)
    {
        // adding only if amount > 0
        if ($oOrderArticle->oxorderarticles__oxamount->value > 0 && !$oOrderArticle->isBundle()) {
            $this->_isForOrderRecalculation = true;
            $sItemId = $oOrderArticle->getId();

            //inserting new
            $this->_aBasketContents[$sItemId] = oxNew(\OxidEsales\Eshop\Application\Model\BasketItem::class);
            $this->_aBasketContents[$sItemId]->initFromOrderArticle($oOrderArticle);
            $this->_aBasketContents[$sItemId]->setWrapping($oOrderArticle->oxorderarticles__oxwrapid->value);
            $this->_aBasketContents[$sItemId]->setBundle($oOrderArticle->isBundle());

            //calling update method
            $this->onUpdate();

            return $this->_aBasketContents[$sItemId];
        } elseif ($oOrderArticle->isBundle()) {
            // deleting bundles, they are handled automatically
            $oOrderArticle->delete();
        }
    }
413161
public function setOrderItemCategory($orderItemCategory) 
    {
        if (!$this->_isNumericArray($orderItemCategory)) {
            $orderItemCategory =  array ($orderItemCategory);    
        }
        $this->fields['OrderItemCategory']['FieldValue'] = $orderItemCategory;
        return $this;
    }
108115
protected function _OxpsPaymorrowOxOrder_finalizeOrder_parent( oxBasket $oBasket, $oUser,
                                                                   $blRecalculatingOrder = false )
    {
        return parent::finalizeOrder( $oBasket, $oUser, $blRecalculatingOrder );
    }
365168
protected function _getVendorList($oArticle)
    {
        if ($oArticle->oxarticles__oxvendorid->value) {
            $oVendor = oxNew(\OxidEsales\Eshop\Application\Model\Vendor::class);
            if ($oVendor->loadInLang($this->getEditLang(), $oArticle->oxarticles__oxvendorid->value)) {
                return [$oVendor];
            }
        }
    }
437153
public function AllowVoucherForArticle(TShopBasketArticle $oArticle)
    {
        $bMayBeUsed = true;

        $oVoucherDef = &$this->GetFieldShopVoucherSeries();

        if ($oArticle->fieldExcludeFromVouchers && empty($oVoucherDef->fieldShopVoucherSeriesSponsorId)) {
            $bMayBeUsed = false;
        }

        // check article restrictions
        if ($bMayBeUsed) {
            $aArticleRestrictons = $oVoucherDef->GetMLTIdList('shop_article_mlt');
            if (count($aArticleRestrictons) > 0 && !in_array($oArticle->id, $aArticleRestrictons)) {
                $bMayBeUsed = false;
            }
        }

        // check manufacturer restrictions
        if ($bMayBeUsed) {
            $aManufacturerRestrictons = $oVoucherDef->GetMLTIdList('shop_manufacturer_mlt');
            if (count($aManufacturerRestrictons) > 0 && !in_array($oArticle->fieldShopManufacturerId, $aManufacturerRestrictons)) {
                $bMayBeUsed = false;
            }
        }

        // check category restrictions
        if ($bMayBeUsed) {
            $aCategoryRestrictons = $oVoucherDef->GetMLTIdList('shop_category_mlt');
            if (count($aCategoryRestrictons) > 0) {
                if (!$oArticle->IsInCategory($aCategoryRestrictons)) {
                    $bMayBeUsed = false;
                }
            }
        }

        // check product group restrictions
        if ($bMayBeUsed) {
            $aArticleGroupRestrictons = $oVoucherDef->GetMLTIdList('shop_article_group_mlt');
            if (count($aArticleGroupRestrictons) > 0) {
                $aGroups = $oArticle->GetMLTIdList('shop_article_group_mlt');
                $aMatches = array_intersect($aGroups, $aArticleGroupRestrictons);
                if (0 == count($aMatches)) {
                    $bMayBeUsed = false;
                }
            }
        }

        return $bMayBeUsed;
    }
1338754
public function store(Order $order, CreateTransactionRequest $request)
    {
        $data = $request->all();
        $data['order_id'] = $order->id;
        $this->transaction->create($data);

        if($request->order_paid) {
            $order->status_id = OrderStatus::PENDING;
            $order->save();
        }

        return redirect()->route('admin.order.order.show', $order->id)
            ->withSuccess(trans('core::core.messages.resource created', ['name' => trans('order::transactions.title.transactions')]));
    }
1349083
public function transformIntoBasket(OrderInterface $order, BasketInterface $basket)
    {
        $event = new OrderTransformEvent($order);
        $this->eventDispatcher->dispatch(TransformerEvents::PRE_ORDER_TO_BASKET_TRANSFORM, $event);

        // we reset the current basket
        $basket->reset(true);

        $basket->setCurrency($order->getCurrency());
        $basket->setLocale($order->getLocale());

        // We are free to convert !
        foreach ($order->getOrderElements() as $orderElement) {
            /*
             * @var $orderElement OrderElementInterface
             */
            $provider = $this->productPool->getProvider($orderElement->getProductType());
            $manager = $this->productPool->getManager($orderElement->getProductType());

            $product = $manager->findOneBy(['id' => $orderElement->getProductId()]);

            if (!$product) {
                continue;
            }

            $basketElement = $provider->createBasketElement($product, $orderElement->getOptions());
            $basketElement->setQuantity($orderElement->getQuantity());

            $provider->basketAddProduct($basket, $product, $basketElement);
        }

        $basket->setCustomer($order->getCustomer());

        $basket->buildPrices();

        $event = new BasketTransformEvent($basket);
        $this->eventDispatcher->dispatch(TransformerEvents::POST_ORDER_TO_BASKET_TRANSFORM, $event);

        return $basket;
    }
1358263
public function loadRecommLists(\OxidEsales\Eshop\Application\Model\Article $oArticle)
    {
        if (($this->_aChannel = $this->_loadFromCache(self::RSS_ARTRECOMMLISTS . $oArticle->getId()))) {
            return;
        }

        $oConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oConfig->setConfigParam('iNrofCrossellArticles', $oConfig->getConfigParam('iRssItemsCount'));

        $oList = oxNew(\OxidEsales\Eshop\Application\Model\RecommendationList::class)->getRecommListsByIds([$oArticle->getId()]);
        if ($oList == null) {
            $oList = oxNew(\OxidEsales\Eshop\Core\Model\ListModel::class);
        }

        $oLang = Registry::getLang();
        $this->_loadData(
            self::RSS_ARTRECOMMLISTS . $oArticle->getId(),
            $this->getRecommListsTitle($oArticle),
            sprintf($oLang->translateString('LISTMANIA_LIST_FOR', $oLang->getBaseLanguage()), $oArticle->oxarticles__oxtitle->value),
            $this->_getRecommListItems($oList),
            $this->getRecommListsUrl($oArticle),
            $oArticle->getLink()
        );
    }
1056905
protected function _addOrderData( array $aData, oxUser $oUser )
    {
        /** @var OxpsPaymorrowOxBasket|oxBasket $oBasket */
        $oBasket = $oUser->getUserPaymorrowUserBasketFromSession();

        // Common order fields
        $aData['order_grossAmount'] = (double) $oBasket->getPaymorrowTotalAmount();
        $aData['order_vatAmount']   = (double) $oBasket->getPaymorrowTotalVatAmount();
        $aData['order_currency']    = self::toUtf( $oBasket->getPaymorrowBasketCurrency() );

        // Summarized line items array: products, costs, vouchers
        $aData = array_merge( $aData, $oBasket->getPaymorrowBasketLineItems() );

        return $aData;
    }
1085743
protected function _setOrderArticles($aArticleList)
    {
        // reset articles list
        $this->_oArticles = oxNew(\OxidEsales\Eshop\Core\Model\ListModel::class);
        $iCurrLang = $this->getOrderLanguage();

        // add all the products we have on basket to the order
        foreach ($aArticleList as $oContent) {
            //$oContent->oProduct = $oContent->getArticle();
            // #M773 Do not use article lazy loading on order save
            $oProduct = $oContent->getArticle(true, null, true);

            // copy only if object is oxarticle type
            if ($oProduct->isOrderArticle()) {
                $oOrderArticle = $oProduct;
            } else {
                // if order language does not match product language article must be reloaded in order language
                if ($iCurrLang != $oProduct->getLanguage()) {
                    $oProduct->loadInLang($iCurrLang, $oProduct->getProductId());
                }

                // set chosen select list
                $sSelList = '';
                if (count($aChosenSelList = $oContent->getChosenSelList())) {
                    foreach ($aChosenSelList as $oItem) {
                        if ($sSelList) {
                            $sSelList .= ", ";
                        }
                        $sSelList .= "{$oItem->name} : {$oItem->value}";
                    }
                    if ($sSelList !== '' && $oContent->getVarSelect() !== '') {
                        $sSelList .= ' ||';
                    }
                }

                $oOrderArticle = oxNew(\OxidEsales\Eshop\Application\Model\OrderArticle::class);
                $oOrderArticle->setIsNewOrderItem(true);
                $oOrderArticle->copyThis($oProduct);
                $oOrderArticle->setId();

                $oOrderArticle->oxorderarticles__oxartnum = clone $oProduct->oxarticles__oxartnum;
                $oOrderArticle->oxorderarticles__oxselvariant = new \OxidEsales\Eshop\Core\Field(trim($sSelList . ' ' . $oContent->getVarSelect()), \OxidEsales\Eshop\Core\Field::T_RAW);
                $oOrderArticle->oxorderarticles__oxshortdesc = new \OxidEsales\Eshop\Core\Field($oProduct->oxarticles__oxshortdesc->getRawValue(), \OxidEsales\Eshop\Core\Field::T_RAW);
                // #M974: duplicated entries for the name of variants in orders
                $oOrderArticle->oxorderarticles__oxtitle = new \OxidEsales\Eshop\Core\Field(trim($oProduct->oxarticles__oxtitle->getRawValue()), \OxidEsales\Eshop\Core\Field::T_RAW);

                // copying persistent parameters ...
                if (!is_array($aPersParams = $oProduct->getPersParams())) {
                    $aPersParams = $oContent->getPersParams();
                }
                if (is_array($aPersParams) && count($aPersParams)) {
                    $oOrderArticle->oxorderarticles__oxpersparam = new \OxidEsales\Eshop\Core\Field(serialize($aPersParams), \OxidEsales\Eshop\Core\Field::T_RAW);
                }
            }

            // ids, titles, numbers ...
            $oOrderArticle->oxorderarticles__oxorderid = new \OxidEsales\Eshop\Core\Field($this->getId());
            $oOrderArticle->oxorderarticles__oxartid = new \OxidEsales\Eshop\Core\Field($oContent->getProductId());
            $oOrderArticle->oxorderarticles__oxamount = new \OxidEsales\Eshop\Core\Field($oContent->getAmount());

            // prices
            $oPrice = $oContent->getPrice();
            $oOrderArticle->oxorderarticles__oxnetprice = new \OxidEsales\Eshop\Core\Field($oPrice->getNettoPrice(), \OxidEsales\Eshop\Core\Field::T_RAW);
            $oOrderArticle->oxorderarticles__oxvatprice = new \OxidEsales\Eshop\Core\Field($oPrice->getVatValue(), \OxidEsales\Eshop\Core\Field::T_RAW);
            $oOrderArticle->oxorderarticles__oxbrutprice = new \OxidEsales\Eshop\Core\Field($oPrice->getBruttoPrice(), \OxidEsales\Eshop\Core\Field::T_RAW);
            $oOrderArticle->oxorderarticles__oxvat = new \OxidEsales\Eshop\Core\Field($oPrice->getVat(), \OxidEsales\Eshop\Core\Field::T_RAW);

            $oUnitPrice = $oContent->getUnitPrice();
            $oOrderArticle->oxorderarticles__oxnprice = new \OxidEsales\Eshop\Core\Field($oUnitPrice->getNettoPrice(), \OxidEsales\Eshop\Core\Field::T_RAW);
            $oOrderArticle->oxorderarticles__oxbprice = new \OxidEsales\Eshop\Core\Field($oUnitPrice->getBruttoPrice(), \OxidEsales\Eshop\Core\Field::T_RAW);

            // wrap id
            $oOrderArticle->oxorderarticles__oxwrapid = new \OxidEsales\Eshop\Core\Field($oContent->getWrappingId(), \OxidEsales\Eshop\Core\Field::T_RAW);

            // items shop id
            $oOrderArticle->oxorderarticles__oxordershopid = new \OxidEsales\Eshop\Core\Field($oContent->getShopId(), \OxidEsales\Eshop\Core\Field::T_RAW);

            // bundle?
            $oOrderArticle->oxorderarticles__oxisbundle = new \OxidEsales\Eshop\Core\Field($oContent->isBundle());

            // add information for eMail
            //P
            //TODO: check if this assign is needed at all
            $oOrderArticle->oProduct = $oProduct;

            $oOrderArticle->setArticle($oProduct);

            // simulation order article list
            $this->_oArticles->offsetSet($oOrderArticle->getId(), $oOrderArticle);
        }
    }
710406
public function loadOrderArticles($aOrders)
    {
        if (!count($aOrders)) {
            $this->clear();

            return;
        }

        foreach ($aOrders as $iKey => $oOrder) {
            $aOrdersIds[] = $oOrder->getId();
        }

        $oBaseObject = $this->getBaseObject();
        $sArticleTable = $oBaseObject->getViewName();
        $sArticleFields = $oBaseObject->getSelectFields();
        $sArticleFields = str_replace("`$sArticleTable`.`oxid`", "`oxorderarticles`.`oxartid` AS `oxid`", $sArticleFields);

        $sSelect = "SELECT $sArticleFields FROM oxorderarticles ";
        $sSelect .= "left join $sArticleTable on oxorderarticles.oxartid = $sArticleTable.oxid ";
        $sSelect .= "WHERE oxorderarticles.oxorderid IN ( '" . implode("','", $aOrdersIds) . "' ) ";
        $sSelect .= "order by $sArticleTable.oxid ";

        $this->selectString($sSelect);

        // not active or not available products must not have button "tobasket"
        $sNow = date('Y-m-d H:i:s');
        foreach ($this as $oArticle) {
            if (!$oArticle->oxarticles__oxactive->value &&
                ($oArticle->oxarticles__oxactivefrom->value > $sNow ||
                 $oArticle->oxarticles__oxactiveto->value < $sNow
                )
            ) {
                $oArticle->setBuyableState(false);
            }
        }
    }
249699
protected function createItemBagForOrder(Order $order)
    {
        if (!$this->sendCartInfo) {
            return null;
        }

        $items = $this->getItemListForOrder($order);
        $itemBagClassName = $this->getItemBagClassName();

        return new $itemBagClassName($items);
    }
1025577
protected function _prepareForTemplate($oOrderFileList)
    {
        $oOrderArticles = [];

        foreach ($oOrderFileList as $oOrderFile) {
            $sOrderArticleIdField = 'oxorderfiles__oxorderarticleid';
            $sOrderNumberField = 'oxorderfiles__oxordernr';
            $sOrderDateField = 'oxorderfiles__oxorderdate';
            $sOrderTitleField = 'oxorderfiles__oxarticletitle';
            $sOrderArticleId = $oOrderFile->$sOrderArticleIdField->value;
            $oOrderArticles[$sOrderArticleId]['oxordernr'] = $oOrderFile->$sOrderNumberField->value;
            $oOrderArticles[$sOrderArticleId]['oxorderdate'] = substr($oOrderFile->$sOrderDateField->value, 0, 16);
            $oOrderArticles[$sOrderArticleId]['oxarticletitle'] = $oOrderFile->$sOrderTitleField->value;
            $oOrderArticles[$sOrderArticleId]['oxorderfiles'][] = $oOrderFile;
        }

        return $oOrderArticles;
    }
997187
public function addArticleAcc()
    {
        $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
        $aChosenArt = $this->_getActionIds('oxarticles.oxid');
        $soxId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');

        // adding
        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('all')) {
            $sArtTable = $this->_getViewName('oxarticles');
            $aChosenArt = $this->_getAll(parent::_addFilter("select $sArtTable.oxid " . $this->_getQuery()));
        }

        if ($oArticle->load($soxId) && $soxId && $soxId != "-1" && is_array($aChosenArt)) {
            foreach ($aChosenArt as $sChosenArt) {
                $oNewGroup = oxNew(\OxidEsales\Eshop\Core\Model\BaseModel::class);
                $oNewGroup->init("oxaccessoire2article");
                $oNewGroup->oxaccessoire2article__oxobjectid = new \OxidEsales\Eshop\Core\Field($sChosenArt);
                $oNewGroup->oxaccessoire2article__oxarticlenid = new \OxidEsales\Eshop\Core\Field($oArticle->oxarticles__oxid->value);
                $oNewGroup->oxaccessoire2article__oxsort = new \OxidEsales\Eshop\Core\Field(0);
                $oNewGroup->save();
            }

            $this->onArticleAccessoryRelationChange($oArticle);
        }
    }
767761
protected function createSubscriptions( \Aimeos\MShop\Order\Item\Base\Iface $basket )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'subscription' );

		foreach( $basket->getProducts() as $orderProduct )
		{
			if( ( $interval = $orderProduct->getAttribute( 'interval', 'config' ) ) !== null )
			{
				$item = $manager->createItem()->setInterval( $interval )
					->setOrderProductId( $orderProduct->getId() )
					->setOrderBaseId( $basket->getId() );

				if( ( $end = $orderProduct->getAttribute( 'intervalend', 'custom' ) ) !== null
					|| ( $end = $orderProduct->getAttribute( 'intervalend', 'config' ) ) !== null
					|| ( $end = $orderProduct->getAttribute( 'intervalend', 'hidden' ) ) !== null
				) {
					$item = $item->setDateEnd( $end );
				}

				$manager->saveItem( $item, false );
			}
		}
	}
586246
public function process(Basket $basket)
    {
        $meta     = $this->meta($basket);
        $products = $this->products($basket);

        return new Order($meta, $products);
    }
781645
public function setOrderItemCategory($orderItemCategory) 
    {
        if (!$this->_isNumericArray($orderItemCategory)) {
            $orderItemCategory =  array ($orderItemCategory);    
        }
        $this->_fields['OrderItemCategory']['FieldValue'] = $orderItemCategory;
        return $this;
    }