From d27dfd1c1ed845c7bab2a6a5eb836cb836aff71f Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Tue, 1 Oct 2019 16:26:49 +0530 Subject: [PATCH] change way for default shipping & payment method selection --- .../Payment/src/Config/paymentmethods.php | 9 +++---- packages/Webkul/Payment/src/Config/system.php | 27 +++---------------- packages/Webkul/Payment/src/Payment.php | 1 - .../Webkul/Payment/src/Payment/Payment.php | 10 ------- .../Webkul/Shipping/src/Config/carriers.php | 6 ++--- .../Webkul/Shipping/src/Config/system.php | 18 ++----------- packages/Webkul/Shipping/src/Shipping.php | 1 - .../views/checkout/onepage.blade.php | 14 ++++++---- 8 files changed, 19 insertions(+), 67 deletions(-) diff --git a/packages/Webkul/Payment/src/Config/paymentmethods.php b/packages/Webkul/Payment/src/Config/paymentmethods.php index 0d78373ed..864751d7a 100755 --- a/packages/Webkul/Payment/src/Config/paymentmethods.php +++ b/packages/Webkul/Payment/src/Config/paymentmethods.php @@ -6,8 +6,7 @@ return [ 'description' => 'shop::app.checkout.onepage.cash-desc', 'class' => 'Webkul\Payment\Payment\CashOnDelivery', 'active' => true, - 'sort' => 1, - 'default' => 'yes' + 'sort' => 1 ], 'moneytransfer' => [ @@ -16,8 +15,7 @@ return [ 'description' => 'shop::app.checkout.onepage.money-desc', 'class' => 'Webkul\Payment\Payment\MoneyTransfer', 'active' => true, - 'sort' => 2, - 'default' => 'no' + 'sort' => 2 ], 'paypal_standard' => [ @@ -28,7 +26,6 @@ return [ 'sandbox' => true, 'active' => true, 'business_account' => 'test@webkul.com', - 'sort' => 3, - 'default' => 'no' + 'sort' => 3 ] ]; \ No newline at end of file diff --git a/packages/Webkul/Payment/src/Config/system.php b/packages/Webkul/Payment/src/Config/system.php index beec93f54..3e1b22195 100755 --- a/packages/Webkul/Payment/src/Config/system.php +++ b/packages/Webkul/Payment/src/Config/system.php @@ -62,14 +62,7 @@ return [ 'value' => 4 ] ], - ], [ - 'name' => 'default', - 'title' => 'admin::app.admin.system.default', - 'type' => 'boolean', - 'validation' => 'required', - 'channel_based' => false, - 'locale_based' => true - ], + ] ] ], [ 'key' => 'sales.paymentmethods.moneytransfer', @@ -124,14 +117,7 @@ return [ 'value' => 4 ] ], - ], [ - 'name' => 'default', - 'title' => 'admin::app.admin.system.default', - 'type' => 'boolean', - 'validation' => 'required', - 'channel_based' => false, - 'locale_based' => true - ], + ] ] ], [ 'key' => 'sales.paymentmethods.paypal_standard', @@ -192,14 +178,7 @@ return [ 'value' => 4 ] ], - ], [ - 'name' => 'default', - 'title' => 'admin::app.admin.system.default', - 'type' => 'boolean', - 'validation' => 'required', - 'channel_based' => false, - 'locale_based' => true - ], + ] ] ] ]; \ No newline at end of file diff --git a/packages/Webkul/Payment/src/Payment.php b/packages/Webkul/Payment/src/Payment.php index f7ba3684d..e70df5d0b 100755 --- a/packages/Webkul/Payment/src/Payment.php +++ b/packages/Webkul/Payment/src/Payment.php @@ -41,7 +41,6 @@ class Payment 'method_title' => $object->getTitle(), 'description' => $object->getDescription(), 'sort' => $object->getSortOrder(), - 'default' => $object->getDefaultMethod(), ]; } } diff --git a/packages/Webkul/Payment/src/Payment/Payment.php b/packages/Webkul/Payment/src/Payment/Payment.php index c695f5998..898fe64ce 100755 --- a/packages/Webkul/Payment/src/Payment/Payment.php +++ b/packages/Webkul/Payment/src/Payment/Payment.php @@ -119,14 +119,4 @@ abstract class Payment { return $this->getConfigData('sort'); } - - /** - * Returns default payment method. - * - * @return boolean - */ - public function getDefaultMethod() - { - return $this->getConfigData('default'); - } } \ No newline at end of file diff --git a/packages/Webkul/Shipping/src/Config/carriers.php b/packages/Webkul/Shipping/src/Config/carriers.php index 9a1c7d05f..209658b15 100755 --- a/packages/Webkul/Shipping/src/Config/carriers.php +++ b/packages/Webkul/Shipping/src/Config/carriers.php @@ -8,8 +8,7 @@ return [ 'active' => true, 'default_rate' => '10', 'type' => 'per_unit', - 'class' => 'Webkul\Shipping\Carriers\FlatRate', - 'default' => 'yes', + 'class' => 'Webkul\Shipping\Carriers\FlatRate' ], 'free' => [ @@ -18,7 +17,6 @@ return [ 'description' => 'Free Shipping', 'active' => true, 'default_rate' => '0', - 'class' => 'Webkul\Shipping\Carriers\Free', - 'default' => 'yes', + 'class' => 'Webkul\Shipping\Carriers\Free' ] ]; \ No newline at end of file diff --git a/packages/Webkul/Shipping/src/Config/system.php b/packages/Webkul/Shipping/src/Config/system.php index 3343bf7f3..916d61b99 100755 --- a/packages/Webkul/Shipping/src/Config/system.php +++ b/packages/Webkul/Shipping/src/Config/system.php @@ -43,14 +43,7 @@ return [ 'validation' => 'required', 'channel_based' => false, 'locale_based' => true - ], [ - 'name' => 'default', - 'title' => 'admin::app.admin.system.default', - 'type' => 'boolean', - 'validation' => 'required', - 'channel_based' => false, - 'locale_based' => true - ], + ] ] ], [ 'key' => 'sales.carriers.flatrate', @@ -106,14 +99,7 @@ return [ 'validation' => 'required', 'channel_based' => false, 'locale_based' => true - ], [ - 'name' => 'default', - 'title' => 'admin::app.admin.system.default', - 'type' => 'boolean', - 'validation' => 'required', - 'channel_based' => false, - 'locale_based' => true - ], + ] ] ], [ 'key' => 'sales.shipping', diff --git a/packages/Webkul/Shipping/src/Shipping.php b/packages/Webkul/Shipping/src/Shipping.php index f5e554e4b..44675b89d 100755 --- a/packages/Webkul/Shipping/src/Shipping.php +++ b/packages/Webkul/Shipping/src/Shipping.php @@ -98,7 +98,6 @@ class Shipping if (! isset($rates[$rate->carrier])) { $rates[$rate->carrier] = [ 'carrier_title' => $rate->carrier_title, - 'default' => core()->getConfigData('sales.carriers.' . $rate->carrier. '.default'), 'rates' => [] ]; } 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 9d81d6ffc..04d425e1c 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php @@ -372,11 +372,13 @@ staticRenderFns: shippingTemplateRenderFns, mounted: function() { + var first_iteration = true; + for (method in shippingMethods) { - if (shippingMethods[method]['default'] == 'yes' || shippingMethods[method]['default'] == 1) { + if (first_iteration) { for (rate in shippingMethods[method]['rates']) { this.selected_shipping_method = shippingMethods[method]['rates'][rate]['method']; - + first_iteration = false; this.methodSelected(); } } @@ -425,10 +427,12 @@ staticRenderFns: paymentTemplateRenderFns, mounted: function() { - for (method in paymentMethods) { - if (paymentMethods[method]['default'] == 'yes' || paymentMethods[method]['default'] == 1) { - this.payment.method = paymentMethods[method]['method']; + var first_iteration = true; + for (method in paymentMethods) { + if (first_iteration) { + this.payment.method = paymentMethods[method]['method']; + first_iteration = false; this.methodSelected(); } }