diff --git a/config/carriers.php b/config/carriers.php index f088f4172..ca9253b71 100644 --- a/config/carriers.php +++ b/config/carriers.php @@ -3,7 +3,7 @@ return [ 'flatrate' => [ 'code' => 'flatrate', - 'title' => 'Flatrate', + 'title' => 'Flat Rate', 'description' => 'This is a flat rate', 'active' => true, 'default_rate' => '10', diff --git a/config/paymentmethods.php b/config/paymentmethods.php index 9b63a0c10..af7fd8ec5 100644 --- a/config/paymentmethods.php +++ b/config/paymentmethods.php @@ -4,7 +4,17 @@ return [ 'cashondelivery' => [ 'code' => 'cashondelivery', 'title' => 'Cash On Delivery', - 'class' => 'Webkul\Payment\Payment\Payment', + 'description' => 'Cash On Delivery', + 'class' => 'Webkul\Payment\Payment\CashOnDelivery', + 'order_status' => 'Pending', + 'active' => true + ], + + 'moneytransfer' => [ + 'code' => 'moneytransfer', + 'title' => 'Money Transfer', + 'description' => 'Money Transfer', + 'class' => 'Webkul\Payment\Payment\MoneyTransfer', 'order_status' => 'Pending', 'active' => true ] diff --git a/packages/Webkul/Cart/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php b/packages/Webkul/Cart/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php index c3c69ed87..5fe74cc90 100644 --- a/packages/Webkul/Cart/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php +++ b/packages/Webkul/Cart/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php @@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateCartProductsTable extends Migration +class CreateCartItemsTable extends Migration { /** * Run the migrations. diff --git a/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php b/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php index 058b8ac5b..e797a15b9 100644 --- a/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php +++ b/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php @@ -6,6 +6,8 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use Auth; use Webkul\Shipping\Facades\Shipping; +use Webkul\Payment\Facades\Payment; +use Webkul\Cart\Facades\Cart; /** * Chekout controller for the customer @@ -51,9 +53,7 @@ class CheckoutController extends Controller public function saveAddress() { - return response()->json([ - 'shipping' => Shipping::collectRates() - ]); + return response()->json(Shipping::collectRates()); } /** @@ -63,6 +63,7 @@ class CheckoutController extends Controller */ public function saveShipping() { + return response()->json(Payment::getSupportedPaymentMethods()); } /** diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 119d43b41..0b5d36e49 100644 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -140,8 +140,8 @@ class Core $channel = $this->getCurrentChannel(); - // $currencyCode = $channel->base_currency->code; - $currencyCode = $channel->base_currency; + $currencyCode = $channel->base_currency->code; + // $currencyCode = $channel->base_currency; return currency($price, $currencyCode); } diff --git a/packages/Webkul/Payment/Payment.php b/packages/Webkul/Payment/Payment.php deleted file mode 100644 index 543172f86..000000000 --- a/packages/Webkul/Payment/Payment.php +++ /dev/null @@ -1,32 +0,0 @@ - $object->getCode(), - 'title' => $object->getTitle(), - 'description' => $object->getDescription(), - ]; - } - } - - return $paymentMethods; - } -} \ No newline at end of file diff --git a/packages/Webkul/Payment/src/Payment.php b/packages/Webkul/Payment/src/Payment.php new file mode 100644 index 000000000..ebbd54637 --- /dev/null +++ b/packages/Webkul/Payment/src/Payment.php @@ -0,0 +1,35 @@ +isAvailable()) { + $paymentMethods[] = [ + 'method' => $object->getCode(), + 'title' => $object->getTitle(), + 'description' => $object->getDescription(), + ]; + } + } + + return [ + 'jump_to_section' => 'payment', + 'html' => view('shop::checkout.onepage.payment', compact('paymentMethods'))->render() + ]; + } +} \ No newline at end of file diff --git a/packages/Webkul/Payment/src/Payment/MoneyTransfer.php b/packages/Webkul/Payment/src/Payment/MoneyTransfer.php new file mode 100644 index 000000000..7e89c243d --- /dev/null +++ b/packages/Webkul/Payment/src/Payment/MoneyTransfer.php @@ -0,0 +1,13 @@ +_code; + return $this->code; } /** @@ -41,13 +41,13 @@ abstract class Payment } /** - * Returns payment method decription + * Returns payment method description * * @return array */ - public function getDecription() + public function getDescription() { - return $this->getConfigData('decription'); + return $this->getConfigData('description'); } /** @@ -61,10 +61,10 @@ abstract class Payment public function getConfigData($field, $channelId = null) { if (null === $channelId) { - $channelId = core()->getCurrentChannel()->getId(); + $channelId = core()->getCurrentChannel()->id; } - $paymentConfig = Config::get('paymentmethods' . $this->getCode()); + $paymentConfig = Config::get('paymentmethods.' . $this->getCode()); return $paymentConfig[$field]; } diff --git a/packages/Webkul/Shipping/src/Carriers/FlatRate.php b/packages/Webkul/Shipping/src/Carriers/FlatRate.php index ec9a1457c..0d93f4cdc 100644 --- a/packages/Webkul/Shipping/src/Carriers/FlatRate.php +++ b/packages/Webkul/Shipping/src/Carriers/FlatRate.php @@ -4,6 +4,7 @@ namespace Webkul\Shipping\Carriers; use Config; use Webkul\Cart\Models\CartShipping; +use Webkul\Shipping\Facades\Shipping; /** * Class Rate. @@ -20,31 +21,18 @@ class FlatRate extends AbstractShipping public function calculate() { - return [ - 'carrier_code' => 'flatrate', - 'carrier_title' => 'Flat Rate', - 'carrier_description' => '', - 'rates' => [ - [ - 'method' => 'flatrate_flatrate', - 'method_title' => 'Flat Rate', - 'price' => 10, - 'price_formated' => core()->currency(10), - ] - ] - ]; - + if(!$this->isAvailable()) + return false; + $object = new CartShipping; - $object->carrier = 'flatrate_flatrate'; - $object->carrier_title = $this->getConfigData('description'); - $object->method = 'flatrate'; + $object->carrier = 'flatrate'; + $object->carrier_title = $this->getConfigData('title'); + $object->method = 'flatrate_flatrate'; $object->method_title = $this->getConfigData('title'); $object->method_description = $this->getConfigData('description'); $object->price = 10; - return [ - 'flatrate' => [$object] - ]; + return $object; } } \ No newline at end of file diff --git a/packages/Webkul/Shipping/src/Shipping.php b/packages/Webkul/Shipping/src/Shipping.php index 384c8b6f0..201b7af19 100644 --- a/packages/Webkul/Shipping/src/Shipping.php +++ b/packages/Webkul/Shipping/src/Shipping.php @@ -10,20 +10,43 @@ use Illuminate\Support\Facades\Config; */ class Shipping { + protected $rates = []; + public function collectRates() { - $rates = []; - foreach(Config::get('carriers') as $shippingMethod) { $object = new $shippingMethod['class']; - if($object->isAvailable()) { - $rates[] = $object->calculate(); + if($rates = $object->calculate()) { + if(is_array($rates)) { + $this->rates = array_merge($this->rates, $rates); + } else { + $this->rates[] = $rates; + } } } - return $rates; + return [ + 'jump_to_section' => 'shipping', + 'html' => view('shop::checkout.onepage.shipping', ['shippingRateGroups' => $this->getGroupedAllShippingRates()])->render() + ]; + } - // return view('shop::checkout.onepage.shipping', compact('rates')); + public function getGroupedAllShippingRates() + { + $rates = []; + + foreach ($this->rates as $rate) { + if (!isset($rates[$rate->carrier])) { + $rates[$rate->carrier] = [ + 'carrier_title' => $rate->carrier_title, + 'rates' => [] + ]; + } + + $rates[$rate->carrier]['rates'][] = $rate; + } + + return $rates; } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index 554d6f408..4f0f02c70 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -798,6 +798,7 @@ section.slider-block { .product-image { margin-bottom: 10px; + background: #F2F2F2; img { align-self: center; @@ -2216,6 +2217,16 @@ section.cart { margin: 0; } } + + .payment-methods { + .radio { + font-weight: 600; + } + + .control-info { + margin-left: 28px; + } + } } } diff --git a/packages/Webkul/Shop/src/Resources/lang/en/app.php b/packages/Webkul/Shop/src/Resources/lang/en/app.php index 7c8d171eb..f183767ed 100644 --- a/packages/Webkul/Shop/src/Resources/lang/en/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/en/app.php @@ -85,7 +85,8 @@ return [ 'shipping-address' => 'Shipping Address', 'use_for_shipping' => 'Ship to this address', 'continue' => 'Continue', - 'shipping-method' => 'Shipping Method' + 'shipping-method' => 'Shipping Method', + 'payment-information' => 'Payment Information' ] ] ]; \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php index 40a6ae6f7..a1ee8b54f 100644 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php @@ -54,8 +54,8 @@
- - @include('shop::checkout.onepage.shipping') + +
@@ -69,7 +69,15 @@
- @include('shop::checkout.onepage.payment') + + +
+ + + +
@@ -87,6 +95,10 @@ @endpush \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php index e69de29bb..7a714a8d9 100644 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php @@ -0,0 +1,30 @@ +
+
+
+

{{ __('shop::app.checkout.onepage.payment-information') }}

+
+ +
+ +
+ + @foreach ($paymentMethods as $payment) + + + + + {{ $payment['title'] }} + + + {{ $payment['description'] }} + + @endforeach + + + @{{ errors.first('payment-form.payment[method]') }} + + +
+
+
+
\ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/shipping.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/shipping.blade.php index a9c0800e9..04e2ffe77 100644 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/shipping.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/shipping.blade.php @@ -6,19 +6,26 @@
-
-

@{{ shipping_method.carrier_title }}

+
- - - - @{{ rate.method_title }} - @{{ rate.price_formated }} - + @foreach ($shippingRateGroups as $rateGroup) +

{{ $rateGroup['carrier_title'] }}

+ + @foreach ($rateGroup['rates'] as $rate) + + + + {{ $rate->method_title }} + {{ $rate->price }} + + @endforeach + + @endforeach @{{ errors.first('shipping-form.shipping_method') }} +
diff --git a/public/themes/default/assets/css/shop.css b/public/themes/default/assets/css/shop.css index f307a35e2..aeacd86fb 100644 --- a/public/themes/default/assets/css/shop.css +++ b/public/themes/default/assets/css/shop.css @@ -850,6 +850,7 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { .main-container-wrapper .product-card .product-image { margin-bottom: 10px; + background: #F2F2F2; } .main-container-wrapper .product-card .product-image img { @@ -2328,6 +2329,14 @@ section.cart .cart-content .right-side .coupon-section .after-coupon-amount .amo margin: 0; } +.checkout-process .col-main .step-content .payment-methods .radio { + font-weight: 600; +} + +.checkout-process .col-main .step-content .payment-methods .control-info { + margin-left: 28px; +} + .checkout-process .col-right { width: 35%; padding-left: 40px; diff --git a/public/themes/default/assets/js/shop.js b/public/themes/default/assets/js/shop.js index f5c835848..f41490317 100644 --- a/public/themes/default/assets/js/shop.js +++ b/public/themes/default/assets/js/shop.js @@ -31659,6 +31659,10 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); initializeDropdown: function initializeDropdown() { this.totalitems = this.items.length; this.cart_items = this.items; +<<<<<<< HEAD +======= + console.log("The cart items here are = ", this.cart_items); +>>>>>>> 4c89e334f5b115301c5fbd345b50cb61b3c7d089 } } });