Merge pull request #1139 from openclassify/vedat

Added Addblock
This commit is contained in:
Muammer Top 2021-08-16 12:33:02 +03:00 committed by GitHub
commit 30d5237105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 6 deletions

View File

@ -25,12 +25,8 @@
{% else %}
{% set continueLink = url_route('adv_detail_seo', [adv.slug, adv.id]) %}
{% endif %}
{% if isActive('shipping') %}
<a href="{{ url_route('visiosoft.module.shipping::create_shipping',{'id':adv.id}) }}"
class="btn btn-outline-primary shadow-sm mr-4">
<i class="fa fa-truck"></i>
{{ trans('visiosoft.module.shipping::button.create_shipping_information') }}
</a>
{% if isActive('shipping') and adv.is_get_adv.getValue() %}
{{ addBlock('new-create/preview/actions',{'adv_id':adv.id})|raw }}
{% endif %}
<a href="{{ url_route('visiosoft.module.advs::edit_adv', [adv.id]) }}"
class="btn preview-edit shadow-sm border">

View File

@ -0,0 +1,50 @@
<?php namespace Visiosoft\AdvsModule\Adv\Command;
use Anomaly\Streams\Platform\Message\MessageBag;
class ConvertCurrency
{
protected $price;
protected $currency;
protected $source;
protected $to;
public function __construct($price, $source, $to)
{
$this->price = $price;
$this->currency = $source;
$this->source = $source;
$this->to = $to;
}
public function handle(MessageBag $message)
{
try {
$url = $this->source . "_" . $this->to;
$freeCurrencyKey = setting_value('visiosoft.module.advs::free_currencyconverterapi_key');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://free.currencyconverterapi.com/api/v6/convert', ['query' => [
'q' => $url,
'compact' => 'y',
'apiKey' => $freeCurrencyKey
]]);
if ($response->getStatusCode() == '200') {
$response = (array)\GuzzleHttp\json_decode($response->getBody()->getContents());
if (!empty($response)) {
$rate = $response[$url]->val;
$this->price *= $rate;
$this->currency = $this->to;
}
}
} catch (\GuzzleHttp\Exception\ClientException $e) {
$message->error(['Para birimi dönüştürme işlemi tamamlanamadı!' . $e->getMessage()]);
}
return [
'currency' => $this->currency,
'price' => $this->price,
];
}
}