Checks if given basket article is buyable. If not remove it from basket with message.

@param TShopBasketArticle $oBasketArticle
@param string             $sMessageManager

@return bool
775484
private function validateBasketContentBuyable(TShopBasketArticle $oBasketArticle, $sMessageManager)
    {
        $bValid = true;
        if (false === $oBasketArticle->IsBuyable()) {
            $oMessage = TCMSMessageManager::GetInstance();
            $aErrorCodes = $oBasketArticle->GetSQLWithTablePrefix();
            $oMessage->AddMessage($sMessageManager, 'ERROR-ADD-TO-BASKET-ARTICLE-NOT-BUYABLE', $aErrorCodes);
            if ($this->IsInList($oBasketArticle)) {
                $this->RemoveArticle($oBasketArticle);
            }
            $bValid = false;
        }

        return $bValid;
    }
156957
public function isAvailableForCategory($obCategoryItem) : bool
    {
        $arCategoryIDList = (array) $this->category_id_list;
        if (empty($arCategoryIDList) || empty($obCategoryItem)) {
            return false;
        }

        if (in_array($obCategoryItem->id, $arCategoryIDList)) {
            return true;
        }

        if ($obCategoryItem->parent->isNotEmpty()) {
            return $this->isAvailableForCategory($obCategoryItem->parent);
        }

        return false;
    }
579816
public function RemoveItem($sBasketItemKey)
    {
        $oRemoveItem = $this->FindItemByBasketItemKey($sBasketItemKey);
        if ($oRemoveItem) {
            $iOldAmount = $oRemoveItem->dAmount;
            $oRemoveItem->ChangeAmount(0);
            $this->UpdateItemAmount($oRemoveItem);
            $oRemoveItem->ChangeAmount($iOldAmount);
        } else {
            $oRemoveItem = false;
        }

        return $oRemoveItem;
    }
354943
protected function _addArticlesToBasket($oBasket, $aArticles)
    {
        // if no order articles
        if (count($aArticles) > 0) {
            //adding order articles to basket
            foreach ($aArticles as $oArticle) {
                $aSel = isset($oArticle->oxorderarticles__oxselvariant) ? $oArticle->oxorderarticles__oxselvariant->value : null;
                $aPersParam = isset($oArticle->oxorderarticles__oxpersparam) ? $oArticle->getPersParams() : null;
                $oBasket->addToBasket(
                    $oArticle->oxorderarticles__oxartid->value,
                    $oArticle->oxorderarticles__oxamount->value,
                    $aSel,
                    $aPersParam
                );
            }
        }
    }
165849
protected function CallPayPalExpressCheckout($sMessageConsumer)
    {
        $oGlobal = TGlobal::instance();

        $sReturnURLBase = $this->getActivePageService()->getActivePage()->GetRealURLPlain(array(), true);
        if ('.html' == substr($sReturnURLBase, -5)) {
            $sReturnURLBase = substr($sReturnURLBase, 0, -5);
        }
        if ('/' != substr($sReturnURLBase, -1)) {
            $sReturnURLBase .= '/';
        }
        $sSuccessURL = $sReturnURLBase.self::URL_IDENTIFIER.'success/spot_'.$oGlobal->GetExecutingModulePointer()->sModuleSpotName;
        $sCancelURL = $sReturnURLBase.self::URL_IDENTIFIER.'cancel/spot_'.$oGlobal->GetExecutingModulePointer()->sModuleSpotName;

        $oBasket = TShopBasket::GetInstance();

        $aParameter = array();
        $aParameter['PAYMENTREQUEST_0_AMT'] = number_format($oBasket->dCostTotal, 2); // the total value to charge (use US-Format (1000.00)
        $aParameter['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->GetCurrencyIdentifier();
        $aParameter['RETURNURL'] = $sSuccessURL; // go to the checkout complete page
        $aParameter['CANCELURL'] = $sCancelURL; //urldecode(str_replace('&amp;','&',$oActivePage->GetRealURL(array('paypalreturn'=>'1'),$aExcludes,true))); // return to the cancel page

        // styling
        $aParameter['HDRIMG'] = ''; // - : specify an image to appear at the top left of the payment page
        $aParameter['HDRBORDERCOLOR'] = ''; // - : set the border color around the header of the payment page
        $aParameter['HDRBACKCOLOR'] = ''; // - : set the background color for the background of the header of the payment page
        $aParameter['PAYFLOWCOLOR'] = ''; // - : set the background color for the payment page

        //$aParameter['notify_url'] = $this->GetInstantPaymentNotificationListenerURL(); // instant payment notification url

        $logger = $this->getPaypalLogger();

        $logger->info('Parameters sent to the PayPal API', $aParameter);
        $aResponse = $this->ExecutePayPalCall('SetExpressCheckout', $aParameter);

        $sSuccess = false;
        // store relevant data in session - and redirect to paypal
        if (array_key_exists('ACK', $aResponse)) {
            $sAckResponse = strtoupper($aResponse['ACK']);
            if ('SUCCESS' == $sAckResponse) {
                $this->sPayPalToken = urldecode($aResponse['TOKEN']);
                $payPalURL = $this->GetConfigParameter('url').'?cmd=_express-checkout&token='.$this->sPayPalToken;
                $this->getRedirect()->redirect($payPalURL);
                $sSuccess = true;
            }
        }
        if (!$sSuccess) {
            $sResponse = self::GetPayPalErrorMessage($aResponse);
            $logger->critical('PayPal payment could not be initiated.', array($sResponse));

            $oMsgManager = TCMSMessageManager::GetInstance();
            $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-PAYMENT-ERROR', array('errorMsg' => 'Error Number: '.$aResponse['L_ERRORCODE0']));
        }

        return $sSuccess;
    }
1295267
public function reserveBasket(\OxidEsales\Eshop\Application\Model\Basket $oBasket)
    {
        if (!$this->isAdmin()) {
            $this->_reserveArticles($this->_basketDifference($oBasket));
        }
    }
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);
            }
        }
    }
1291877
protected function GetNextAvailableVoucher($sVoucherCode, $sSeriesId, $sMessageConsumer)
    {
        $oNextAvailableVoucher = null;
        $oVoucher = TdbShopVoucher::GetNewInstance();
        if ($oVoucher->LoadFromFields(array('code' => $sVoucherCode, 'is_used_up' => '0', 'shop_voucher_series_id' => $sSeriesId))) {
            $oNextAvailableVoucher = $oVoucher;
        }

        return $oNextAvailableVoucher;
    }
811663
public function ExecutePayment(TdbShopOrder &$oOrder, $sMessageConsumer = '')
    {
        $bPaymentOk = parent::ExecutePayment($oOrder, $sMessageConsumer);
        if ($bPaymentOk) {
            $aEasyCashPayload = $this->GetPaymentPayload($oOrder);

            $aResponse = $this->SendRequestToEasyCash(self::EASY_CASH_DEBIT_PATH, $aEasyCashPayload);
            $bPaymentOk = $this->ProcessOrderResponse($oOrder, $aResponse, $aEasyCashPayload, $sMessageConsumer);
        }

        return $bPaymentOk;
    }
176332
protected function _basketDifference(\OxidEsales\Eshop\Application\Model\Basket $oBasket)
    {
        $aDiff = $this->_getReservedItems();
        // refreshing history
        foreach ($oBasket->getContents() as $oItem) {
            $sProdId = $oItem->getProductId();
            if (!isset($aDiff[$sProdId])) {
                $aDiff[$sProdId] = -$oItem->getAmount();
            } else {
                $aDiff[$sProdId] -= $oItem->getAmount();
            }
        }

        return $aDiff;
    }
1101498
public function ShopOrderSendConfirmOrderMail($sMail = null)
    {
        $oGlobal = TGlobal::instance();
        if (is_null($sMail)) {
            $sMail = $oGlobal->GetUserData('sTargetMail');
        }
        $oReturnData = $this->GetObjectShortInfo();
        $oReturnData->sTargetMail = $sMail;

        $bSuccess = false;
        $oOrder = TdbShopOrder::GetNewInstance();
        /** @var $oOrder TdbShopOrder */
        $oOrder->AllowEditByAll(true);
        if (!$oOrder->Load($this->sId)) {
            $oOrder = null;
        } else {
            $bSuccess = $oOrder->SendOrderNotification($sMail);
        }

        if (true === $bSuccess) {
            $oReturnData->bSuccess = true;
            $oReturnData->sMessage = TGlobal::Translate('chameleon_system_shop.orders.msg_order_confirm_sent', array('%mail%' => $sMail));
        } else {
            $oReturnData->bSuccess = false;
            $oReturnData->sMessage = TGlobal::Translate('chameleon_system_shop.orders.error_sending_confirm_mail', array('%error%' => $bSuccess));
        }

        return $oReturnData;
    }
31961
public function OnBasketItemUpdateEvent($oBasketItemChanged)
    {
        $event = new \ChameleonSystem\ShopBundle\objects\TShopBasket\BasketItemEvent(
            TdbDataExtranetUser::GetInstance(),
            $this,
            $oBasketItemChanged
        );
        $this->getEventDispatcher()->dispatch(\ChameleonSystem\ShopBundle\ShopEvents::BASKET_UPDATE_ITEM, $event);
    }
1299790
protected function CheckBasketContents()
    {
        if ('basket' !== $this->fieldSystemname) {
            $oBasket = $this->getShopService()->getActiveBasket();
            if ($oBasket->dTotalNumberOfArticles <= 0) {
                $oBasketStep = TdbShopOrderStep::GetStep('basket');
                $this->JumpToStep($oBasketStep);
            }
        }
    }
387687
protected function CheckAuthorisationResponse($sMessageConsumer = '')
    {
        $bResponseSuccessful = false;
        if (empty($sMessageConsumer)) {
            $sMessageConsumer = $this->GetMsgManagerName();
        }
        $sReturnMessage = $this->GetErrorCodesFromResponse();
        if (!empty($sReturnMessage)) {
            $oMsgManager = TCMSMessageManager::GetInstance();
            $oMsgManager->AddMessage($sMessageConsumer, $sReturnMessage);
        } else {
            $bResponseSuccessful = true;
        }

        return $bResponseSuccessful;
    }
273141
protected function getArticle(TdbShopOrderItem $oOrderItem, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aArticle = array();
        $oArticle = &$oOrderItem->GetFieldShopArticle();

        $aArticle['iAmount'] = $oOrderItem->fieldOrderAmountFormated;
        $aArticle['sManufacturer'] = $oOrderItem->fieldShopManufacturerName;
        $aArticle['sArticleName'] = $oOrderItem->fieldName;
        $aArticle['sArticleVariantName'] = $oOrderItem->fieldNameVariantInfo;
        $aArticle['sShippingInformation'] = '';
        $aArticle['sPrice'] = $oOrderItem->fieldOrderPriceFormated;
        $aArticle['sPriceTotal'] = $oOrderItem->fieldOrderPriceTotalFormated;
        $aArticle['sVat'] = $oOrderItem->fieldVatPercentFormated;
        $aArticle['sVatFormatted'] = number_format($oOrderItem->fieldVatPercent, 0, '.', '').'%';
        if ($oArticle) {
            $aArticle['sImageId'] = $this->getArticleImageId($oArticle, $oCacheTriggerManager, $bCachingEnabled);
            $aArticle = $this->GetVariantInfo($oArticle, $aArticle, $oCacheTriggerManager, $bCachingEnabled);
            $aArticle['sArticleDetailURL'] = $oArticle->GetDetailLink($this->bAbsoluteArticleUrls);
            if ($bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oArticle->table, $oArticle->id);
            }
        }
        if ($oOrderItem instanceof IPkgShopOrderItemWithCustomData) {
            $aArticle['customData'] = $oOrderItem->getCustomDataForTwigOutput();
            $aArticle['customDataTwigTemplate'] = $oOrderItem->getCustomDataTwigTemplate();
        }

        return $aArticle;
    }
625455
protected function UnlockReview()
    {
        $oGlobal = TGlobal::instance();
        $oMsgManager = TCMSMessageManager::GetInstance();
        if ($oGlobal->UserDataExists(TdbShopArticleReview::URL_PARAM_ACTION_ID)) {
            $oReviewItem = TdbShopArticleReview::GetNewInstance();
            if ($oReviewItem->LoadFromField('action_id', $oGlobal->GetUserData(TdbShopArticleReview::URL_PARAM_ACTION_ID))) {
                if (0 == $oReviewItem->sqlData['publish']) {
                    $oReviewItem->AllowEditByAll(true);
                    $oReviewItem->sqlData['publish'] = true;
                    $oReviewItem->sqlData['action_id'] = '';
                    $oReviewItem->Save();
                    $oArticle = TdbShop::GetActiveItem();
                    if ($oArticle->IsVariant()) {
                        $oArticle = $oArticle->GetFieldVariantParent();
                    }
                    $oArticle->UpdateStatsReviews();
                    $oMsgManager->AddMessage(self::MSG_CONSUMER_NAME, 'ARTICLE-REVIEW-UNLOCK-SUCCESS');
                } else {
                    $oMsgManager->AddMessage(self::MSG_CONSUMER_NAME, 'ARTICLE-REVIEW-ACTION-REVIEW-NOT-BLOCKED');
                }
            } else {
                $oMsgManager->AddMessage(self::MSG_CONSUMER_NAME, 'ARTICLE-REVIEW-ACTION-REVIEW-NOT-FOUND');
            }
        } else {
            $oMsgManager->AddMessage(self::MSG_CONSUMER_NAME, 'ARTICLE-REVIEW-ACTION-MISSING-PARAMETER');
        }
        $this->RedirectToItemPage();
    }
697693
public function GetValueForBasketValue($dBasketValueApplicableForDiscount)
    {
        $dValue = $this->fieldValue;
        $oBasket = TShopBasket::GetInstance();
        if ('prozent' == $this->fieldValueType) {
            $dValue = round($dBasketValueApplicableForDiscount * ($dValue / 100), 2);
        }
        // now if the discount is worth more than the current basket, we need to use only the part that we can
        if ($dBasketValueApplicableForDiscount < $dValue) {
            $dValue = $dBasketValueApplicableForDiscount;
        }

        return $dValue;
    }