Get a list of shipping types based on a basket article list and the desired shipping country id.

@param TShopBasketArticleList $oBasketArticleList
@param string                 $sDataCountryId

@return TIterator
199843
public function GetValidShippingTypesForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
    {
        $oValidShippingTypes = new TIterator();
        /** @var $oValidShippingTypes TIterator* */
        $oShippingTypes = $this->GetFieldShopShippingTypeList('position');
        while ($oShippingType = $oShippingTypes->Next()) {
            $bIsValid = $oShippingType->IsActive();
            $bIsValid = $bIsValid && $oShippingType->isValidForCurrentPortal();
            $bIsValid = $bIsValid && $oShippingType->IsValidForCurrentUser(false);
            $bIsValid = $bIsValid && $oShippingType->IsValidForCountry($sDataCountryId);
            if ($bIsValid) {
                $oAffectedArticles = $oBasketArticleList->GetArticlesAffectedByShippingType($oShippingType);
                $bIsValid = ($oAffectedArticles->Length() > 0);
            }
            if ($bIsValid) {
                $oValidShippingTypes->AddItem($oShippingType);
            }
        }

        return $oValidShippingTypes;
    }
821812
protected function GetExportRowFromDataObject(&$oDataObjct)
    {
        $aRow = parent::GetExportRowFromDataObject($oDataObjct);
        $aRow['adr_billing_country_name'] = '';
        $aRow['adr_billing_salutation_name'] = '';
        $aRow['adr_shipping_country_name'] = '';
        $aRow['adr_shipping_salutation_name'] = '';

        $oCountry = $oDataObjct->GetFieldAdrBillingCountry();
        if (!is_null($oCountry)) {
            $aRow['adr_billing_country_name'] = $oCountry->fieldName;
        }
        $oCountry = $oDataObjct->GetFieldAdrShippingCountry();
        if (!is_null($oCountry)) {
            $aRow['adr_shipping_country_name'] = $oCountry->fieldName;
        }
        $oSal = $oDataObjct->GetFieldAdrBillingSalutation();
        if (!is_null($oSal)) {
            $aRow['adr_billing_salutation_name'] = $oSal->fieldName;
        }
        $oSal = $oDataObjct->GetFieldAdrShippingSalutation();
        if (!is_null($oSal)) {
            $aRow['adr_shipping_salutation_name'] = $oSal->fieldName;
        }

        $oLocale = &TCMSLocal::GetActive();
        $aRow['value_vat_total'] = $oLocale->FormatNumber($aRow['value_vat_total'], 2);
        $aRow['count_unique_articles'] = $oLocale->FormatNumber($aRow['count_unique_articles'], 2);

        $aRow['value_article'] = $oLocale->FormatNumber($aRow['value_article'], 2);
        $aRow['value_total'] = $oLocale->FormatNumber($aRow['value_total'], 2);
        $aRow['totalweight'] = $oLocale->FormatNumber($aRow['totalweight'], 2);
        $aRow['totalvolume'] = $oLocale->FormatNumber($aRow['totalvolume'], 2);
        $aRow['count_articles'] = $oLocale->FormatNumber($aRow['count_articles'], 2);

        $aRow['shop_shipping_group_price'] = $oLocale->FormatNumber($aRow['shop_shipping_group_price'], 2);
        $aRow['shop_shipping_group_vat_percent'] = $oLocale->FormatNumber($aRow['shop_shipping_group_vat_percent'], 2);
        $aRow['shop_payment_method_price'] = $oLocale->FormatNumber($aRow['shop_payment_method_price'], 2);
        $aRow['shop_payment_method_vat_percent'] = $oLocale->FormatNumber($aRow['shop_payment_method_vat_percent'], 2);

        return $aRow;
    }
779213
public function LoadFromBasket(TShopBasket &$oBasket)
    {
        $oShop = TdbShop::GetInstance();
        $oPortal = $this->getPortalDomainService()->getActivePortal();
        $oUser = TdbDataExtranetUser::GetInstance();
        $oBillingAdr = $oUser->GetBillingAddress();

        $sAffiliateCode = $oShop->GetAffilateCode();
        if (false === $sAffiliateCode) {
            $sAffiliateCode = '';
        }

        $pkg_shop_affiliate_id = '';
        $oAffiliatePartnerProgram = TdbPkgShopAffiliate::GetActiveInstance();
        if ($oAffiliatePartnerProgram) {
            if (!empty($oAffiliatePartnerProgram->sCode)) {
                $pkg_shop_affiliate_id = $oAffiliatePartnerProgram->id;
            }
        }
        $request = $this->getCurrentRequest();
        $aOrderData = array(
            'shop_id' => $oShop->id,
            'cms_portal_id' => $oPortal->id,
            'ordernumber' => '',
            'order_ident' => $oBasket->sBasketIdentifier,
            'data_extranet_user_id' => $oUser->id,
            'user_email' => $oUser->GetUserEMail(),
            'customer_number' => $oUser->GetCustomerNumber(),
            'vat_id' => $oUser->fieldVatId,
            'adr_billing_company' => $oBillingAdr->fieldCompany,
            'adr_billing_salutation_id' => $oBillingAdr->fieldDataExtranetSalutationId,
            'adr_billing_firstname' => $oBillingAdr->fieldFirstname,
            'adr_billing_lastname' => $oBillingAdr->fieldLastname,
            'adr_billing_street' => $oBillingAdr->fieldStreet,
            'adr_billing_streetnr' => $oBillingAdr->fieldStreetnr,
            'adr_billing_city' => $oBillingAdr->fieldCity,
            'adr_billing_postalcode' => $oBillingAdr->fieldPostalcode,
            'adr_billing_country_id' => $oBillingAdr->fieldDataCountryId,
            'adr_billing_telefon' => $oBillingAdr->fieldTelefon,
            'adr_billing_fax' => $oBillingAdr->fieldFax,
            'adr_shipping_use_billing' => '1',
            'adr_shipping_salutation_id' => '',
            'adr_shipping_company' => '',
            'adr_shipping_firstname' => '',
            'adr_shipping_lastname' => '',
            'adr_shipping_street' => '',
            'adr_shipping_streetnr' => '',
            'adr_shipping_city' => '',
            'adr_shipping_postalcode' => '',
            'adr_shipping_country_id' => '',
            'adr_shipping_telefon' => '',
            'adr_shipping_fax' => '',
            'shop_shipping_group_price' => $oBasket->dCostShipping,
            'shop_payment_method_price' => $oBasket->dCostPaymentMethodSurcharge,
            'value_article' => $oBasket->dCostArticlesTotal,
            'value_total' => $oBasket->dCostTotal,
            'value_wrapping' => $oBasket->dCostWrapping,
            'value_wrapping_card' => $oBasket->dCostWrappingCards,
            'value_vouchers' => $oBasket->dCostVouchers,
            'value_vouchers_not_sponsored' => $oBasket->dCostNoneSponsoredVouchers,
            'value_discounts' => $oBasket->dCostDiscounts,
            'value_vat_total' => $oBasket->dCostVAT,
            'count_articles' => $oBasket->dTotalNumberOfArticles,
            'count_unique_articles' => $oBasket->iTotalNumberOfUniqueArticles,
            'totalweight' => $oBasket->dTotalWeight,
            'totalvolume' => $oBasket->dTotalVolume,
            'affiliate_code' => $sAffiliateCode,
            'pkg_shop_affiliate_id' => $pkg_shop_affiliate_id,
            'cms_language_id' => self::getLanguageService()->getActiveLanguageId(),
            'user_ip' => null === $request ? '' : $request->getClientIp(),
        );
        if (property_exists($oBillingAdr, 'fieldAddressAdditionalInfo')) {
            $aOrderData['adr_billing_additional_info'] = $oBillingAdr->fieldAddressAdditionalInfo;
        }

        $oShippingGroup = $oBasket->GetActiveShippingGroup();
        if ($oShippingGroup) {
            $oShippingVat = $oShippingGroup->GetVat();
            $aOrderData['shop_shipping_group_id'] = $oShippingGroup->id;
            $aOrderData['shop_shipping_group_name'] = $oShippingGroup->fieldName;
            if ($oShippingVat) {
                $aOrderData['shop_shipping_group_vat_percent'] = $oShippingVat->fieldVatPercent;
            }
        }
        $oPayment = $oBasket->GetActivePaymentMethod();
        if ($oPayment) {
            $aOrderData['shop_payment_method_id'] = $oPayment->id;
            $aOrderData['shop_payment_method_name'] = $oPayment->fieldName;
            $oPaymentVat = $oPayment->GetVat();
            if ($oPaymentVat) {
                $aOrderData['shop_payment_method_vat_percent'] = $oPaymentVat->fieldVatPercent;
            }
        }

        if (!$oUser->ShipToBillingAddress()) {
            $oShippingAdr = $oUser->GetShippingAddress();
            $aOrderData['adr_shipping_use_billing'] = '0';
            $aOrderData['adr_shipping_salutation_id'] = $oShippingAdr->fieldDataExtranetSalutationId;
            $aOrderData['adr_shipping_company'] = $oShippingAdr->fieldCompany;
            $aOrderData['adr_shipping_firstname'] = $oShippingAdr->fieldFirstname;
            $aOrderData['adr_shipping_lastname'] = $oShippingAdr->fieldLastname;
            $aOrderData['adr_shipping_street'] = $oShippingAdr->fieldStreet;
            $aOrderData['adr_shipping_streetnr'] = $oShippingAdr->fieldStreetnr;
            $aOrderData['adr_shipping_city'] = $oShippingAdr->fieldCity;
            $aOrderData['adr_shipping_postalcode'] = $oShippingAdr->fieldPostalcode;
            $aOrderData['adr_shipping_country_id'] = $oShippingAdr->fieldDataCountryId;
            $aOrderData['adr_shipping_telefon'] = $oShippingAdr->fieldTelefon;
            $aOrderData['adr_shipping_fax'] = $oShippingAdr->fieldFax;
            if (property_exists($oShippingAdr, 'fieldAddressAdditionalInfo')) {
                $aOrderData['adr_shipping_additional_info'] = $oShippingAdr->fieldAddressAdditionalInfo;
            }
        }
        $this->LoadFromBasketPostProcessData($oBasket, $aOrderData);
        $this->LoadFromRow($aOrderData);
    }
47717
public function getCategoryString($oArticle, $sSeparator = "/")
    {
        $sCatStr = '';

        $sLang = \OxidEsales\Eshop\Core\Registry::getLang()->getBaseLanguage();
        $oDB = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        $sCatView = getViewName('oxcategories', $sLang);
        $sO2CView = getViewName('oxobject2category', $sLang);

        //selecting category
        $sQ = "select $sCatView.oxleft, $sCatView.oxright, $sCatView.oxrootid from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
        $sQ .= "where oxobject2category.oxobjectid=" . $oDB->quote($oArticle->getId()) . " and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";

        $oRs = $oDB->select($sQ);
        if ($oRs != false && $oRs->count() > 0) {
            $sLeft = $oRs->fields[0];
            $sRight = $oRs->fields[1];
            $sRootId = $oRs->fields[2];

            //selecting all parent category titles
            $sQ = "select oxtitle from $sCatView where oxright >= {$sRight} and oxleft <= {$sLeft} and oxrootid = '{$sRootId}' order by oxleft ";

            $oRs = $oDB->select($sQ);
            if ($oRs != false && $oRs->count() > 0) {
                while (!$oRs->EOF) {
                    if ($sCatStr) {
                        $sCatStr .= $sSeparator;
                    }
                    $sCatStr .= $oRs->fields[0];
                    $oRs->fetchRow();
                }
            }
        }

        return $sCatStr;
    }
32587
protected function getDataFromVoucher(TdbShopVoucherUse $oVoucherUse, TdbShopVoucher $oVoucher = null, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aVoucher = array(
            'sCode' => '',
            'sName' => '',
            'dValue' => $oVoucherUse->fieldValueUsed,
            'dValueInOrderCurrency' => $oVoucherUse->fieldValueUsedInOrderCurrency,
            'sValue' => TCMSLocal::GetActive()->FormatNumber($oVoucherUse->fieldValueUsed, 2),
            'sValueInOrderCurrency' => TCMSLocal::GetActive()->FormatNumber($oVoucherUse->fieldValueUsedInOrderCurrency, 2),
            'sRemoveFromBasketLink' => '#', );

        if (null !== $oVoucher) {
            $aVoucher['sCode'] = $oVoucher->fieldCode;
            $oVoucherSeries = &$oVoucher->GetFieldShopVoucherSeries();
            if (null !== $oVoucherSeries) {
                if ($bCachingEnabled) {
                    $oCacheTriggerManager->addTrigger($oVoucherSeries->table, $oVoucherSeries->id);
                }
                $aVoucher['sName'] = $oVoucherSeries->fieldName;
            }
        }

        return $aVoucher;
    }
1335562
public function GetShippingCostsForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
    {
        /** @var Request $request */
        $request = \ChameleonSystem\CoreBundle\ServiceLocator::get('request_stack')->getCurrentRequest();

        $oBasketArticleList->GoToStart();

        $oOldBasket = clone TShopBasket::GetInstance();
        $oOldUser = clone TdbDataExtranetUser::GetInstance();

        $oTmpBasket = new TShopBasket();
        $request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oTmpBasket);

        $oTmpUser = TdbDataExtranetUser::GetNewInstance();

        $oTmpShippingAddress = TdbDataExtranetUserAddress::GetNewInstance();
        $oTmpShippingAddress->fieldDataCountryId = $sDataCountryId;
        $oTmpShippingAddress->sqlData['data_country_id'] = $sDataCountryId;
        $oTmpShippingAddress->sqlData['lastname'] = 'Dummy';
        $oTmpShippingAddress->fieldLastname = 'Dummy';
        $oTmpShippingAddress->sqlData['city'] = 'Dummy';

        $oTmpUser->setFakedShippingAddressForUser($oTmpShippingAddress);

        $oTmpUser->fieldDataCountryId = $sDataCountryId;
        $oTmpUser->sqlData['data_country_id'] = $sDataCountryId;
        $oTmpUser->sqlData['lastname'] = 'Dummy';
        $oTmpUser->sqlData['city'] = 'Dummy';

        $request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oTmpUser);

        while ($oBasketArticle = $oBasketArticleList->Next()) {
            $oTmpBasket->AddItem($oBasketArticle);
        }

        $oTmpBasket->SetActiveShippingGroup($this);

        $oTmpBasket->RecalculateBasket();
        $oTmpBasket->ResetAllShippingMarkers();

        $dShippingCosts = $oTmpBasket->dCostShipping;

        $request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oOldBasket);
        $request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oOldUser);

        return $dShippingCosts;
    }
1216967
public function ExecutePayment(TdbShopOrder &$oOrder, $sMessageConsumer = '')
    {
        $bPaymentOk = parent::ExecutePayment($oOrder);

        if ($bPaymentOk && $this->TransactionMatchesCurrentBasketState()) {
            $bPaymentOk = $this->UpdateTransaction('SAS'); //capture
        } else {
            $bPaymentOk = false;
        }

        return $bPaymentOk;
    }
651725
@Override
	public List<CommerceCountry> getCommerceCountriesByUuidAndCompanyId(
		String uuid, long companyId) {
		return commerceCountryPersistence.findByUuid_C(uuid, companyId);
	}
359608
public function scopeGetByPriceType($obQuery, $sData)
    {
        if (!empty($sData)) {
            $obQuery->where('price_type_id', $sData);
        } else {
            $obQuery->whereNull('price_type_id');
        }

        return $obQuery;
    }
91375
protected function &GetBasketArticles()
    {
        if (is_null($this->oBasketArticles)) {
            $this->oBasketArticles = new TShopBasketArticleList();
        }
        // attach basket as observer - but on first call only
        $this->oBasketArticles->ObserverRegister('oBasketInstance', $this);

        return $this->oBasketArticles;
    }
353144
public function getBasketPrice($dAmount, $aSelList, $oBasket)
    {
        $oUser = $oBasket->getBasketUser();
        $this->setArticleUser($oUser);

        $oBasketPrice = $this->_getPriceObject($oBasket->isCalculationModeNetto());

        // get base price
        $dBasePrice = $this->getBasePrice($dAmount);

        $dBasePrice = $this->_modifySelectListPrice($dBasePrice, $aSelList);
        $dBasePrice = $this->_preparePrice($dBasePrice, $this->getArticleVat(), $oBasket->isCalculationModeNetto());

        // applying select list price

        // setting price
        $oBasketPrice->setPrice($dBasePrice);

        $dVat = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Application\Model\VatSelector::class)->getBasketItemVat($this, $oBasket);
        $this->_calculatePrice($oBasketPrice, $dVat);

        // returning final price object
        return $oBasketPrice;
    }
1298205
protected function _getArticleBundles($oBasketItem)
    {
        $aBundles = [];

        if ($oBasketItem->isBundle()) {
            return $aBundles;
        }

        $oArticle = $oBasketItem->getArticle(true);
        if ($oArticle && $oArticle->oxarticles__oxbundleid->value) {
            $aBundles[$oArticle->oxarticles__oxbundleid->value] = 1;
        }

        return $aBundles;
    }
159681
public function isAvailableForCountry($obCountry) : bool
    {
        $arCountryIDList = (array) $this->country_id_list;

        $bResult = !empty($arCountryIDList) && !empty($obCountry) && in_array($obCountry->id, $arCountryIDList);

        return $bResult;
    }
625911
public static function &GetAvailableShippingGroups()
    {
        $oList = &TdbShopShippingGroupList::GetList();
        $oList->bAllowItemCache = true;
        $oList->RemoveInvalidItems();
        $oList->GoToStart();

        return $oList;
    }
338524
protected function _addOrderArticlesToBasket($oBasket, $aOrderArticles)
    {
        // if no order articles, return empty basket
        if (count($aOrderArticles) > 0) {
            //adding order articles to basket
            foreach ($aOrderArticles as $oOrderArticle) {
                $oBasket->addOrderArticleToBasket($oOrderArticle);
            }
        }
    }
1335930
protected function SetShippingTypeForArticle(TShopBasketArticle &$oItem, TdbShopShippingType &$oShippingType)
    {
        $iCurrentPos = $this->getItemPointer();
        $this->GoToStart();
        $bFound = false;
        while (!$bFound && ($oExistingItem = &$this->Next())) {
            /** @var $oExistingItem TShopBasketArticle */
            if ($oExistingItem->IsSameAs($oItem)) {
                $bFound = true;
            }
        }
        if ($bFound) {
            $oExistingItem->SetActingShippingType($oShippingType);
        }
        $this->setItemPointer($iCurrentPos);
    }
843133
protected function getArticleList(TdbShopOrder $oOrder, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aArticleList = array();
        $oOrderItemList = &$oOrder->GetFieldShopOrderItemList();
        while ($oOrderItem = &$oOrderItemList->Next()) {
            if ($bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oOrderItem->table, $oOrderItem->id);
            }
            $aArticleList[] = $this->getArticle($oOrderItem, $oCacheTriggerManager, $bCachingEnabled);
        }

        return $aArticleList;
    }