Generates the basket hash.

@param string          $sAmazonOrderReferenceId
@param oxBasket|\OxidEsales\Eshop\Application\Model\Basket $oBasket

@return string

@throws oxArticleException
@throws oxArticleInputException
@throws oxNoArticleException
165781
public function getBasketHash($sAmazonOrderReferenceId, $oBasket)
    {
        $aBasket = array(
            'amazonOrderReferenceId' => $sAmazonOrderReferenceId,
            'totalSum' => $oBasket->getBruttoSum(),
            'contents' => array()
        );

        /** @var oxBasketItem $oBasketItem */
        foreach ($oBasket->getContents() as $oBasketItem) {
            $sId = $oBasketItem->getArticle()->getId();
            $aBasket['contents'][$sId] = $oBasketItem->getAmount();
        }

        return md5(json_encode($aBasket));
    }
1245632
public function tobasket(
        $sProductId = null,
        $dAmount = null,
        $aSelectList = null,
        $aPersistentParameters = null,
        $blOverride = false
    ) {
        $oContainer = $this->_getContainer();
        $oConfig = $oContainer->getConfig();
        $isAmazonPay = (bool)$oConfig->getRequestParameter('bestitAmazonPayIsAmazonPay');
        $sReturn = null;

        if ($isAmazonPay === true) {
            $oContainer->getBasketUtil()->setQuickCheckoutBasket();
            $sAmazonOrderReferenceId = $oConfig->getRequestParameter('amazonOrderReferenceId');
            $sAccessToken = $oConfig->getRequestParameter('access_token');
            $sReturn = 'user?fnc=amazonLogin&redirectCl=user&amazonOrderReferenceId='.$sAmazonOrderReferenceId
                .'&access_token='.$sAccessToken;
        }

        $sDefaultReturn = $this->_parentToBasket(
            $sProductId,
            $dAmount,
            $aSelectList,
            $aPersistentParameters,
            $blOverride
        );

        if ($isAmazonPay === true) {
            $oSession = $oContainer->getSession();
            $oSession->setVariable('blAddedNewItem', false);
            $oSession->setVariable('isAmazonPayQuickCheckout', true);
            return $sReturn;
        }

        return $sDefaultReturn;
    }
641457
public function getBasketLink()
    {
        if ($this->getAmazonLoginIsActive() === true) {
            $sValue = $this->getViewConfigParam('basketlink');

            if ((string)$sValue === '') {
                $sValue = $this->_getContainer()->getConfig()->getShopSecureHomeUrl().'cl=basket';
                $this->setViewConfigParam('basketlink', $sValue);
            }

            return $sValue;
        }

        return parent::getBasketLink();
    }
414044
public function getBasketBundleDiscounts($oBasket, $oUser = null)
    {
        $aList = [];
        $aDiscList = $this->_getList($oUser)->getArray();
        /** @var \OxidEsales\Eshop\Application\Model\Discount $oDiscount */
        foreach ($aDiscList as $oDiscount) {
            if ($oDiscount->isForBundleBasket($oBasket)) {
                $aList[$oDiscount->getId()] = $oDiscount;
            }
        }

        return $aList;
    }
352106
public static function createFromOrderReferenceId(Connection $dbal, $amazon_order_reference_id)
    {
        $data = $dbal->fetchAll(
            'select * from '.self::PERSIST_TABLE.' WHERE `amazon_order_reference_id` = ? ORDER BY `cmsident`',
            array($amazon_order_reference_id)
        );
        $manager = self::createFromRecordList($data);

        if (null === $manager) {
            throw new \InvalidArgumentException("unable to find an an id mapper object based on the amazonOrderReferenceId [{$amazon_order_reference_id}]");
        }

        return $manager;
    }
371468
public function getBasketArticles()
    {
        if ($this->_oBasketArtList === null) {
            $this->_oBasketArtList = false;
            if ($oBasket = $this->getBasket()) {
                $this->_oBasketArtList = $oBasket->getBasketArticles();
            }
        }

        return $this->_oBasketArtList;
    }
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);
            }
        }
    }
415619
public function createReference($reactionId)
    {
        $myReactionId = $reactionId;
        if(is_array($reactionId) && array_key_exists('id', $reactionId)){
            $myReactionId = $reactionId['id'];
        }
        return 'SR:' . $myReactionId;
    }
774502
public function load($oxID)
    {

        $blRet = parent::load($oxID);

        // convert date's to international format
        if (isset($this->oxuser__oxcreate->value)) {
            $this->oxuser__oxcreate->setValue(Registry::getUtilsDate()->formatDBDate($this->oxuser__oxcreate->value));
        }

        // change newsSubcription user id
        if (isset($this->_oNewsSubscription)) {
            $this->_oNewsSubscription->oxnewssubscribed__oxuserid = new \OxidEsales\Eshop\Core\Field($oxID, \OxidEsales\Eshop\Core\Field::T_RAW);
        }

        return $blRet;
    }
108115
protected function _OxpsPaymorrowOxOrder_finalizeOrder_parent( oxBasket $oBasket, $oUser,
                                                                   $blRecalculatingOrder = false )
    {
        return parent::finalizeOrder( $oBasket, $oUser, $blRecalculatingOrder );
    }
662523
public function isForBasket($oBasket)
    {
        // initial configuration check
        if ($this->oxdiscount__oxamount->value == 0 && $this->oxdiscount__oxprice->value == 0) {
            return false;
        }

        $oSummary = $oBasket->getBasketSummary();
        // amounts check
        if ($this->oxdiscount__oxamount->value && ($oSummary->iArticleCount < $this->oxdiscount__oxamount->value || $oSummary->iArticleCount > $this->oxdiscount__oxamountto->value)) {
            return false;
            // price check
        } elseif ($this->oxdiscount__oxprice->value) {
            $dRate = $oBasket->getBasketCurrency()->rate;
            if ($oSummary->dArticleDiscountablePrice < $this->oxdiscount__oxprice->value * $dRate || $oSummary->dArticleDiscountablePrice > $this->oxdiscount__oxpriceto->value * $dRate) {
                return false;
            }
        }

        // oxobject2discount configuration check
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sQ = 'select 1 from oxobject2discount where oxdiscountid = ' . $oDb->quote($this->oxdiscount__oxid->value) . ' and oxtype in ("oxarticles", "oxcategories" ) ';

        return !((bool) $oDb->getOne($sQ));
    }
151527
public function getProductNumber()
    {
        /** @var $this OxpsPaymorrowOxBasketItem|oxBasketItem */

        /** @var oxArticle $oArticle */
        $oArticle = $this->getArticle();

        return isset( $oArticle->oxarticles__oxartnum->value ) ? (string) $oArticle->oxarticles__oxartnum->value : '';
    }
594084
public function getFirstBasketProduct()
    {
        if ($this->_oFirstBasketProduct === null) {
            $this->_oFirstBasketProduct = false;

            $aBasketArticles = $this->getBasketArticles();
            if (is_array($aBasketArticles) && $oProduct = reset($aBasketArticles)) {
                $this->_oFirstBasketProduct = $oProduct;
            }
        }

        return $this->_oFirstBasketProduct;
    }
861630
public function setOrderReferenceDetails($oBasket = null, array $aRequestParameters = array())
    {
        //Set default params
        $aRequestParameters['amazon_order_reference_id'] = $this->getSession()->getVariable('amazonOrderReferenceId');

        if ($oBasket !== null) {
            $oActiveShop = $this->getConfig()->getActiveShop();
            $sShopName = $oActiveShop->getFieldData('oxname');
            $sOxidVersion = $oActiveShop->getFieldData('oxversion');
            $sModuleVersion = bestitAmazonPay4Oxid_init::getCurrentVersion();

            $aRequestParameters = array_merge(
                $aRequestParameters,
                array(
                    'amount' => $oBasket->getPrice()->getBruttoPrice(),
                    'currency_code' => $oBasket->getBasketCurrency()->name,
                    'platform_id' => 'A26EQAZK19E0U2',
                    'store_name' => $sShopName,
                    'custom_information' => "created by best it, OXID eShop v{$sOxidVersion}, v{$sModuleVersion}"
                )
            );
        }

        $this->_addSandboxSimulationParams('setOrderReferenceDetails', $aRequestParameters);

        return $this->_convertResponse($this->_getAmazonClient()->setOrderReferenceDetails($aRequestParameters));
    }
1044768
public function addReference($columnName, $refTable, $refColumn,
            $onDelete = 'RESTRICT', $onUpdate = 'RESTRICT') {
        $this->addIndex($columnName);
        $this->newReferences[$columnName] = array(
            'table' => $refTable,
            'column' => $refColumn,
            'onDelete' => $onDelete,
            'onUpdate' => $onUpdate,
        );
        return $this;
    }
1344567
protected function _getBasketAndSessionHash()
    {
        $oSession = oxRegistry::getSession();
        $oBasket  = $oSession->getBasket();

        return md5(
            $oSession->getId() . serialize( $oBasket ) .
            $this->getUniqueString( self::OXPS_PAYMORROW_ORDER_HASH_SALT )
        );
    }
902837
protected function &SaveArticle(TShopBasketArticle $oBasketItem)
    {
        $oVat = $oBasketItem->GetVat();
        $oOrderItem = TdbShopOrderItem::GetNewInstance();
        /** @var $oOrderItem TdbShopOrderItem */
        $oManufacturer = TdbShopManufacturer::GetNewInstance();
        $oManufacturer->Load($oBasketItem->fieldShopManufacturerId);
        $aData = array(
            'shop_order_id' => $this->id,
            'basket_item_key' => $oBasketItem->sBasketItemKey,
            'shop_article_id' => $oBasketItem->id,
            'name' => $oBasketItem->fieldName,
            'name_variant_info' => $oBasketItem->fieldNameVariantInfo,
            'articlenumber' => $oBasketItem->fieldArticlenumber,
            'description_short' => $oBasketItem->fieldDescriptionShort,
            'description' => $oBasketItem->fieldDescription,
            'shop_manufacturer_id' => $oBasketItem->fieldShopManufacturerId,
            'shop_manufacturer_name' => $oManufacturer->GetName(),
            'price' => $oBasketItem->fieldPrice,
            'price_reference' => $oBasketItem->fieldPriceReference,
            'vat_percent' => $oVat->fieldVatPercent,
            'size_weight' => $oBasketItem->fieldSizeWeight,
            'size_width' => $oBasketItem->fieldSizeWidth,
            'size_height' => $oBasketItem->fieldSizeHeight,
            'size_length' => $oBasketItem->fieldSizeLength,
            'stock' => $oBasketItem->getAvailableStock(),
            'virtual_article' => $oBasketItem->sqlData['virtual_article'],
            'exclude_from_vouchers' => $oBasketItem->sqlData['exclude_from_vouchers'],
            'subtitle' => $oBasketItem->fieldSubtitle,
            'is_new' => $oBasketItem->sqlData['is_new'],
            'usp' => $oBasketItem->fieldUsp,
            'is_bundle' => $oBasketItem->sqlData['is_bundle'],
            'order_amount' => $oBasketItem->dAmount,
            'order_price' => $oBasketItem->dPrice,
            'order_price_total' => $oBasketItem->dPriceTotal,
            'order_price_after_discounts' => $oBasketItem->dPriceTotalAfterDiscount,
            'order_total_weight' => $oBasketItem->dTotalWeight,
            'order_total_volume' => $oBasketItem->dTotalVolume,
            'download' => $oBasketItem->fieldDownload,
            'price_discounted' => $oBasketItem->dPriceAfterDiscount,
            'exclude_from_discounts' => $oBasketItem->sqlData['exclude_from_discounts'],
            'quantity_in_units' => $oBasketItem->fieldQuantityInUnits,
            'shop_unit_of_measurement_id' => $oBasketItem->fieldShopUnitOfMeasurementId,
            'custom_data' => $oBasketItem->getCustomData(),
        );
        $this->PrepareArticleDataForSave($oBasketItem, $aData);
        $oOrderItem->LoadFromRow($aData);
        $oOrderItem->AllowEditByAll(true);
        $iInsertedOrderArticleId = $oOrderItem->Save();

        //Linking the downloads from BasketItem to OrderItem
        $oDownloadFilesList = $oBasketItem->GetDownloads('download');
        while ($oDownloadFile = $oDownloadFilesList->Next()) {
            $sQuery = "INSERT INTO `shop_order_item_download_cms_document_mlt`
                           SET `source_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iInsertedOrderArticleId)."',
                               `target_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($oDownloadFile->id)."'";
            MySqlLegacySupport::getInstance()->query($sQuery);
        }

        if ($oBasketItem->fieldIsBundle) {
            // also save bundle articles
            $oBundleArticles = $oBasketItem->GetFieldShopBundleArticleList();
            while ($oBundleArticle = $oBundleArticles->Next()) {
                $this->SaveBundleArticle($oBasketItem, $oOrderItem, $oBundleArticle);
            }
        }

        return $oOrderItem;
    }