Helper method to check if the product is
a valid shop product.

@param string $defaultCurrency

@return bool
548252
public function isValidShopProduct($defaultCurrency)
    {
        $isValid = false;

        if (method_exists($this, 'getPrices') &&
            $this->getStatus()->getId() == Status::ACTIVE &&
            $this->getPrices() &&
            count($this->getPrices()) > 0 &&
            $this->hasPriceInDefaultCurrency($this->getPrices(), $defaultCurrency) &&
            $this->getSupplier()
        ) {
            $isValid = true;
        }

        return $isValid;
    }
667715
protected function validateProduct()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->product->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('Product'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }
421345
@Indexable(type = IndexableType.REINDEX)
	@Override
	public CommerceCurrency updateCommerceCurrency(
		CommerceCurrency commerceCurrency) {
		return commerceCurrencyPersistence.update(commerceCurrency);
	}
101321
protected function validateRelatedProduct()
    {
        $field = 'related';

        if ($this->isExcluded($field) || $this->isError('store_id')) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (empty($value)) {
            $this->setSubmitted($field, array());
            return null;
        }

        $store_id = $this->getSubmitted('store_id');

        $product_ids = array();

        foreach (array_unique($value) as $product_id) {

            $product = $this->product->get($product_id);

            if (empty($product['store_id'])) {
                $this->setError($field, $this->translation->text('Some of related products are invalid'));
                return false;
            }

            if ($product['store_id'] != $store_id) {
                $this->setError($field, $this->translation->text('All related product must belong to the same store'));
                return false;
            }

            $product_ids[$product['product_id']] = $product['product_id'];
        }

        $updating = $this->getUpdating();

        if (isset($updating['product_id'])) {
            // Exclude the current product from the related products
            unset($product_ids[$updating['product_id']]);
        }

        $this->setSubmitted('related', $product_ids);
        return true;
    }
377612
public function getBasePriceForCurrency(ProductInterface $product, $currency = null)
    {
        $currency = $currency ?: $this->defaultCurrency;
        if ($prices = $product->getPrices()) {
            foreach ($prices as $price) {
                if ($price->getCurrency()->getCode() == $currency && $price->getMinimumQuantity() == 0) {
                    return $price;
                }
            }
        }

        return null;
    }
233261
protected function checkUserCountry()
    {
        $isValid = true;

        $payPalPayment = $this->getPayment();

        $countries = $payPalPayment->getCountries();
        if ($countries) {
            $isValid = false;
            foreach ($countries as $countryId) {
                if ($countryId === $this->getShippingCountryId()) {
                    $isValid = true;
                    break;
                }
            }
        }

        return $isValid;
    }
806078
public function isPaymentValid()
    {
        $isValid = $this->isPaymentActive();

        if ($isValid && !is_null($this->getPrice())) {
            $isValid = $this->checkPriceRange() && $this->checkMinOrderPrice();
        }

        $user = $this->getUser();
        if ($isValid && $user && $user->hasAccount()) {
            $isValid = $this->checkUserGroup();
        }

        if ($isValid && $user && $this->getCheckCountry()) {
            $isValid = $this->checkUserCountry();
        }

        return $isValid;
    }
1174947
protected function verifyPayment()
	{

		$fields = array(
			'MerchantID' => $this->config->get('gateway.zarinpal.merchant-id'),
			'Authority' => $this->refId,
			'Amount' => $this->amount,
		);

		try {
			$soap = new SoapClient($this->serverUrl, ['encoding' => 'UTF-8']);
			$response = $soap->PaymentVerification($fields);

		} catch (\SoapFault $e) {
			$this->transactionFailed();
			$this->newLog('SoapFault', $e->getMessage());
			throw $e;
		}

		if ($response->Status != 100 && $response->Status != 101) {
			$this->transactionFailed();
			$this->newLog($response->Status, ZarinpalException::$errors[$response->Status]);
			throw new ZarinpalException($response->Status);
		}

		$this->trackingCode = $response->RefID;
		$this->transactionSucceed();
		$this->newLog($response->Status, Enum::TRANSACTION_SUCCEED_TEXT);
		return true;
	}
619596
public function isValid($value)
    {
        if (!is_string($value)) {
            $this->error(self::INVALID);
            return false;
        }

        $this->setValue($value);
        if (!preg_match(self::PATTERN, $value)) {
            $this->error(self::NOT_MATCH);
            return false;
        }

        if (!$this->getCurrencyList()->isAllowed($value)) {
            $this->error(self::NOT_FOUND);
        }

        return count($this->getMessages()) === 0;
    }
869773
public function isPaymentOnlyCheckoutEnabled($store = null)
    {
        return $this->getScopeConfig()->isSetFlag(
            self::XML_PATH_PAYMENT_ONLY_CHECKOUT,
            ScopeInterface::SCOPE_STORE,
            $store
        );
    }
1259583
protected function validateConvertionRateCurrency()
    {
        $field = 'conversion_rate';
        $value = $this->getSubmitted($field);

        if (!isset($value)) {
            return null;
        }

        $label = $this->translation->text('Conversion rate');

        if (empty($value) || strlen($value) > 10) {
            $this->setErrorLengthRange($field, $label, 1, 10);
            return false;
        }

        if (preg_match('/^[0-9]\d*(\.\d+)?$/', $value) !== 1) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        return true;
    }
776616
public function IsValidForCurrentUser()
    {
        $bIsValidForUser = false;
        $bIsValidShippingCountry = false;
        $bIsValidBillingCountry = false;

        $oUser = TdbDataExtranetUser::GetInstance();
        $bIsValidGroup = $this->checkUserGroup($oUser);
        if ($bIsValidGroup) {
            $bIsValidForUser = $this->checkUser($oUser);
        }
        if ($bIsValidForUser && $bIsValidGroup) {
            $bIsValidShippingCountry = $this->checkUserShippingCountry($oUser);
        }
        if ($bIsValidForUser && $bIsValidGroup && $bIsValidShippingCountry) {
            $bIsValidBillingCountry = $this->checkUserBillingCountry($oUser);
        }

        return $bIsValidForUser && $bIsValidGroup && $bIsValidShippingCountry && $bIsValidBillingCountry;
    }
551665
public static function isPayPalActiveOnSubShops()
    {
        $active = false;
        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        $extensionChecker = oxNew(\OxidEsales\PayPalModule\Core\ExtensionChecker::class);
        $shops = $config->getShopIds();
        $activeShopId = $config->getShopId();

        foreach ($shops as $shopId) {
            if ($shopId != $activeShopId) {
                $extensionChecker->setShopId($shopId);
                $extensionChecker->setExtensionId('oepaypal');
                if ($extensionChecker->isActive()) {
                    $active = true;
                    break;
                }
            }
        }

        return $active;
    }
92633
public function items($displayCurrency = false)
    {
        $items = $this->items->map->toArray();

        if (! $displayCurrency) {
            return $items->toArray();
        }

        setlocale(LC_MONETARY, config('cart_manager.LC_MONETARY'));

        return $items->map(function ($item) {
            $item['price'] = money_format('%n', $item['price']);

            return $item;
        })->toArray();
    }
149588
function baseCurrency()
    {
        // use value of the first custom price as
        // base price and base currency.

        $baseCurrency = false;
        $customPriceList = $this->customPriceList();
        $currencies = array_keys( $customPriceList );
        if ( count( $currencies ) > 0 )
        {
            $baseCurrency = $currencies[0];
        }

        return $baseCurrency;
    }
556740
protected function isValidCurrency(string $value): void
    {
        $allowedCurrency = $this->getAllowedCurrency();

        $regex = '/^' . implode('|', $allowedCurrency) . '$/';
        if (!preg_match($regex, $value)) {
            throw new InvalidCurrencyException(sprintf(
                '%s is not a valid currency. Currency must be in ISO-4217-3 format.',
                $value
            ));
        }
    }
841309
private function isValidPayment($basket)
    {
        $paymentId = $basket->getPaymentId();
        $paymentModel = oxNew(EshopPayment::class);
        $paymentModel->load($paymentId);

        $dynamicValues = $this->getDynamicValues();
        $shopId = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId();

        return $paymentModel->isValidPayment(
            $dynamicValues,
            $shopId,
            $this->getUser(),
            $basket->getPriceForPayment(),
            $basket->getShippingId()
        );
    }