diff --git a/.env.example b/.env.example
index 55c0422ae..49f65a19b 100644
--- a/.env.example
+++ b/.env.example
@@ -1,6 +1,6 @@
APP_NAME=Bagisto
APP_ENV=local
-APP_VERSION=1.1.0
+APP_VERSION=1.1.2
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
diff --git a/.env.testing b/.env.testing
index da181c35c..f872c6bfe 100644
--- a/.env.testing
+++ b/.env.testing
@@ -1,6 +1,6 @@
APP_NAME=Laravel
APP_ENV=local
-APP_VERSION=1.1.0
+APP_VERSION=1.1.2
APP_KEY=base64:G4KY3tUsTaY9ONo1n/QyJvVLQZdJDgbIkSJswFK01HE=
APP_DEBUG=true
APP_URL=http://localhost
diff --git a/CHANGELOG for v1.x.x.md b/CHANGELOG for v1.x.x.md
index ef6004129..ec55be765 100644
--- a/CHANGELOG for v1.x.x.md
+++ b/CHANGELOG for v1.x.x.md
@@ -2,6 +2,75 @@
#### This changelog consists the bug & security fixes and new features being included in the releases listed below.
+## **v1.1.2 (24th of March 2020)** - *Release*
+
+* [feature] - Now customer can cancel order.
+
+* [feature] - Auto and manual currency exchange rates update feature added.
+
+
+
+* #797 [fixed] - Add new module
+
+* #2453 [fixed] - Velocity theme is not loading on fresh instance
+
+* #2691 [fixed] - Shipping and Payment methods automatically selected on Checkout oage
+
+* #2752 [fixed] - Error when you create or update a new catalog under root
+
+* #2793 [fixed] - Stock Check Incorrect for Configurable Items
+
+* #2826 [fixed] - Not able to view cart icon
+
+* #2869 [fixed] - Updating "Velocity meta data" throws QueryException
+
+* #2871 [fixed] - Refund throws "Undefined index: shipping" error
+
+* #2875 [fixed] - Deleting brands that have been assigned to products causes checkout error
+
+* #2884 [fixed] - Undefined Index slot: when add to cart rental booking
+
+* #2890 [fixed] - cart rule condition (price in cart) always set to equal or less than when select greater than/less than
+
+* #2895 [fixed] - The type hint of view in this blade file is 'address' - there is no tag in any provider which loads view with this type hint.
+
+* #2896 [fixed] - There are two fields with having same value of name attribute one is hidden and other is of its desired type - is this redundant code or its solving any purpose?
+
+* #2897 [fixed] - Inventory status field should be passed through validation for boolean in its backend controller.
+
+* #2898 [fixed] - error when viewing a category and then wanting to change the language of the page in mobile view
+
+* #2899 [fixed] - showing the configured products as radio button
+
+* #2900 [fixed] - getting different variant of a configurable product in front end
+
+* #2901 [fixed] - Error when creating a category
+
+* #2902 [fixed] - unify address tables
+
+* #2908 [fixed] - A class is missing from the Velocity ProductRepositiry file
+
+* #2914 [fixed] - Filter not showing on mobile, also sorting not working on mobile
+
+* #2915 [fixed] - filters are missing on mobile view.
+
+* #2919 [fixed] - Header Content not working on other languages
+
+* #2925 [fixed] - exception for php version 7.4
+
+* #2938 [fixed] - Extend Model Class
+
+* #2939 [fixed] - get product description for API without html tags
+
+* #2940 [fixed] - creating categories have error
+
+* #2943 [fixed] - Scroll images is not working
+
+* #2945 [fixed] - API product detail return empty array
+
+* #2954 [fixed] - The merging cart function does not work when already added all items of product into customer cart
+
+
## **v1.1.0 (24th of March 2020)** - *Release*
* #797 [fixed] - Add new module
diff --git a/composer.lock b/composer.lock
index 6393d3998..0e8076162 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4096,16 +4096,16 @@
},
{
"name": "symfony/http-foundation",
- "version": "v4.4.5",
+ "version": "v4.4.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
- "reference": "7e41b4fcad4619535f45f8bfa7744c4f384e1648"
+ "reference": "62f92509c9abfd1f73e17b8cf1b72c0bdac6611b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/http-foundation/zipball/7e41b4fcad4619535f45f8bfa7744c4f384e1648",
- "reference": "7e41b4fcad4619535f45f8bfa7744c4f384e1648",
+ "url": "https://api.github.com/repos/symfony/http-foundation/zipball/62f92509c9abfd1f73e17b8cf1b72c0bdac6611b",
+ "reference": "62f92509c9abfd1f73e17b8cf1b72c0bdac6611b",
"shasum": ""
},
"require": {
@@ -4147,7 +4147,7 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
- "time": "2020-02-13T19:40:01+00:00"
+ "time": "2020-03-30T14:07:33+00:00"
},
{
"name": "symfony/http-kernel",
@@ -4241,16 +4241,16 @@
},
{
"name": "symfony/mime",
- "version": "v5.0.5",
+ "version": "v5.0.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/mime.git",
- "reference": "9b3e5b5e58c56bbd76628c952d2b78556d305f3c"
+ "reference": "481b7d6da88922fb1e0d86a943987722b08f3955"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/mime/zipball/9b3e5b5e58c56bbd76628c952d2b78556d305f3c",
- "reference": "9b3e5b5e58c56bbd76628c952d2b78556d305f3c",
+ "url": "https://api.github.com/repos/symfony/mime/zipball/481b7d6da88922fb1e0d86a943987722b08f3955",
+ "reference": "481b7d6da88922fb1e0d86a943987722b08f3955",
"shasum": ""
},
"require": {
@@ -4299,7 +4299,7 @@
"mime",
"mime-type"
],
- "time": "2020-02-04T09:41:09+00:00"
+ "time": "2020-03-27T16:56:45+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -4420,16 +4420,16 @@
},
{
"name": "symfony/polyfill-intl-idn",
- "version": "v1.14.0",
+ "version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
- "reference": "6842f1a39cf7d580655688069a03dd7cd83d244a"
+ "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6842f1a39cf7d580655688069a03dd7cd83d244a",
- "reference": "6842f1a39cf7d580655688069a03dd7cd83d244a",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf",
+ "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf",
"shasum": ""
},
"require": {
@@ -4443,7 +4443,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.14-dev"
+ "dev-master": "1.15-dev"
}
},
"autoload": {
@@ -4478,20 +4478,20 @@
"portable",
"shim"
],
- "time": "2020-01-17T12:01:36+00:00"
+ "time": "2020-03-09T19:04:49+00:00"
},
{
"name": "symfony/polyfill-mbstring",
- "version": "v1.14.0",
+ "version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
- "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2"
+ "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2",
- "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac",
+ "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac",
"shasum": ""
},
"require": {
@@ -4503,7 +4503,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.14-dev"
+ "dev-master": "1.15-dev"
}
},
"autoload": {
@@ -4537,7 +4537,7 @@
"portable",
"shim"
],
- "time": "2020-01-13T11:15:53+00:00"
+ "time": "2020-03-09T19:04:49+00:00"
},
{
"name": "symfony/polyfill-php56",
@@ -4597,16 +4597,16 @@
},
{
"name": "symfony/polyfill-php72",
- "version": "v1.14.0",
+ "version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
- "reference": "46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf"
+ "reference": "37b0976c78b94856543260ce09b460a7bc852747"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf",
- "reference": "46ecacf4751dd0dc81e4f6bf01dbf9da1dc1dadf",
+ "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747",
+ "reference": "37b0976c78b94856543260ce09b460a7bc852747",
"shasum": ""
},
"require": {
@@ -4615,7 +4615,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.14-dev"
+ "dev-master": "1.15-dev"
}
},
"autoload": {
@@ -4648,7 +4648,7 @@
"portable",
"shim"
],
- "time": "2020-01-13T11:15:53+00:00"
+ "time": "2020-02-27T09:26:54+00:00"
},
{
"name": "symfony/polyfill-php73",
@@ -7770,6 +7770,5 @@
"ext-pdo_mysql": "*",
"ext-tokenizer": "*"
},
- "platform-dev": [],
- "plugin-api-version": "1.1.0"
+ "platform-dev": []
}
diff --git a/config/app.php b/config/app.php
index 94f8ad62d..8cd62b101 100755
--- a/config/app.php
+++ b/config/app.php
@@ -153,7 +153,7 @@ return [
/*
Application Version
*/
- 'version' => env('APP_VERSION', '1.1.0'),
+ 'version' => env('APP_VERSION'),
/**
* Blacklisting attributes while debugging
diff --git a/config/services.php b/config/services.php
index 22a2286f8..f198a9ca1 100755
--- a/config/services.php
+++ b/config/services.php
@@ -30,12 +30,16 @@ return [
],
'exchange-api' => [
- 'default' => 'fixer',
+ 'default' => 'exchange_rates',
+
'fixer' => [
- 'paid_account' => false,
'key' => env('fixer_api_key'),
'class' => 'Webkul\Core\Helpers\Exchange\FixerExchange'
- ]
+ ],
+
+ 'exchange_rates' => [
+ 'class' => 'Webkul\Core\Helpers\Exchange\ExchangeRates'
+ ],
],
'stripe' => [
diff --git a/packages/Webkul/API/Http/Controllers/Shop/ProductController.php b/packages/Webkul/API/Http/Controllers/Shop/ProductController.php
index fe9392332..051982e51 100755
--- a/packages/Webkul/API/Http/Controllers/Shop/ProductController.php
+++ b/packages/Webkul/API/Http/Controllers/Shop/ProductController.php
@@ -45,10 +45,9 @@ class ProductController extends Controller
*/
public function get($id)
{
- $product = $this->productRepository->findOrFail($id);
- $options = $this->productRepository->findOrFail($id)->getTypeInstance()->getProductOptions($product);
-
- return $options;
+ return new ProductResource(
+ $this->productRepository->findOrFail($id)
+ );
}
/**
diff --git a/packages/Webkul/Admin/src/Config/system.php b/packages/Webkul/Admin/src/Config/system.php
index e5c2dc139..71f555aa5 100644
--- a/packages/Webkul/Admin/src/Config/system.php
+++ b/packages/Webkul/Admin/src/Config/system.php
@@ -99,6 +99,12 @@ return [
'type' => 'image',
'channel_based' => true,
'validation' => 'mimes:jpeg,bmp,png,jpg',
+ ], [
+ 'name' => 'favicon',
+ 'title' => 'admin::app.admin.system.favicon',
+ 'type' => 'image',
+ 'channel_based' => true,
+ 'validation' => 'mimes:jpeg,bmp,png,jpg',
],
],
], [
diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php
index 914486afc..350d86b17 100755
--- a/packages/Webkul/Admin/src/Http/routes.php
+++ b/packages/Webkul/Admin/src/Http/routes.php
@@ -507,7 +507,7 @@ Route::group(['middleware' => ['web']], function () {
'view' => 'admin::settings.exchange_rates.edit'
])->name('admin.exchange_rates.edit');
- Route::get('/exchange_rates/update-rates/{service}', 'Webkul\Core\Http\Controllers\ExchangeRateController@updateRates')->name('admin.exchange_rates.update-rates');
+ Route::get('/exchange_rates/update-rates', 'Webkul\Core\Http\Controllers\ExchangeRateController@updateRates')->name('admin.exchange_rates.update_rates');
Route::put('/exchange_rates/edit/{id}', 'Webkul\Core\Http\Controllers\ExchangeRateController@update')->defaults('_config', [
'redirect' => 'admin.exchange_rates.index'
diff --git a/packages/Webkul/Admin/src/Resources/lang/ar/app.php b/packages/Webkul/Admin/src/Resources/lang/ar/app.php
index 61969ca19..77d065054 100644
--- a/packages/Webkul/Admin/src/Resources/lang/ar/app.php
+++ b/packages/Webkul/Admin/src/Resources/lang/ar/app.php
@@ -729,7 +729,7 @@ return [
'target_currency' => 'العملة المستهدفة',
'rate' => 'معدل',
'exchange-class-not-found' => ':service لم يتم العثور على فئة سعر الصرف آسيف',
- 'update-rates' => ':service تحديث الأسعار باستخدام ',
+ 'update-rates' => 'الأسعار',
'create-success' => 'تم إنشاء سعر الصرف بنجاح',
'update-success' => 'تم تحديث سعر الصرف بنجاح',
'delete-success' => 'تم حذف سعر الصرف بنجاح',
@@ -1304,7 +1304,8 @@ return [
'all-channels' => 'الكل',
'all-locales' => 'الكل',
'invoice-slip-design' => 'Invoice Slip Design',
- 'logo' => 'logo'
+ 'logo' => 'logo',
+ 'favicon' => 'Favicon'
]
]
];
diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php
index e04395bab..5fcd7723f 100755
--- a/packages/Webkul/Admin/src/Resources/lang/en/app.php
+++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php
@@ -729,7 +729,7 @@ return [
'target_currency' => 'Target Currency',
'rate' => 'Rate',
'exchange-class-not-found' => ':service exchange rate class not found',
- 'update-rates' => 'Update rates using :service',
+ 'update-rates' => 'Update Rates',
'create-success' => 'Exchange Rate created successfully.',
'update-success' => 'Exchange Rate updated successfully.',
'delete-success' => 'Exchange Rate deleted successfully.',
@@ -1309,7 +1309,8 @@ return [
'all-channels' => 'All',
'all-locales' => 'All',
'invoice-slip-design' => 'Invoice Slip Design',
- 'logo' => 'logo'
+ 'logo' => 'logo',
+ 'favicon' => 'Favicon'
]
]
];
diff --git a/packages/Webkul/Admin/src/Resources/lang/fa/app.php b/packages/Webkul/Admin/src/Resources/lang/fa/app.php
index ea4c62a9b..0a3da78e0 100644
--- a/packages/Webkul/Admin/src/Resources/lang/fa/app.php
+++ b/packages/Webkul/Admin/src/Resources/lang/fa/app.php
@@ -729,7 +729,7 @@ return [
'target_currency' => 'هدف ارز',
'rate' => 'نرخ',
'exchange-class-not-found' => 'کلاس نرخ ارز :service یافت نشد',
- 'update-rates' => ' به روز کنید :service نرخ ها را با استفاده از',
+ 'update-rates' => 'نرخ ها را به روز کنید',
'create-success' => 'نرخ ارز با موفقیت ایجاد شد.',
'update-success' => 'نرخ ارز با موفقیت به روز شد.',
'delete-success' => 'نرخ ارز با موفقیت حذف شد.',
@@ -1310,7 +1310,8 @@ return [
'all-locales' => 'همه',
'sandbox' => 'Sandbox',
'invoice-slip-design' => 'Invoice Slip Design',
- 'logo' => 'logo'
+ 'logo' => 'logo',
+ 'favicon' => 'Favicon'
]
]
];
diff --git a/packages/Webkul/Admin/src/Resources/lang/nl/app.php b/packages/Webkul/Admin/src/Resources/lang/nl/app.php
index 18a75ccd5..b402d567a 100644
--- a/packages/Webkul/Admin/src/Resources/lang/nl/app.php
+++ b/packages/Webkul/Admin/src/Resources/lang/nl/app.php
@@ -729,7 +729,7 @@ return [
'target_currency' => 'Valuta doel',
'rate' => 'Tarief',
'exchange-class-not-found' => ':service wisselkoersklasse niet gevonden',
- 'update-rates' => 'Tarieven bijwerken met :service',
+ 'update-rates' => 'Tarieven bijwerken',
'create-success' => 'Wisselkoers succesvol aangemaakt.',
'update-success' => 'Wisselkoers succesvol bijgewerkt.',
'delete-success' => 'Wisselkoers succesvol verwijderd.',
@@ -1309,7 +1309,8 @@ return [
'all-channels' => 'Alles',
'all-locales' => 'Alles',
'invoice-slip-design' => 'Invoice Slip Design',
- 'logo' => 'logo'
+ 'logo' => 'logo',
+ 'favicon' => 'Favicon'
]
]
];
diff --git a/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php b/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php
index c6ea97783..bb0b0e9fe 100755
--- a/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php
+++ b/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php
@@ -729,6 +729,7 @@ return [
'target_currency' => 'Moeda Alvo',
'rate' => 'Taxa',
'exchange-class-not-found' => ':service de taxa de câmbio de serviço não encontrada',
+ 'update-rates' => 'Atualizar Tarifas',
'rate' => 'Taxa',
'create-success' => 'Taxa de Câmbio criada com sucesso.',
'update-success' => 'Taxa de Câmbio atualizada com sucesso.',
@@ -1312,7 +1313,8 @@ return [
'all-locales' => 'Todos',
'sandbox' => 'Sandbox',
'invoice-slip-design' => 'Design da Nota do Pedido',
- 'logo' => 'logo'
+ 'logo' => 'logo',
+ 'favicon' => 'Favicon'
]
]
];
diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/attributes/index.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/attributes/index.blade.php
index 46cd37681..a40a1d2a6 100755
--- a/packages/Webkul/Admin/src/Resources/views/catalog/attributes/index.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/catalog/attributes/index.blade.php
@@ -13,7 +13,7 @@
@@ -28,4 +28,4 @@
{!! view_render_event('bagisto.admin.catalog.attributes.list.after') !!}
-@stop
\ No newline at end of file
+@stop
diff --git a/packages/Webkul/Admin/src/Resources/views/layouts/master.blade.php b/packages/Webkul/Admin/src/Resources/views/layouts/master.blade.php
index 86512323a..53ce71fd4 100755
--- a/packages/Webkul/Admin/src/Resources/views/layouts/master.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/layouts/master.blade.php
@@ -6,7 +6,12 @@
-
+
+ @if ($favicon = core()->getConfigData('general.design.admin_logo.favicon'))
+
+ @else
+
+ @endif
diff --git a/packages/Webkul/Admin/src/Resources/views/settings/exchange_rates/create.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/exchange_rates/create.blade.php
index ed1a75c1c..047f2e316 100755
--- a/packages/Webkul/Admin/src/Resources/views/settings/exchange_rates/create.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/settings/exchange_rates/create.blade.php
@@ -56,7 +56,7 @@
- @inject('exchange_rates','Webkul\Admin\DataGrids\ExchangeRatesDataGrid')
- {!! $exchange_rates->render() !!}
+
+ {!! app('Webkul\Admin\DataGrids\ExchangeRatesDataGrid')->render() !!}
+
@stop
\ No newline at end of file
diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php
index 4a4ddd407..a2a343a16 100755
--- a/packages/Webkul/Checkout/src/Cart.php
+++ b/packages/Webkul/Checkout/src/Cart.php
@@ -368,8 +368,14 @@ class Cart
continue;
}
+ $found = true;
+
$cartItem->quantity = $newQuantity = $cartItem->quantity + $guestCartItem->quantity;
+ if ($cartItem->quantity > $cartItem->product->getTypeInstance()->totalQuantity()) {
+ $cartItem->quantity = $newQuantity = $cartItem->product->getTypeInstance()->totalQuantity();
+ }
+
if (! $this->isItemHaveQuantity($cartItem)) {
$this->cartItemRepository->delete($guestCartItem->id);
@@ -387,8 +393,6 @@ class Cart
$guestCart->items->forget($key);
$this->cartItemRepository->delete($guestCartItem->id);
-
- $found = true;
}
if (! $found) {
diff --git a/packages/Webkul/Core/src/Console/Commands/ExchangeRateUpdate.php b/packages/Webkul/Core/src/Console/Commands/ExchangeRateUpdate.php
new file mode 100644
index 000000000..cd3a4ca39
--- /dev/null
+++ b/packages/Webkul/Core/src/Console/Commands/ExchangeRateUpdate.php
@@ -0,0 +1,36 @@
+updateRates();
+ } catch(\Exception $e) {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Core/src/Helpers/Exchange/ExchangeRate.php b/packages/Webkul/Core/src/Helpers/Exchange/ExchangeRate.php
index 4d0612399..030d1fc5d 100644
--- a/packages/Webkul/Core/src/Helpers/Exchange/ExchangeRate.php
+++ b/packages/Webkul/Core/src/Helpers/Exchange/ExchangeRate.php
@@ -4,7 +4,5 @@ namespace Webkul\Core\Helpers\Exchange;
abstract class ExchangeRate
{
- abstract public function fetchRates();
-
- abstract public function UpdateRates();
+ abstract public function updateRates();
}
\ No newline at end of file
diff --git a/packages/Webkul/Core/src/Helpers/Exchange/ExchangeRates.php b/packages/Webkul/Core/src/Helpers/Exchange/ExchangeRates.php
new file mode 100644
index 000000000..5c53c3a66
--- /dev/null
+++ b/packages/Webkul/Core/src/Helpers/Exchange/ExchangeRates.php
@@ -0,0 +1,88 @@
+currencyRepository = $currencyRepository;
+
+ $this->exchangeRateRepository = $exchangeRateRepository;
+
+ $this->apiEndPoint = 'https://api.exchangeratesapi.io/latest';
+ }
+
+ /**
+ * Fetch rates and updates in currency_exchange_rates table
+ *
+ * @return \Exception|void
+ */
+ public function updateRates()
+ {
+ $client = new \GuzzleHttp\Client();
+
+ foreach ($this->currencyRepository->all() as $currency) {
+ if ($currency->code == config('app.currency')) {
+ continue;
+ }
+
+ $result = $client->request('GET', $this->apiEndPoint . '?base=' . config('app.currency') . '&symbols=' . $currency->code);
+
+ $result = json_decode($result->getBody()->getContents(), true);
+
+ if (isset($result['success']) && ! $result['success']) {
+ throw new E\xception(
+ isset($result['error']['info'])
+ ? $result['error']['info']
+ : $result['error']['type'], 1);
+ }
+
+ if ($exchangeRate = $currency->exchange_rate) {
+ $this->exchangeRateRepository->update([
+ 'rate' => $result['rates'][$currency->code],
+ ], $exchangeRate->id);
+ } else {
+ $this->exchangeRateRepository->create([
+ 'rate' => $result['rates'][$currency->code],
+ 'target_currency' => $currency->id,
+ ]);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Core/src/Helpers/Exchange/FixerExchange.php b/packages/Webkul/Core/src/Helpers/Exchange/FixerExchange.php
index c68ffabb4..8e69a06b3 100644
--- a/packages/Webkul/Core/src/Helpers/Exchange/FixerExchange.php
+++ b/packages/Webkul/Core/src/Helpers/Exchange/FixerExchange.php
@@ -3,9 +3,10 @@
namespace Webkul\Core\Helpers\Exchange;
use Webkul\Core\Helpers\Exchange\ExchangeRate;
+use Webkul\Core\Repositories\CurrencyRepository;
use Webkul\Core\Repositories\ExchangeRateRepository;
-class FixerExchange extends ExchangeRate
+class FixerExchange extends ExchangeRate
{
/**
* API key
@@ -21,49 +22,76 @@ class FixerExchange extends ExchangeRate
*/
protected $apiEndPoint;
+ /**
+ * Holds CurrencyRepository instance
+ *
+ * @var \Webkul\Core\Repositories\CurrencyRepository
+ */
+ protected $currencyRepository;
+
/**
* Holds ExchangeRateRepository instance
*
- * @var \Webkul\Core\Helpers\Exchange\ExchangeRate
+ * @var \Webkul\Core\Repositories\ExchangeRateRepository
*/
- protected $exchangeRate;
+ protected $exchangeRateRepository;
/**
* Create a new helper instance.
*
+ * @param \Webkul\Core\Repositories\CurrencyRepository $currencyRepository
+ * @param \Webkul\Core\Repositories\ExchangeRateRepository $exchangeRateRepository
* @return void
*/
- public function __construct()
+ public function __construct(
+ CurrencyRepository $currencyRepository,
+ ExchangeRateRepository $exchangeRateRepository
+ )
{
- $this->apiKey = config('services.exchange-api')['fixer']['key'];
+ $this->currencyRepository = $currencyRepository;
- $this->apiEndPoint = 'http://data.fixer.io/api/latest?access_key=' . $this->apiKey;
+ $this->exchangeRateRepository = $exchangeRateRepository;
+
+ $this->apiEndPoint = 'http://data.fixer.io/api';
+
+ $this->apiKey = config('services.exchange-api')['fixer']['key'];
}
/**
- * @return array
+ * Fetch rates and updates in currency_exchange_rates table
+ *
+ * @return \Exception|void
*/
- public function fetchRates()
- {
- $rates = array();
-
- $this->exchangeRate = app('Webkul\Core\Repositories\ExchangeRateRepository');
-
- // dummy api call
- $client = new \GuzzleHttp\Client();
-
- if (config('services.exchange-api')['fixer']['paid_account']) {
- $result = $client->request('GET', 'http://data.fixer.io/api/' . date('Y-m-d').'?access_key=' . $this->apiKey.'&base=' . core()->getBaseCurrency()->code . '&symbols=INR');
- } else {
- $result = $client->request('GET', 'http://data.fixer.io/api/' . date('Y-m-d') . '?access_key=' . $this->apiKey . '&symbols=USD');
- }
-
- $result = json_decode($result->getBody()->getContents());
-
- return $result;
- }
-
public function updateRates()
{
+ $client = new \GuzzleHttp\Client();
+
+ foreach ($this->currencyRepository->all() as $currency) {
+ if ($currency->code == config('app.currency')) {
+ continue;
+ }
+
+ $result = $client->request('GET', $this->apiEndPoint . '/' . date('Y-m-d') . '?access_key=' . $this->apiKey .'&base=' . config('app.currency') . '&symbols=' . $currency->code);
+
+ $result = json_decode($result->getBody()->getContents(), true);
+
+ if (isset($result['success']) && ! $result['success']) {
+ throw new \Exception(
+ isset($result['error']['info'])
+ ? $result['error']['info']
+ : $result['error']['type'], 1);
+ }
+
+ if ($exchangeRate = $currency->exchange_rate) {
+ $this->exchangeRateRepository->update([
+ 'rate' => $result['rates'][$currency->code],
+ ], $exchangeRate->id);
+ } else {
+ $this->exchangeRateRepository->create([
+ 'rate' => $result['rates'][$currency->code],
+ 'target_currency' => $currency->id,
+ ]);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/packages/Webkul/Core/src/Http/Controllers/ExchangeRateController.php b/packages/Webkul/Core/src/Http/Controllers/ExchangeRateController.php
index 38926e452..05ab1b8cd 100755
--- a/packages/Webkul/Core/src/Http/Controllers/ExchangeRateController.php
+++ b/packages/Webkul/Core/src/Http/Controllers/ExchangeRateController.php
@@ -67,7 +67,7 @@ class ExchangeRateController extends Controller
*/
public function create()
{
- $currencies = $this->currencyRepository->with('CurrencyExchangeRate')->all();
+ $currencies = $this->currencyRepository->with('exchange_rate')->all();
return view($this->_config['view'], compact('currencies'));
}
@@ -137,38 +137,19 @@ class ExchangeRateController extends Controller
/**
* Update Rates Using Exchange Rates API
*
- * @param string $service
* @return \Illuminate\Http\JsonResponse
*/
- public function updateRates($service)
+ public function updateRates()
{
- $exchangeService = config('services.exchange-api')[$service];
+ try {
+ app(config('services.exchange-api.' . config('services.exchange-api.default') . '.class'))->updateRates();
- if (is_array($exchangeService)) {
- if (! array_key_exists('class', $exchangeService)) {
- return response()->json([
- 'success' => false,
- 'rates' => null,
- 'error' => trans('admin::app.exchange-rate.exchange-class-not-found', [
- 'service' => $service,
- ]),
- ], 400);
- }
-
- $exchangeServiceInstance = new $exchangeService['class'];
- $updatedRates = $exchangeServiceInstance->fetchRates();
-
- return response()->json([
- 'success' => true,
- 'rates' => 'rates',
- ], 200);
- } else {
- return response()->json([
- 'success' => false,
- 'rates' => null,
- 'error' => trans('admin::app.exchange-rate.invalid-config'),
- ], 400);
+ session()->flash('success', trans('admin::app.settings.exchange_rates.update-success'));
+ } catch(\Exception $e) {
+ session()->flash('error', $e->getMessage());
}
+
+ return redirect()->back();
}
/**
diff --git a/packages/Webkul/Core/src/Models/Currency.php b/packages/Webkul/Core/src/Models/Currency.php
index 70170d19f..7fc11b6d7 100755
--- a/packages/Webkul/Core/src/Models/Currency.php
+++ b/packages/Webkul/Core/src/Models/Currency.php
@@ -30,9 +30,9 @@ class Currency extends Model implements CurrencyContract
}
/**
- * Get the currency_exchange associated with the currency.
+ * Get the exchange rate associated with the currency.
*/
- public function CurrencyExchangeRate()
+ public function exchange_rate()
{
return $this->hasOne(CurrencyExchangeRateProxy::modelClass(), 'target_currency');
}
diff --git a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php
index fa1715bfa..dcc7c0e89 100755
--- a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php
+++ b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php
@@ -12,6 +12,7 @@ use Webkul\Core\Models\SliderProxy;
use Webkul\Core\Observers\SliderObserver;
use Webkul\Core\Console\Commands\BagistoVersion;
use Webkul\Core\Console\Commands\Install;
+use Webkul\Core\Console\Commands\ExchangeRateUpdate;
class CoreServiceProvider extends ServiceProvider
{
@@ -78,7 +79,7 @@ class CoreServiceProvider extends ServiceProvider
protected function registerCommands(): void
{
if ($this->app->runningInConsole()) {
- $this->commands([BagistoVersion::class, Install::class,]);
+ $this->commands([BagistoVersion::class, Install::class, ExchangeRateUpdate::class]);
}
}
diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php
index 4a9acacaf..711207976 100755
--- a/packages/Webkul/Product/src/Repositories/ProductRepository.php
+++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php
@@ -145,14 +145,16 @@ class ProductRepository extends Repository
if (isset($params['sort'])) {
$attribute = $this->attributeRepository->findOneByField('code', $params['sort']);
- if ($params['sort'] == 'price') {
- if ($attribute->code == 'price') {
- $qb->orderBy('min_price', $params['order']);
+ if ($attribute) {
+ if ($params['sort'] == 'price') {
+ if ($attribute->code == 'price') {
+ $qb->orderBy('min_price', $params['order']);
+ } else {
+ $qb->orderBy($attribute->code, $params['order']);
+ }
} else {
- $qb->orderBy($attribute->code, $params['order']);
+ $qb->orderBy($params['sort'] == 'created_at' ? 'product_flat.created_at' : $attribute->code, $params['order']);
}
- } else {
- $qb->orderBy($params['sort'] == 'created_at' ? 'product_flat.created_at' : $attribute->code, $params['order']);
}
}
@@ -262,7 +264,7 @@ class ProductRepository extends Repository
->where('product_flat.new', 1)
->where('product_flat.channel', $channel)
->where('product_flat.locale', $locale)
- ->orderBy('product_id', 'desc');
+ ->inRandomOrder();
})->paginate(4);
return $results;
@@ -287,7 +289,7 @@ class ProductRepository extends Repository
->where('product_flat.featured', 1)
->where('product_flat.channel', $channel)
->where('product_flat.locale', $locale)
- ->orderBy('product_id', 'desc');
+ ->inRandomOrder();
})->paginate(4);
return $results;
diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/customer-info.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/customer-info.blade.php
index 5214f57c0..90fa8652c 100755
--- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/customer-info.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/customer-info.blade.php
@@ -161,6 +161,26 @@
+
+
+
+
+
+
+ @{{ errors.first('address-form.billing[country]') }}
+
+
+
-
-
-
-
-
-
- @{{ errors.first('address-form.billing[country]') }}
-
-
-
+
+
+
+
+
+
+ @{{ errors.first('address-form.shipping[country]') }}
+
+
+
-
-
-
-
-
-
- @{{ errors.first('address-form.shipping[country]') }}
-
-
-