Merge pull request #980 from openclassify/dia

#3481 [advs-module] Currency error when viewing an ad
This commit is contained in:
spektra2147 2021-03-04 15:19:17 +03:00 committed by GitHub
commit 21128aa5ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 8 deletions

View File

@ -14,8 +14,9 @@ return [
'google_statistic_code',
'ogImage',
'free_currencyconverterapi_key',
'hide_price_categories',
'tcmb_exchange_url',
'enabled_currencies',
'tcmb_exchange_url'
],
],
'ads' => [

View File

@ -94,6 +94,14 @@ return [
"default_value" => "1eea72940f3868c77420"
]
],
'hide_price_categories' => [
'type' => 'anomaly.field_type.checkboxes',
'config' => [
'options' => function (\Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface $categoryRepository) {
return $categoryRepository->mainCats()->pluck('name', 'id')->all();
},
],
],
'default_GET' => [
'type' => 'anomaly.field_type.boolean',
'bind' => 'adv.default_GET',

View File

@ -61,6 +61,10 @@ return [
'default_country' => [
'name' => 'Default Ad Country',
],
'hide_price_categories' => [
'name' => 'Hide Price On Categories',
'instructions' => 'The price will be hidden when you create an ad or view an ad under these categories.'
],
'free_currencyconverterapi_key' => [
'name' => 'Currency Converter API Key'
],

View File

@ -90,8 +90,7 @@
</div>
</div>
<div class="row form-group select-price
{{ setting_value('visiosoft.module.advs::price_area_hidden') ? 'hidden' }}">
<div class="row form-group select-price{{ hidePrice ? ' hidden' }}">
<label class="col-sm-2 col-xs-12">
{{ form.fields.price.label|raw }}

View File

@ -589,17 +589,21 @@ class AdvsController extends PublicController
$configurations = $this->optionConfigurationRepository->getConf($adv->id);
$foreign_currencies = json_decode($adv->foreign_currencies, true);
if ($_COOKIE['currency'] && $adv->foreign_currencies && array_key_exists($_COOKIE['currency'], $foreign_currencies)) {
if (isset($_COOKIE['currency']) && $_COOKIE['currency'] && $adv->foreign_currencies && array_key_exists($_COOKIE['currency'], $foreign_currencies)) {
$adv->currency = $_COOKIE['currency'];
$adv->price = $foreign_currencies[$_COOKIE['currency']];
}
// Check if hide price
$hidePrice = false;
if ($hidePriceCats = setting_value('visiosoft.module.advs::hide_price_categories')) {
$hidePrice = in_array($adv['cat1'], $hidePriceCats);
}
if ($adv->created_by_id == isset(auth()->user()->id) or $adv->status == "approved") {
return $this->view->make('visiosoft.module.advs::ad-detail/detail', compact('adv', 'complaints',
'recommended_advs', 'categories', 'features', 'options', 'configurations'));
'recommended_advs', 'categories', 'features', 'options', 'configurations', 'hidePrice'));
} else {
return back();
}
@ -956,9 +960,17 @@ class AdvsController extends PublicController
->edit($adv, $categories, $cats);
}
// Check if hide price
$hidePrice = false;
if (setting_value('visiosoft.module.advs::price_area_hidden')) {
$hidePrice = true;
} elseif ($hidePriceCats = setting_value('visiosoft.module.advs::hide_price_categories')) {
$hidePrice = in_array($adv['cat1'], $hidePriceCats);
}
return $this->view->make(
'visiosoft.module.advs::new-ad/new-create',
compact('id', 'cats_d', 'cats', 'Cloudinary', 'adv', 'custom_fields', 'options')
compact('id', 'cats_d', 'cats', 'Cloudinary', 'adv', 'custom_fields', 'options', 'hidePrice')
);
}