Issue #1172 default payment & shipping method

This commit is contained in:
rahul shukla 2019-09-13 14:34:15 +05:30
parent 9eef8aed0a
commit 5a54c02d50
9 changed files with 86 additions and 11 deletions

View File

@ -1137,7 +1137,7 @@ return [
'invoice number prefix' => 'Invoice Number Prefix',
'invoice number length' => 'Invoice Number Length',
'invoice number suffix' => 'Invoice Number Suffix',
'default' => 'Default',
]
]
];

View File

@ -6,7 +6,8 @@ return [
'description' => 'shop::app.checkout.onepage.cash-desc',
'class' => 'Webkul\Payment\Payment\CashOnDelivery',
'active' => true,
'sort' => 1
'sort' => 1,
'default' => 'no'
],
'moneytransfer' => [
@ -15,7 +16,8 @@ return [
'description' => 'shop::app.checkout.onepage.money-desc',
'class' => 'Webkul\Payment\Payment\MoneyTransfer',
'active' => true,
'sort' => 2
'sort' => 2,
'default' => 'yes'
],
'paypal_standard' => [
@ -26,6 +28,7 @@ return [
'sandbox' => true,
'active' => true,
'business_account' => 'test@webkul.com',
'sort' => 3
'sort' => 3,
'default' => 'no'
]
];

View File

@ -62,7 +62,14 @@ 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',
@ -117,7 +124,14 @@ 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',
@ -178,7 +192,14 @@ return [
'value' => 4
]
],
]
], [
'name' => 'default',
'title' => 'admin::app.admin.system.default',
'type' => 'boolean',
'validation' => 'required',
'channel_based' => false,
'locale_based' => true
],
]
]
];

View File

@ -18,6 +18,7 @@ class Payment
return [
'jump_to_section' => 'payment',
'paymentMethods' => $this->getPaymentMethods(),
'html' => view('shop::checkout.onepage.payment', compact('paymentMethods'))->render()
];
}
@ -40,6 +41,7 @@ class Payment
'method_title' => $object->getTitle(),
'description' => $object->getDescription(),
'sort' => $object->getSortOrder(),
'default' => $object->getDefaultMethod(),
];
}
}

View File

@ -113,10 +113,20 @@ abstract class Payment
/**
* Returns payment method sort order
*
* @return array
* @return int
*/
public function getSortOrder()
{
return $this->getConfigData('sort');
}
/**
* Returns default payment method.
*
* @return boolean
*/
public function getDefaultMethod()
{
return $this->getConfigData('default');
}
}

View File

@ -9,6 +9,7 @@ return [
'default_rate' => '10',
'type' => 'per_unit',
'class' => 'Webkul\Shipping\Carriers\FlatRate',
'default' => 'yes',
],
'free' => [
@ -18,5 +19,6 @@ return [
'active' => true,
'default_rate' => '0',
'class' => 'Webkul\Shipping\Carriers\Free',
'default' => 'yes',
]
];

View File

@ -43,7 +43,14 @@ 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',
@ -99,7 +106,14 @@ 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',

View File

@ -46,6 +46,7 @@ class Shipping
return [
'jump_to_section' => 'shipping',
'shippingMethods' => $this->getGroupedAllShippingRates(),
'html' => view('shop::checkout.onepage.shipping', ['shippingRateGroups' => $this->getGroupedAllShippingRates()])->render()
];
}
@ -97,6 +98,7 @@ class Shipping
if (! isset($rates[$rate->carrier])) {
$rates[$rate->carrier] = [
'carrier_title' => $rate->carrier_title,
'default' => core()->getConfigData('sales.carriers.' . $rate->carrier. '.default'),
'rates' => []
];
}

View File

@ -103,6 +103,8 @@
var reviewHtml = '';
var summaryHtml = '';
var customerAddress = '';
var shippingMethods = '';
var paymentMethods = '';
@auth('customer')
@if(auth('customer')->user()->addresses)
@ -230,6 +232,7 @@
if (response.data.jump_to_section == 'shipping') {
shippingHtml = Vue.compile(response.data.html)
shippingMethods = response.data.shippingMethods;
this_this.completedStep = 1;
this_this.currentStep = 2;
@ -254,6 +257,7 @@
if (response.data.jump_to_section == 'payment') {
paymentHtml = Vue.compile(response.data.html)
paymentMethods = response.data.paymentMethods;
this_this.completedStep = 2;
this_this.currentStep = 3;
@ -368,6 +372,16 @@
staticRenderFns: shippingTemplateRenderFns,
mounted: function() {
for (method in shippingMethods) {
if (shippingMethods[method]['default'] == 'yes' || shippingMethods[method]['default'] == 1) {
for (rate in shippingMethods[method]['rates']) {
this.selected_shipping_method = shippingMethods[method]['rates'][rate]['method'];
this.methodSelected();
}
}
}
this.templateRender = shippingHtml.render;
for (var i in shippingHtml.staticRenderFns) {
shippingTemplateRenderFns.push(shippingHtml.staticRenderFns[i]);
@ -411,8 +425,15 @@
staticRenderFns: paymentTemplateRenderFns,
mounted: function() {
this.templateRender = paymentHtml.render;
for (method in paymentMethods) {
if (paymentMethods[method]['default'] == 'yes' || paymentMethods[method]['default'] == 1) {
this.payment.method = paymentMethods[method]['method'];
this.methodSelected();
}
}
this.templateRender = paymentHtml.render;
for (var i in paymentHtml.staticRenderFns) {
paymentTemplateRenderFns.push(paymentHtml.staticRenderFns[i]);
}