Commit 486b8f14 by lmf

修改js差异

parent c43a4ddc
define([
'Magento_Paypal/js/in-context/express-checkout-smart-buttons'
], function (checkoutSmartButtons) {
'use strict';
window.paypalElement = false;
return function(target){
target.renderPayPalButtons = function (element) {
if (window.paypalElement == false) {
window.paypalElement = element;
}
if (typeof window.checkoutConfig === "undefined") {
checkoutSmartButtons(this.prepareClientConfig(), element);
}
}
return target;
};
});
define([
'jquery',
'uiRegistry',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Paypal/js/in-context/express-checkout-smart-buttons',
'Rokanthemes_OnePageCheckout/js/action/validate-shipping-information',
'Magento_Checkout/js/action/select-billing-address',
'Magento_Checkout/js/model/full-screen-loader',
'mage/translate'
], function ($, registry, quote, additionalValidators, checkoutSmartButtons, validateShippingInformationAction, selectBillingAddress, fullScreenLoader) {
'use strict';
var buttonId = 'paypay-in-context-button',
errorId = 'paypay-in-context-validate-error',
html = '<p id="' + errorId + '" style="display:none">' + $.mage.__('Please Fill All Require Field!') + '</p><p class="action primary" id="' + buttonId + '" style="display:none">' + $.mage.__('Continue Paypal') + '</p>',
mixin = {
/**
* Listens element on change and validate it.
*
* @param {HTMLElement} context
*/
initListeners: function (context) {
$(context).find('.payment-method-content').append(html);
var seft = this;
quote.billingAddress.subscribe(function (address) {
if (quote.isVirtual()) {
if (address !== null && quote.paymentMethod() != null) {
$('#' + buttonId).removeClass('disable');
return;
}
} else {
if (address !== null && quote.paymentMethod() != null && quote.shippingMethod() != null) {
$('#' + buttonId).removeClass('disable');
return;
}
}
if (!$('#' + buttonId).hasClass('disable')) {
$('#' + buttonId).addClass('disable');
}
}, this);
this.customValidate(seft);
$('#' + buttonId).click(function () {
if (!$(this).hasClass('disable')) {
$(this).addClass('disable');
seft.customValidate(seft);
}
})
this.fieldChange();
},
/**
* Validates Smart Buttons
*/
validate: function () {
if (this.actions) {
this.actions.enable();
}
},
fieldChange: function () {
$('input[type=radio], input[type=checkbox], select').change(function () {
$('#' + buttonId).parent().find('.actions-toolbar').html('');
$('#' + buttonId).show();
$('#' + errorId).hide();
$('#' + buttonId).removeClass('disable');
if ($(this).val() == 'paypal_express') {
$('#' + buttonId).trigger('click');
}
});
$("input[type=text], textarea").keyup(function(){
$('#' + buttonId).parent().find('.actions-toolbar').html('');
$('#' + buttonId).show();
$('#' + buttonId).removeClass('disable');
});
$("input[type=text], textarea").keydown(function(){
$('#' + buttonId).parent().find('.actions-toolbar').html('');
$('#' + buttonId).show();
$('#' + buttonId).removeClass('disable');
});
},
customValidate: function (seft) {
var shippingAddressComponent = registry.get('checkout.steps.shipping-step.shippingAddress');
if (additionalValidators.validate() == true) {
if (!quote.isVirtual()) {
if (shippingAddressComponent.validateShippingInformation()) {
validateShippingInformationAction().done(
function () {
$('#' + buttonId).hide();
$('#' + errorId).hide();
checkoutSmartButtons(seft.prepareClientConfig(), window.paypalElement);
}
).fail(
function () {
$('#' + buttonId).show();
$('#' + errorId).show();
$('#' + buttonId).removeClass('disable');
fullScreenLoader.stopLoader();
}
);
return;
}
}
}
$('#' + buttonId).show();
$('#' + errorId).show();
$('#' + buttonId).removeClass('disable');
}
};
return function (target) {
return target.extend(mixin);
};
});
define([
'uiComponent',
'Magento_Checkout/js/model/payment/additional-validators',
'Rokanthemes_OnePageCheckout/js/model/agreement-validator'
], function (Component, additionalValidators, agreementValidator) {
'use strict';
additionalValidators.registerValidator(agreementValidator);
return Component.extend({});
});
define([
'uiComponent',
'jquery',
'ko',
'Amazon_Payment/js/model/storage',
'Magento_Checkout/js/model/shipping-rate-service',
'Rokanthemes_OnePageCheckout/js/action/payment-total-information',
'Rokanthemes_OnePageCheckout/js/model/compatible/amazon-pay',
'Magento_Checkout/js/model/quote'
], function (Component, $, ko, amazonStorage, shippingService, getPaymentTotalInformation, amazonPay, quote) {
'use strict';
return Component.extend({
defaults: {
template: 'Amazon_Payment/shipping-address/inline-form',
formSelector: 'co-shipping-form'
},
/**
* Init inline form
*/
initObservable: function () {
this._super();
amazonStorage.isAmazonAccountLoggedIn.subscribe(function (value) {
if (value == false) {
window.checkoutConfig.OnePageCheckout.isAmazonAccountLoggedIn = value;
amazonPay.setLogin(value);
if (!quote.isVirtual()) {
shippingService.estimateShippingMethod();
}
getPaymentTotalInformation();
}
var elem = document.getElementById(this.formSelector);
if (elem && value === false) {
document.getElementById(this.formSelector).style.display = 'block';
}
}, this);
return this;
},
/**
* Show/hide inline form
*/
manipulateInlineForm: function () {
if (amazonStorage.isAmazonAccountLoggedIn()) {
window.checkoutConfig.OnePageCheckout.isAmazonAccountLoggedIn = true;
amazonPay.setLogin(true);
setTimeout(function () {
if (!quote.isVirtual()) {
shippingService.estimateShippingMethod();
}
getPaymentTotalInformation();
}, 1000);
var elem = document.getElementById(this.formSelector);
if (elem) {
document.getElementById(this.formSelector).style.display = 'none';
}
}
}
});
});
define([
'uiComponent',
'Magento_Checkout/js/model/payment/additional-validators',
'Rokanthemes_OnePageCheckout/js/model/create-new-account-validator'
], function (Component, additionalValidators, agreementValidator) {
'use strict';
additionalValidators.registerValidator(agreementValidator);
return Component.extend({});
});
define([
'moment',
'Magento_Ui/js/form/element/date',
'Rokanthemes_OnePageCheckout/js/lib/jquery/jquery-ui-addon-slider-access'
], function (moment, coreDate) {
'use strict';
return coreDate.extend({
defaults: {
options: {
addSliderAccess: true,
sliderAccessArgs: { touchonly: false }
},
},
/**
* Prepares and sets date/time value that will be sent
* to the server.
*
* @param {String} shiftedValue
*/
onShiftedValueChange: function (shiftedValue) {
var value,
formattedValue,
momentValue;
if (shiftedValue) {
momentValue = moment(shiftedValue, this.pickerDateTimeFormat);
if (this.options.showsTime) {
formattedValue = moment(momentValue).format(this.timezoneFormat);
value = moment.tz(formattedValue, this.storeTimeZone).tz('UTC').toISOString();
} else {
value = momentValue.format(this.outputDateFormat);
}
} else {
value = '';
}
if (value !== this.value() && !this.options.showsTime) {
this.value(value);
}
},
});
});
define([
'jquery',
'Magento_Checkout/js/view/form/element/email',
'mage/validation'
], function ($, Component) {
'use strict';
return Component.extend({
defaults: {
template: 'Rokanthemes_OnePageCheckout/form/element/email',
createNewAccount: false
},
checkDelay: 1000,
initObservable: function () {
this._super()
.observe(['email', 'emailFocused', 'isLoading', 'isPasswordVisible', 'createNewAccount']);
return this;
},
createNewAccountConfig: function () {
return window.checkoutConfig.OnePageCheckout.autoCreateNewAccount.enable;
},
createNewAccountChecked: function (element) {
if ($('#' + element).is(":checked")) {
this.createNewAccount(true);
} else {
this.createNewAccount(false);
}
},
minLength: function () {
return window.checkoutConfig.OnePageCheckout.autoCreateNewAccount.minLength;
},
minCharacterSets: function () {
return window.checkoutConfig.OnePageCheckout.autoCreateNewAccount.minCharacterSets;
}
});
});
define([
'uiRegistry',
'Magento_Ui/js/form/element/region'
], function (registry, Component) {
'use strict';
return Component.extend({
/**
* @inheritdoc
*/
filter: function (value, field) {
var country = registry.get(this.parentName + '.' + 'country_id');
if (country) {
this._super(value, field);
}
}
});
});
define([
'ko',
'uiComponent',
'Rokanthemes_OnePageCheckout/js/model/gift-message',
'Rokanthemes_OnePageCheckout/js/action/gift-options'
], function (ko, Component, GiftMessage, giftOptionsService) {
'use strict';
return Component.extend({
formBlockVisibility: null,
resultBlockVisibility: null,
model: {},
isLoading: ko.observable(false),
/**
* Component init
*/
initialize: function () {
var self = this,
model;
this._super()
.observe('formBlockVisibility')
.observe({
'resultBlockVisibility': false
});
this.itemId = this.itemId || 'orderLevel';
this.model = new GiftMessage(this.itemId);
this.model.getObservable('isClear').subscribe(function (value) {
if (value == true) {
self.formBlockVisibility(false);
self.model.getObservable('alreadyAdded')(true);
}
});
this.model.afterSubmit = function () {
self.hideFormBlock();
self.resultBlockVisibility(false);
self.isLoading(false);
};
this.isResultBlockVisible();
},
/**
* Is reslt block visible
*/
isResultBlockVisible: function () {
var self = this;
if (this.model.getObservable('alreadyAdded')()) {
this.resultBlockVisibility(true);
}
this.model.getObservable('additionalOptionsApplied').subscribe(function (value) {
if (value == true) { //eslint-disable-line eqeqeq
self.resultBlockVisibility(true);
}
});
},
/**
* @param {String} key
* @return {*}
*/
getObservable: function (key) {
return this.model.getObservable(key);
},
/**
* Hide\Show form block
*/
toggleFormBlockVisibility: function () {
if (!this.model.getObservable('alreadyAdded')()) {
this.formBlockVisibility(!this.formBlockVisibility());
} else {
this.resultBlockVisibility(!this.resultBlockVisibility());
}
},
/**
* Edit options
*/
editOptions: function () {
this.resultBlockVisibility(false);
this.formBlockVisibility(true);
},
/**
* Delete options
*/
deleteOptions: function () {
this.isLoading(true);
giftOptionsService(this.model);
this.model.getObservable('alreadyAdded')(false);
},
/**
* Hide form block
*/
hideFormBlock: function () {
this.formBlockVisibility(false);
if (this.model.getObservable('alreadyAdded')()) {
this.resultBlockVisibility(true);
}
},
/**
* @return {Boolean}
*/
hasActiveOptions: function () {
var regionData = this.getRegion('additionalOptions'),
options = regionData(),
i;
for (i = 0; i < options.length; i++) {
if (options[i].isActive()) {
return true;
}
}
return false;
},
/**
* @return {Boolean}
*/
isActive: function () {
return this.model.isGiftMessageAvailable();
},
/**
* Submit options
*/
submitOptions: function () {
this.isLoading(true);
giftOptionsService(this.model);
this.model.getObservable('alreadyAdded')(true);
}
});
});
define([
'uiComponent',
'uiRegistry',
'underscore',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/action/select-billing-address',
'Rokanthemes_OnePageCheckout/js/model/payment-service',
'Magento_Checkout/js/model/totals',
'Rokanthemes_OnePageCheckout/js/action/set-shipping-information',
'Magento_Checkout/js/model/shipping-service',
'Magento_Customer/js/model/customer',
'Rokanthemes_OnePageCheckout/js/model/update-item-service'
], function (
Component,
registry,
_,
quote,
selectBillingAddress,
paymentService,
totalsService,
setShippingInformationAction,
shippingService,
customer,
updateItemService
) {
'use strict';
return Component.extend({
/** @inheritdoc */
initialize: function () {
this._super();
var self = this;
quote.shippingMethod.subscribe(function (method) {
if (method && !updateItemService.hasUpdateResult()) {
var shippingRates = shippingService.getShippingRates();
var availableRate = _.find(shippingRates(), function (rate) {
if (rate['method_code'] === null && method['method_code'] === null) {
return false;
}
return rate['carrier_code'] + '_' + rate['method_code'] === method['carrier_code'] + '_' + method['method_code'];
});
if (availableRate) {
if (self._isAddressSameAsShipping()) {
selectBillingAddress(quote.shippingAddress());
}
paymentService.isLoading(true);
totalsService.isLoading(true);
setShippingInformationAction().done(
function () {
paymentService.isLoading(false);
totalsService.isLoading(false);
}
);
}
}
}, this);
if (!customer.isLoggedIn()) {
quote.shippingAddress.subscribe(function (address) {
if (_.isUndefined(address.street) || address.street.length == 0) {
address.street = ["", ""];
}
}, this);
}
},
/**
* @returns {*}
*/
_isAddressSameAsShipping: function () {
return registry.get('checkout.steps.billing-step.payment.payments-list.billing-address-form-shared').isAddressSameAsShipping();
}
});
});
define(
[
'jquery',
'ko',
'uiComponent'
],
function (
$,
ko,
Component
) {
'use strict';
return Component.extend({
defaults: {
template: 'Rokanthemes_OnePageCheckout/widget/opc-widget'
},
getOpcWidget: function (position) {
var widgetList = window.checkoutConfig.opcWidget,
result = ko.observableArray([]);
if (position == "widget_after_placeorder") {
$.each(widgetList.widget_after_placeorder, function (index, value) {
result.push(value);
});
}
return result;
}
});
}
);
define([
'jquery',
'underscore',
'uiComponent',
'ko',
'Magento_Checkout/js/model/quote',
'Rokanthemes_OnePageCheckout/js/model/step-navigator',
'Magento_Checkout/js/model/payment-service',
'Magento_Checkout/js/model/payment/method-converter',
'Magento_Checkout/js/action/get-payment-information',
'Magento_Checkout/js/model/checkout-data-resolver',
'mage/translate',
'Rokanthemes_OnePageCheckout/js/model/payment-service'
], function (
$,
_,
Component,
ko,
quote,
stepNavigator,
paymentService,
methodConverter,
getPaymentInformation,
checkoutDataResolver,
$t,
paymentServiceCt
) {
'use strict';
/** Set payment methods to collection */
paymentService.setPaymentMethods(methodConverter(window.checkoutConfig.paymentMethods));
return Component.extend({
defaults: {
template: 'Magento_Checkout/payment',
activeMethod: ''
},
isVisible: ko.observable(true),
quoteIsVirtual: quote.isVirtual(),
isLoading: paymentServiceCt.isLoading,
isPaymentMethodsAvailable: ko.computed(function () {
return paymentService.getAvailablePaymentMethods().length > 0;
}),
/** @inheritdoc */
initialize: function () {
this._super();
checkoutDataResolver.resolvePaymentMethod();
stepNavigator.registerStep(
'payment',
null,
$t('Review & Payments'),
this.isVisible,
_.bind(this.navigate, this),
20
);
this.navigate();
return this;
},
/**
* Navigate method.
*/
navigate: function () {
var self = this;
getPaymentInformation().done(function () {
self.isVisible(true);
});
},
/**
* @return {*}
*/
getFormKey: function () {
return window.checkoutConfig.formKey;
}
});
});
define(
[
'jquery',
'ko',
'uiComponent',
'Magento_Checkout/js/model/quote',
'Magento_SalesRule/js/action/set-coupon-code',
'Magento_SalesRule/js/action/cancel-coupon',
'Rokanthemes_OnePageCheckout/js/model/payment-service'
],
function ($, ko, Component, quote, setCouponCodeAction, cancelCouponAction, paymentServiceOpc) {
'use strict';
var totals = quote.getTotals(),
couponCode = ko.observable(null),
isApplied = paymentServiceOpc.isAppliedCoupon;
if (totals()) {
couponCode(totals()['coupon_code']);
}
return Component.extend({
defaults: {
template: 'Magento_SalesRule/payment/discount'
},
couponCode: couponCode,
/**
* Applied flag
*/
isApplied: isApplied,
/**
* Coupon code application procedure
*/
apply: function() {
if (this.validate()) {
setCouponCodeAction(couponCode(), isApplied);
}
},
/**
* Cancel using coupon
*/
cancel: function() {
if (this.validate()) {
couponCode('');
cancelCouponAction(isApplied);
}
},
/**
* Coupon form validation
*
* @returns {Boolean}
*/
validate: function () {
var form = '#discount-form';
return $(form).validation() && $(form).validation('isValid');
}
});
}
);
define([
'underscore',
'Magento_Checkout/js/view/payment/list'
], function (_, Component) {
'use strict';
return Component.extend({
/** @inheritdoc */
initialize: function () {
this._super();
},
/**
* Returns payment group title
*
* @param {Object} group
* @returns {String}
*/
getGroupTitle: function (group) {
var title = group().title;
if (group().isDefault() && this.paymentGroupsList().length > 1) {
title = this.defaultGroupTitle;
}
return title;
},
/**
* @param {Object} group
* @returns {Boolean}
*/
showFormShared: function (group) {
var isShow = false;
if (this.paymentGroupsList().length) {
if (_.first(this.paymentGroupsList()).alias == group().alias) {
isShow = true;
}
}
return isShow;
}
});
});
define([
'jquery',
'uiRegistry',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Paypal/js/in-context/express-checkout-smart-buttons',
'Rokanthemes_OnePageCheckout/js/action/validate-shipping-information',
'Magento_Checkout/js/action/select-billing-address',
'Magento_Checkout/js/model/full-screen-loader',
'mage/translate'
], function ($, registry, quote, additionalValidators, checkoutSmartButtons, validateShippingInformationAction, selectBillingAddress, fullScreenLoader) {
'use strict';
var buttonId = 'paypay-in-context-button',
errorId = 'paypay-in-context-validate-error',
html = '<p id="' + errorId + '" style="display:none">' + $.mage.__('Please Fill All Require Field!') + '</p><p class="action primary" id="' + buttonId + '" style="display:none">' + $.mage.__('Continue Paypal') + '</p>',
mixin = {
/**
* Listens element on change and validate it.
*
* @param {HTMLElement} context
*/
initListeners: function (context) {
$(context).find('.payment-method-content').append(html);
var seft = this;
quote.billingAddress.subscribe(function (address) {
if (quote.isVirtual()) {
if (address !== null && quote.paymentMethod() != null) {
$('#' + buttonId).removeClass('disable');
return;
}
} else {
if (address !== null && quote.paymentMethod() != null && quote.shippingMethod() != null) {
$('#' + buttonId).removeClass('disable');
return;
}
}
if (!$('#' + buttonId).hasClass('disable')) {
$('#' + buttonId).addClass('disable');
}
}, this);
this.customValidate(seft);
$('#' + buttonId).click(function () {
if (!$(this).hasClass('disable')) {
$(this).addClass('disable');
seft.customValidate(seft);
}
})
this.fieldChange();
},
/**
* Validates Smart Buttons
*/
validate: function () {
if (this.actions) {
this.actions.enable();
}
},
fieldChange: function () {
$('input[type=radio], input[type=checkbox], select').change(function () {
$('#' + buttonId).parent().find('.actions-toolbar').html('');
$('#' + buttonId).show();
$('#' + errorId).hide();
$('#' + buttonId).removeClass('disable');
if ($(this).val() == 'paypal_express') {
$('#' + buttonId).trigger('click');
}
});
$("input[type=text], textarea").keyup(function(){
$('#' + buttonId).parent().find('.actions-toolbar').html('');
$('#' + buttonId).show();
$('#' + buttonId).removeClass('disable');
});
$("input[type=text], textarea").keydown(function(){
$('#' + buttonId).parent().find('.actions-toolbar').html('');
$('#' + buttonId).show();
$('#' + buttonId).removeClass('disable');
});
},
customValidate: function (seft) {
var shippingAddressComponent = registry.get('checkout.steps.shipping-step.shippingAddress');
if (additionalValidators.validate() == true) {
if (!quote.isVirtual()) {
if (shippingAddressComponent.validateShippingInformation()) {
validateShippingInformationAction().done(
function () {
$('#' + buttonId).hide();
$('#' + errorId).hide();
checkoutSmartButtons(seft.prepareClientConfig(), window.paypalElement);
}
).fail(
function () {
$('#' + buttonId).show();
$('#' + errorId).show();
$('#' + buttonId).removeClass('disable');
fullScreenLoader.stopLoader();
}
);
return;
}
}
}
$('#' + buttonId).show();
$('#' + errorId).show();
$('#' + buttonId).removeClass('disable');
}
};
return function (target) {
return target.extend(mixin);
};
});
define([
'ko',
'jquery',
'uiComponent',
'uiRegistry',
'mage/translate',
'Magento_Checkout/js/model/quote',
'Rokanthemes_OnePageCheckout/js/model/shipping-rate-processor/new-address',
'Rokanthemes_OnePageCheckout/js/model/shipping-rate-processor/customer-address',
'Rokanthemes_OnePageCheckout/js/action/validate-shipping-information',
// 'Rokanthemes_OnePageCheckout/js/action/validate-gift-wrap-before-order',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/action/select-billing-address',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/shipping-service',
'Magento_Checkout/js/model/shipping-rate-registry',
'underscore',
'Magento_Ui/js/modal/alert',
'Magento_Checkout/js/checkout-data',
'Magento_Checkout/js/model/totals',
'Amazon_Payment/js/model/storage'
], function (
ko,
$,
Component,
registry,
$t,
quote,
DefaultProcessor,
CustomerAddressProcessor,
validateShippingInformationAction,
// validateGiftWrapAction,
fullScreenLoader,
selectBillingAddress,
additionalValidators,
shippingService,
rateRegistry,
_,
alert,
checkoutData,
totals,
amazonStorage
) {
'use strict';
return Component.extend({
defaults: {
template: 'Rokanthemes_OnePageCheckout/place-order-btn'
},
placeOrderLabel: ko.observable($t(window.checkoutConfig.OnePageCheckout.titlePlaceOrder)),
isVisible: ko.observable(true),
isPlaceOrderActionAllowed: ko.observable(quote.billingAddress() != null && quote.paymentMethod() != null),
/** @inheritdoc */
initialize: function () {
window.isPlaceOrderDispatched = false;
this._super();
var self = this;
quote.billingAddress.subscribe(function (address) {
if (quote.isVirtual()) {
setTimeout(function () {
self.isPlaceOrderActionAllowed(address !== null && quote.paymentMethod() != null);
}, 500);
} else {
self.isPlaceOrderActionAllowed(address !== null && quote.paymentMethod() != null && quote.shippingMethod() != null);
}
}, this);
quote.paymentMethod.subscribe(function (newMethod) {
if (quote.isVirtual()) {
self.isPlaceOrderActionAllowed(newMethod !== null && quote.billingAddress() != null);
} else {
self.isPlaceOrderActionAllowed(newMethod !== null && quote.billingAddress() != null && quote.shippingMethod() != null);
}
if ((newMethod.method === "amazonlogin" && !amazonStorage.isAmazonAccountLoggedIn()) ||
newMethod.method === "braintree_paypal"
) {
self.isVisible(false);
}
}, this);
if (!quote.isVirtual()) {
quote.shippingMethod.subscribe(function (method) {
var availableRate,
shippingRates = shippingService.getShippingRates();
if (method) {
availableRate = _.find(shippingRates(), function (rate) {
return rate['carrier_code'] + '_' + rate['method_code'] === method['carrier_code'] + '_' + method['method_code'];
});
}
self.isPlaceOrderActionAllowed(availableRate && quote.paymentMethod() != null && quote.billingAddress() != null);
}, this);
}
if (
window.checkoutConfig.paypal_in_context == true || !_.isEmpty(window.checkoutConfig.amazonLogin)
) {
var selectedPaymentMethod = checkoutData.getSelectedPaymentMethod();
if (selectedPaymentMethod == "paypal_express" ||
selectedPaymentMethod == "amazonlogin" ||
selectedPaymentMethod == "braintree_paypal") {
self.isVisible(false);
}
$(document).on('change', '.payment-method .radio', function () {
if ($('.payment-method._active').find('.actions-toolbar').is('#paypal-express-in-context-button') ||
($(this).attr('id') === 'amazonlogin') ||
($(this).attr('id') === 'braintree_paypal')
) {
self.isVisible(false);
} else {
self.isVisible(true);
}
});
}
},
placeOrder: function (data, event) {
var self = this;
var shippingAddressComponent = registry.get('checkout.steps.shipping-step.shippingAddress');
window.isPlaceOrderDispatched = true;
if (event) {
event.preventDefault();
}
if (additionalValidators.validate()) {
if (quote.isVirtual()) {
$('input#' + self.getCode())
.closest('.payment-method').find('.payment-method-content .actions-toolbar:not([style*="display: none"]) button.action.checkout')
.trigger('click');
} else {
if (shippingAddressComponent.validateShippingInformation()) {
var reSelectShippingAddress = false;
if (typeof window.shippingAddress !== "undefined" || !$.isEmptyObject(window.shippingAddress)) {
quote.shippingAddress(window.shippingAddress);
var type = quote.shippingAddress().getType();
if (type == 'customer-address') {
var cache = rateRegistry.get(quote.shippingAddress().getKey());
if (!cache) {
reSelectShippingAddress = true;
CustomerAddressProcessor(quote.shippingAddress()).done(function (result) {
self.placeOrderContinue();
}).fail(function (response) {
}).always(function () {
window.shippingAddress = {};
});
} else {
window.shippingAddress = {};
}
} else {
var cache = rateRegistry.get(quote.shippingAddress().getCacheKey());
if (!cache) {
reSelectShippingAddress = true;
DefaultProcessor(quote.shippingAddress()).done(function (result) {
self.placeOrderContinue();
}).fail(function (response) {
}).always(function () {
window.shippingAddress = {};
});
} else {
window.shippingAddress = {};
}
}
}
if (!reSelectShippingAddress) {
self.placeOrderContinue();
}
}
}
}
return false;
},
placeOrderContinue: function () {
var self = this;
var billingAddressComponent = registry.get('checkout.steps.billing-step.payment.payments-list.billing-address-form-shared');
if (billingAddressComponent.isAddressSameAsShipping()) {
fullScreenLoader.startLoader();
selectBillingAddress(quote.shippingAddress());
}
validateShippingInformationAction().done(
function () {
fullScreenLoader.stopLoader();
$('input#' + self.getCode())
.closest('.payment-method').find('.payment-method-content .actions-toolbar:not([style*="display: none"]) button.action.checkout')
.trigger('click');
}
).fail(
function () {
fullScreenLoader.stopLoader();
}
);
},
getCode: function () {
return quote.paymentMethod().method;
}
});
});
define([
'underscore',
'ko',
'mageUtils',
'Magento_Checkout/js/view/shipping-address/list',
'uiLayout'
], function (_, ko, utils, Component, layout) {
'use strict';
var defaultRendererTemplate = {
parent: '${ $.$data.parentName }',
name: '${ $.$data.name }',
component: 'Magento_Checkout/js/view/shipping-address/address-renderer/default',
template: 'Rokanthemes_OnePageCheckout/shipping-address/address-renderer/default'
};
return Component.extend({
/**
* Create new component that will render given address in the address list
*
* @param {Object} address
* @param {*} index
*/
createRendererComponent: function (address, index) {
var rendererTemplate, templateData, rendererComponent;
if (index in this.rendererComponents) {
this.rendererComponents[index].address(address);
} else {
// rendererTemplates are provided via layout
rendererTemplate = address.getType() != undefined && this.rendererTemplates[address.getType()] != undefined ? //eslint-disable-line
utils.extend({}, defaultRendererTemplate, this.rendererTemplates[address.getType()]) :
defaultRendererTemplate;
templateData = {
parentName: this.name,
name: index
};
rendererComponent = utils.template(rendererTemplate, templateData);
utils.extend(rendererComponent, {
address: ko.observable(address)
});
layout([rendererComponent]);
this.rendererComponents[index] = rendererComponent;
}
}
});
});
define([
'jquery',
'Magento_Checkout/js/view/summary/item/details',
'mage/translate',
'ko',
'underscore',
'Magento_Customer/js/customer-data',
'Rokanthemes_OnePageCheckout/js/action/update-item',
'Magento_Checkout/js/model/quote'
], function ($, Component, $t, ko, _, customerData, updateItemAction, quote) {
'use strict';
return Component.extend({
defaults: {
template: 'Rokanthemes_OnePageCheckout/summary/item/details'
},
titleQtyBox: ko.observable($t('Qty')),
number: null,
/**
* @param {Object} item
* @returns void
*/
updateQty: function (item) {
if (item.qty < 0) {
$(".error-message[itemId = '" + item.item_id + "']").text($t('Please enter the number greater than or equal to 0!'));
return;
}
if (parseFloat(item.qty) != item.qty) {
$(".error-message[itemId = '" + item.item_id + "']").text($t('Please enter number!'));
return;
}
$(".error-message[itemId = '" + item.item_id + "']").text($t(''));
updateItemAction(item).done(
function (response) {
var totals = response.totals,
data = JSON.parse(this.data),
itemId = data.itemId,
itemsOrigin = [],
quoteItemData = window.checkoutConfig.quoteItemData;
if (!response.status) {
var originItem = _.find(quoteItemData, function (index) {
return index.item_id == itemId;
});
$.each(totals.items, function (index) {
if (this.item_id == originItem.item_id) {
this.qty = originItem.qty;
}
itemsOrigin[index] = this;
});
totals.items = itemsOrigin;
} else {
customerData.reload('cart');
}
quote.setTotals(totals);
}
);
},
/**
* @param data
* @param event
*/
updateQtyButton: function (data, event) {
var element = event.target,
action = element.getAttribute('action'),
itemId = element.getAttribute('itemId'),
qtyInput = $('[itemId = ' + itemId + ']').parent().parent().find('input');
if (typeof action === "undefined" || typeof itemId === "undefined" || typeof qtyInput === "undefined") {
return;
}
var currentQty = parseFloat(qtyInput.val());
currentQty = Math.round(currentQty * 100);
if (this.number != null && currentQty >= 100) {
clearTimeout(this.number);
}
if (action == 'increase') {
var nextQty = (currentQty + 100)/100;
nextQty = +nextQty.toFixed(2);
qtyInput.val(nextQty);
this.number = setTimeout(function () {
qtyInput.trigger('change');
}, 1000);
} else {
if (currentQty >= 100) {
var nextQty = (currentQty - 100)/100;
nextQty = +nextQty.toFixed(2);
qtyInput.val(nextQty);
this.number = setTimeout(function () {
qtyInput.trigger('change');
}, 1000);
}
}
},
/**
* @param {*} itemId
* @returns {String}
*/
getProductUrl: function (itemId) {
if (_.isUndefined(customerData.get('cart')())) {
customerData.reload('cart');
}
var productUrl = 'javascript:void(0)',
cartData = customerData.get('cart')(),
items = cartData.items;
var item = _.find(items, function (item) {
return item.item_id == itemId;
});
if (!_.isUndefined(item) && item.product_has_url) {
productUrl = item.product_url;
}
return productUrl;
}
});
});
......@@ -12,10 +12,7 @@ define([
'use strict';
var buttonId = 'paypay-in-context-button',
errorId = 'paypay-in-context-validate-error',
/* html = '<p id="' + errorId + '" style="display:none">' + $.mage.__('Please Fill All Require Field!') + '</p><p class="action primary" id="' + buttonId + '" style="display:none">' + $.mage.__('Continue Paypal') + '</p>', */
html = '<p id="' + errorId + '" >' + $.mage.__('Please Fill All Require Field!') + '</p><p class="action primary" id="' + buttonId + '" >' + $.mage.__('Continue Paypal') + '</p>',
html = '<p id="' + errorId + '" style="display:none">' + $.mage.__('Please Fill All Require Field!') + '</p><p class="action primary" id="' + buttonId + '" style="display:none">' + $.mage.__('Continue Paypal') + '</p>',
mixin = {
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment