From a0770926315c9247f448d545fc8cafe0db82ba07 Mon Sep 17 00:00:00 2001 From: IceToast Date: Mon, 30 Jan 2023 22:44:48 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Allow=20to=20buy=20a=20prod?= =?UTF-8?q?uct=20for=20free?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/PaymentController.php | 29 ++++++++++++------- themes/default/views/store/checkout.blade.php | 10 +++++-- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index 4fdaf2f9..0cf2e399 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -39,21 +39,29 @@ class PaymentController extends Controller */ public function checkOut(ShopProduct $shopProduct) { - $extensions = ExtensionHelper::getAllExtensionsByNamespace('PaymentGateways'); + $discount = PartnerDiscount::getDiscount(); + $price = $shopProduct->price - ($shopProduct->price * $discount / 100); - // build a paymentgateways array that contains the routes for the payment gateways and the image path for the payment gateway which lays in public/images/Extensions/PaymentGateways with the extensionname in lowercase $paymentGateways = []; - foreach ($extensions as $extension) { - $extensionName = basename($extension); - if (!ExtensionHelper::getExtensionConfig($extensionName, 'enabled')) continue; // skip if not enabled + if ($price > 0) { + $extensions = ExtensionHelper::getAllExtensionsByNamespace('PaymentGateways'); - $payment = new \stdClass(); - $payment->name = ExtensionHelper::getExtensionConfig($extensionName, 'name'); - $payment->image = asset('images/Extensions/PaymentGateways/' . strtolower($extensionName) . '_logo.png'); - $paymentGateways[] = $payment; + // build a paymentgateways array that contains the routes for the payment gateways and the image path for the payment gateway which lays in public/images/Extensions/PaymentGateways with the extensionname in lowercase + foreach ($extensions as $extension) { + $extensionName = basename($extension); + if (!ExtensionHelper::getExtensionConfig($extensionName, 'enabled')) continue; // skip if not enabled + + $payment = new \stdClass(); + $payment->name = ExtensionHelper::getExtensionConfig($extensionName, 'name'); + $payment->image = asset('images/Extensions/PaymentGateways/' . strtolower($extensionName) . '_logo.png'); + $paymentGateways[] = $payment; + } } - $discount = PartnerDiscount::getDiscount(); + + + + return view('store.checkout')->with([ 'product' => $shopProduct, @@ -64,6 +72,7 @@ class PaymentController extends Controller 'taxpercent' => $shopProduct->getTaxPercent(), 'total' => $shopProduct->getTotalPrice(), 'paymentGateways' => $paymentGateways, + 'productIsFree' => $price <= 0, ]); } diff --git a/themes/default/views/store/checkout.blade.php b/themes/default/views/store/checkout.blade.php index 2b6cc796..4ce7c5ee 100644 --- a/themes/default/views/store/checkout.blade.php +++ b/themes/default/views/store/checkout.blade.php @@ -130,11 +130,15 @@
-