Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
joshine
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
joshine
Commits
486b8f14
Commit
486b8f14
authored
Nov 28, 2022
by
lmf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改js差异
parent
c43a4ddc
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1 additions
and
2112 deletions
+1
-2112
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/paypal-1/in-context/express-checkout-wrapper-mixin.js
+0
-17
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/paypal-1/view/payment/method-renderer/in-context/checkout-express-mixin.js
+0
-115
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/agreement-validation.js
+0
-11
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/amazon.js
+0
-66
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/billing-address.js
+0
-409
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/create-new-account-validation.js
+0
-11
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/form/element/date.js
+0
-44
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/form/element/email.js
+0
-37
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/form/element/region.js
+0
-20
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/gift-message.js
+0
-138
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/onepage.js
+0
-76
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/opc-widget.js
+0
-29
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/payment.js
+0
-79
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/payment/discount.js
+0
-64
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/payment/list.js
+0
-44
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/payment/method-renderer/in-context/checkout-expres.js
+0
-115
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/place-order-btn.js
+0
-203
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/shipping-address/list.js
+0
-47
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/shipping.js
+0
-464
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/summary/item/details.js
+0
-119
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view/payment/method-renderer/in-context/checkout-expres.js
+1
-4
No files found.
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/paypal-1/in-context/express-checkout-wrapper-mixin.js
deleted
100644 → 0
View file @
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
;
};
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/paypal-1/view/payment/method-renderer/in-context/checkout-express-mixin.js
deleted
100644 → 0
View file @
c43a4ddc
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
);
};
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/agreement-validation.js
deleted
100644 → 0
View file @
c43a4ddc
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
({});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/amazon.js
deleted
100644 → 0
View file @
c43a4ddc
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'
;
}
}
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/billing-address.js
deleted
100644 → 0
View file @
c43a4ddc
define
([
'ko'
,
'jquery'
,
'underscore'
,
'Magento_Ui/js/form/form'
,
'Magento_Customer/js/model/customer'
,
'Magento_Customer/js/model/address-list'
,
'Magento_Checkout/js/model/quote'
,
'Magento_Checkout/js/action/create-billing-address'
,
'Magento_Checkout/js/action/select-billing-address'
,
'Magento_Checkout/js/checkout-data'
,
'Magento_Checkout/js/model/checkout-data-resolver'
,
'Magento_Customer/js/customer-data'
,
'Magento_Checkout/js/action/set-billing-address'
,
'Magento_Ui/js/model/messageList'
,
'mage/translate'
,
'uiRegistry'
],
function
(
ko
,
$
,
_
,
Component
,
customer
,
addressList
,
quote
,
createBillingAddress
,
selectBillingAddress
,
checkoutData
,
checkoutDataResolver
,
customerData
,
setBillingAddressAction
,
globalMessageList
,
$t
,
registry
)
{
'use strict'
;
var
lastSelectedBillingAddress
=
null
,
newAddressOption
=
{
/**
* Get new address label
* @returns {String}
*/
getAddressInline
:
function
()
{
return
$t
(
'New Address'
);
},
customerAddressId
:
null
},
countryData
=
customerData
.
get
(
'directory-data'
),
addressOptions
=
addressList
().
filter
(
function
(
address
)
{
return
address
.
getType
()
==
'customer-address'
;
//eslint-disable-line eqeqeq
});
addressOptions
.
push
(
newAddressOption
);
return
Component
.
extend
({
defaults
:
{
template
:
'Rokanthemes_OnePageCheckout/billing-address'
},
currentBillingAddress
:
quote
.
billingAddress
,
addressOptions
:
addressOptions
,
customerHasAddresses
:
addressOptions
.
length
>
1
,
/**
* Init component
*/
initialize
:
function
()
{
var
self
=
this
;
this
.
_super
();
quote
.
paymentMethod
.
subscribe
(
function
()
{
if
(
self
.
isAddressSameAsShipping
())
{
selectBillingAddress
(
quote
.
shippingAddress
());
}
checkoutDataResolver
.
resolveBillingAddress
();
},
this
);
},
/**
* @return {exports.initObservable}
*/
initObservable
:
function
()
{
this
.
_super
()
.
observe
({
selectedAddress
:
null
,
isAddressDetailsVisible
:
quote
.
billingAddress
()
!=
null
,
isAddressFormVisible
:
!
customer
.
isLoggedIn
()
||
addressOptions
.
length
===
1
,
isAddressSameAsShipping
:
false
,
saveInAddressBook
:
1
});
quote
.
billingAddress
.
subscribe
(
function
(
newAddress
)
{
if
(
quote
.
isVirtual
()
||
!
quote
.
shippingAddress
())
{
this
.
isAddressSameAsShipping
(
false
);
}
else
{
this
.
isAddressSameAsShipping
(
newAddress
!=
null
&&
newAddress
.
getCacheKey
()
==
quote
.
shippingAddress
().
getCacheKey
()
//eslint-disable-line eqeqeq
);
}
if
(
newAddress
!=
null
&&
newAddress
.
saveInAddressBook
!==
undefined
)
{
this
.
saveInAddressBook
(
newAddress
.
saveInAddressBook
);
}
else
{
this
.
saveInAddressBook
(
1
);
}
this
.
isAddressDetailsVisible
(
true
);
},
this
);
return
this
;
},
canUseShippingAddress
:
ko
.
computed
(
function
()
{
return
!
quote
.
isVirtual
()
&&
quote
.
shippingAddress
()
&&
quote
.
shippingAddress
().
canUseForBilling
();
}),
/**
* @param {Object} address
* @return {*}
*/
addressOptionsText
:
function
(
address
)
{
return
address
.
getAddressInline
();
},
/**
* @return {Boolean}
*/
useShippingAddress
:
function
()
{
if
(
this
.
isAddressSameAsShipping
())
{
selectBillingAddress
(
quote
.
shippingAddress
());
this
.
updateAddresses
();
this
.
isAddressDetailsVisible
(
true
);
}
else
{
lastSelectedBillingAddress
=
quote
.
billingAddress
();
quote
.
billingAddress
(
null
);
this
.
isAddressDetailsVisible
(
false
);
}
checkoutData
.
setSelectedBillingAddress
(
null
);
return
true
;
},
/**
* Update address action
*/
updateAddress
:
function
()
{
var
addressData
,
newBillingAddress
,
update
;
if
(
this
.
selectedAddress
()
&&
this
.
selectedAddress
()
!=
newAddressOption
)
{
//eslint-disable-line eqeqeq
selectBillingAddress
(
this
.
selectedAddress
());
checkoutData
.
setSelectedBillingAddress
(
this
.
selectedAddress
().
getKey
());
update
=
true
;
}
else
{
this
.
source
.
set
(
'params.invalid'
,
false
);
this
.
source
.
trigger
(
this
.
dataScopePrefix
+
'.data.validate'
);
if
(
this
.
source
.
get
(
this
.
dataScopePrefix
+
'.custom_attributes'
))
{
this
.
source
.
trigger
(
this
.
dataScopePrefix
+
'.custom_attributes.data.validate'
);
}
if
(
!
this
.
source
.
get
(
'params.invalid'
))
{
addressData
=
this
.
source
.
get
(
this
.
dataScopePrefix
);
if
(
customer
.
isLoggedIn
()
&&
!
this
.
customerHasAddresses
)
{
//eslint-disable-line max-depth
this
.
saveInAddressBook
(
1
);
}
addressData
[
'save_in_address_book'
]
=
this
.
saveInAddressBook
()
?
1
:
0
;
newBillingAddress
=
createBillingAddress
(
addressData
);
// New address must be selected as a billing address
selectBillingAddress
(
newBillingAddress
);
checkoutData
.
setSelectedBillingAddress
(
newBillingAddress
.
getKey
());
checkoutData
.
setNewCustomerBillingAddress
(
addressData
);
update
=
true
;
}
}
if
(
!
_
.
isUndefined
(
update
))
{
this
.
updateAddresses
();
}
},
/**
* Edit address action
*/
editAddress
:
function
()
{
lastSelectedBillingAddress
=
quote
.
billingAddress
();
quote
.
billingAddress
(
null
);
this
.
isAddressDetailsVisible
(
false
);
},
/**
* Cancel address edit action
*/
cancelAddressEdit
:
function
()
{
this
.
restoreBillingAddress
();
if
(
quote
.
billingAddress
())
{
// restore 'Same As Shipping' checkbox state
this
.
isAddressSameAsShipping
(
quote
.
billingAddress
()
!=
null
&&
quote
.
billingAddress
().
getCacheKey
()
==
quote
.
shippingAddress
().
getCacheKey
()
&&
//eslint-disable-line
!
quote
.
isVirtual
()
);
this
.
isAddressDetailsVisible
(
true
);
}
},
/**
* Restore billing address
*/
restoreBillingAddress
:
function
()
{
if
(
lastSelectedBillingAddress
!=
null
)
{
selectBillingAddress
(
lastSelectedBillingAddress
);
}
},
/**
* @param {Object} address
*/
onAddressChange
:
function
(
address
)
{
if
(
address
==
newAddressOption
)
{
this
.
autoFillAddress
(
'co-billing-form'
);
}
this
.
isAddressFormVisible
(
address
==
newAddressOption
);
//eslint-disable-line eqeqeq
},
/**
* @param {Number} countryId
* @return {*}
*/
getCountryName
:
function
(
countryId
)
{
return
countryData
()[
countryId
]
!=
undefined
?
countryData
()[
countryId
].
name
:
''
;
//eslint-disable-line
},
/**
* Trigger action to update shipping and billing addresses
*/
updateAddresses
:
function
()
{
if
(
window
.
checkoutConfig
.
reloadOnBillingAddress
||
!
window
.
checkoutConfig
.
displayBillingOnPaymentMethod
)
{
setBillingAddressAction
(
globalMessageList
);
}
},
/**
* Get code
* @param {Object} parent
* @returns {String}
*/
getCode
:
function
(
parent
)
{
return
_
.
isFunction
(
parent
.
getCode
)
?
parent
.
getCode
()
:
'shared'
;
},
/**
* Auto Fill Address
* @param element
*/
autoFillAddress
:
function
(
element
)
{
var
self
=
this
;
if
(
typeof
(
element
)
===
"object"
)
{
var
formId
=
element
.
id
;
}
else
if
(
typeof
(
element
)
===
"string"
)
{
var
formId
=
element
.
replace
(
"#"
,
""
);
}
if
(
addressList
().
length
===
0
||
typeof
(
element
)
===
"string"
)
{
setTimeout
(
function
(){
var
streetId
=
$
(
'#'
+
formId
+
' [name="street[0]"]'
).
id
;
var
street
=
$
(
'#'
+
formId
+
' [name="street[0]"]'
).
val
();
if
(
street
==
''
)
{
self
.
fillCountry
(
formId
);
}
},
1000
);
}
},
/**
* Fill Address
* @param address
* @param id
*/
fillInAddress
:
function
(
address
,
id
)
{
var
componentFields
=
[
'country_id'
,
'postcode'
,
'region_id'
,
'region'
,
'city'
,
'street'
];
var
country
=
false
,
countryList
=
window
.
checkoutConfig
.
OnePageCheckout
.
googleApiListCountries
,
useRegionId
=
false
,
countryElement
=
false
,
regionIdElement
=
false
,
component
=
'checkout.steps.billing-step.payment.payments-list.billing-address-form-shared.form-fields'
;
registry
.
get
(
component
,
function
(
formComponent
)
{
$
.
each
(
componentFields
,
function
(
index
,
field
)
{
var
element
=
formComponent
.
getChild
(
field
);
if
(
field
===
'region'
)
{
element
=
formComponent
.
getChild
(
'region_id_input'
);
}
if
(
field
==
'country_id'
&&
field
in
address
)
{
$
(
'#'
+
element
.
uid
).
find
(
'option'
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
'value'
)
==
address
[
field
])
{
var
currentCountry
=
element
.
value
();
element
.
value
(
address
[
field
]);
country
=
address
[
field
];
countryElement
=
element
;
if
((
$
.
inArray
(
currentCountry
,
countryList
)
===
-
1
&&
$
.
inArray
(
address
[
field
],
countryList
)
!==
-
1
)
||
(
$
.
inArray
(
currentCountry
,
countryList
)
!==
-
1
&&
$
.
inArray
(
address
[
field
],
countryList
)
!==
-
1
&&
currentCountry
!=
address
[
field
])
)
{
element
.
trigger
(
'change'
);
}
return
false
;
}
});
}
if
(
field
==
'region_id'
&&
field
in
address
&&
country
!=
false
&&
$
.
inArray
(
country
,
countryList
)
!==
-
1
)
{
$
(
'#'
+
element
.
uid
).
find
(
'option'
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
'data-title'
)
==
address
[
field
])
{
element
.
value
(
$
(
this
).
attr
(
'value'
));
regionIdElement
=
element
;
return
false
;
}
});
useRegionId
=
true
;
}
if
(
field
==
'region'
&&
country
!=
false
&&
useRegionId
==
false
)
{
if
(
'region_id'
in
address
)
{
element
.
value
(
address
[
'region_id'
]);
}
else
{
element
.
value
(
''
);
}
}
if
(
field
==
'street'
&&
field
in
address
)
{
element
=
formComponent
.
getChild
(
field
).
getChild
(
0
);
element
.
value
(
address
[
field
]);
}
if
((
field
==
'postcode'
||
field
==
'city'
))
{
if
(
field
in
address
)
{
element
.
value
(
address
[
field
]);
}
else
{
element
.
value
(
''
);
}
}
});
});
if
(
country
!=
''
&&
component
==
shipping
)
{
if
(
useRegionId
==
true
&&
regionIdElement
!=
false
)
{
regionIdElement
.
trigger
(
'change'
);
}
else
{
if
(
countryElement
!=
false
)
{
countryElement
.
trigger
(
'change'
);
}
}
}
},
/**
* Fill Country
* @param id
* @param countryCode
*/
fillCountry
:
function
(
formId
)
{
var
countryCode
=
window
.
checkoutConfig
.
OnePageCheckout
.
googleApiCustomerCountry
,
countrySelector
=
$
(
'#'
+
formId
+
' [name="country_id"]'
),
currentCountry
=
countrySelector
.
val
();
if
(
currentCountry
==
countryCode
)
{
return
;
}
countrySelector
.
find
(
'option'
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
'value'
)
==
countryCode
)
{
countrySelector
.
val
(
countryCode
);
countrySelector
.
trigger
(
'change'
);
return
false
;
}
});
},
/**
* Get customer attribute label
*
* @param {*} attribute
* @returns {*}
*/
getCustomAttributeLabel
:
function
(
attribute
)
{
var
resultAttribute
;
if
(
typeof
attribute
===
'string'
)
{
return
attribute
;
}
if
(
attribute
.
label
)
{
return
attribute
.
label
;
}
resultAttribute
=
_
.
findWhere
(
this
.
source
.
get
(
'customAttributes'
)[
attribute
[
'attribute_code'
]],
{
value
:
attribute
.
value
});
return
resultAttribute
&&
resultAttribute
.
label
||
attribute
.
value
;
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/create-new-account-validation.js
deleted
100644 → 0
View file @
c43a4ddc
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
({});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/form/element/date.js
deleted
100644 → 0
View file @
c43a4ddc
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
);
}
},
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/form/element/email.js
deleted
100644 → 0
View file @
c43a4ddc
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
;
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/form/element/region.js
deleted
100644 → 0
View file @
c43a4ddc
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
);
}
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/gift-message.js
deleted
100644 → 0
View file @
c43a4ddc
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
);
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/onepage.js
deleted
100644 → 0
View file @
c43a4ddc
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
();
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/opc-widget.js
deleted
100644 → 0
View file @
c43a4ddc
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
;
}
});
}
);
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/payment.js
deleted
100644 → 0
View file @
c43a4ddc
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
;
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/payment/discount.js
deleted
100644 → 0
View file @
c43a4ddc
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'
);
}
});
}
);
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/payment/list.js
deleted
100644 → 0
View file @
c43a4ddc
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
;
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/payment/method-renderer/in-context/checkout-expres.js
deleted
100644 → 0
View file @
c43a4ddc
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
);
};
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/place-order-btn.js
deleted
100644 → 0
View file @
c43a4ddc
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
;
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/shipping-address/list.js
deleted
100644 → 0
View file @
c43a4ddc
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
;
}
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/shipping.js
deleted
100644 → 0
View file @
c43a4ddc
define
([
'jquery'
,
'underscore'
,
'Magento_Ui/js/form/form'
,
'ko'
,
'Magento_Customer/js/model/customer'
,
'Magento_Customer/js/model/address-list'
,
'Magento_Checkout/js/model/address-converter'
,
'Magento_Checkout/js/model/quote'
,
'Magento_Checkout/js/action/create-shipping-address'
,
'Magento_Checkout/js/action/select-shipping-address'
,
'Rokanthemes_OnePageCheckout/js/model/shipping-rates-validator'
,
'Magento_Checkout/js/model/shipping-address/form-popup-state'
,
'Magento_Checkout/js/model/shipping-service'
,
'Magento_Checkout/js/action/select-shipping-method'
,
'Magento_Checkout/js/model/shipping-rate-registry'
,
'Magento_Checkout/js/action/set-shipping-information'
,
'Magento_Checkout/js/model/step-navigator'
,
'Magento_Ui/js/modal/modal'
,
'Magento_Checkout/js/model/checkout-data-resolver'
,
'Magento_Checkout/js/checkout-data'
,
'uiRegistry'
,
'mage/translate'
,
'Magento_Checkout/js/model/shipping-rate-service'
],
function
(
$
,
_
,
Component
,
ko
,
customer
,
addressList
,
addressConverter
,
quote
,
createShippingAddress
,
selectShippingAddress
,
shippingRatesValidator
,
formPopUpState
,
shippingService
,
selectShippingMethodAction
,
rateRegistry
,
setShippingInformationAction
,
stepNavigator
,
modal
,
checkoutDataResolver
,
checkoutData
,
registry
,
$t
)
{
'use strict'
;
var
popUp
=
null
;
return
Component
.
extend
({
defaults
:
{
template
:
'Magento_Checkout/shipping'
,
shippingFormTemplate
:
'Rokanthemes_OnePageCheckout/shipping-address/form'
,
shippingMethodListTemplate
:
'Magento_Checkout/shipping-address/shipping-method-list'
,
shippingMethodItemTemplate
:
'Magento_Checkout/shipping-address/shipping-method-item'
},
visible
:
ko
.
observable
(
!
quote
.
isVirtual
()),
errorValidationMessage
:
ko
.
observable
(
false
),
isCustomerLoggedIn
:
customer
.
isLoggedIn
,
isFormPopUpVisible
:
formPopUpState
.
isVisible
,
isFormInline
:
addressList
().
length
===
0
,
isNewAddressAdded
:
ko
.
observable
(
false
),
saveInAddressBook
:
1
,
quoteIsVirtual
:
quote
.
isVirtual
(),
/**
* @return {exports}
*/
initialize
:
function
()
{
var
self
=
this
,
hasNewAddress
,
fieldsetName
=
'checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset'
;
this
.
_super
();
if
(
!
quote
.
isVirtual
())
{
stepNavigator
.
registerStep
(
'shipping'
,
''
,
$t
(
'Shipping'
),
this
.
visible
,
_
.
bind
(
this
.
navigate
,
this
),
10
);
}
checkoutDataResolver
.
resolveShippingAddress
();
hasNewAddress
=
addressList
.
some
(
function
(
address
)
{
return
address
.
getType
()
==
'new-customer-address'
;
//eslint-disable-line eqeqeq
});
this
.
isNewAddressAdded
(
hasNewAddress
);
this
.
isFormPopUpVisible
.
subscribe
(
function
(
value
)
{
if
(
value
)
{
self
.
getPopUp
().
openModal
();
}
});
quote
.
shippingMethod
.
subscribe
(
function
()
{
self
.
errorValidationMessage
(
false
);
});
registry
.
async
(
'checkoutProvider'
)(
function
(
checkoutProvider
)
{
var
shippingAddressData
=
checkoutData
.
getShippingAddressFromData
();
if
(
shippingAddressData
)
{
checkoutProvider
.
set
(
'shippingAddress'
,
$
.
extend
(
true
,
{},
checkoutProvider
.
get
(
'shippingAddress'
),
shippingAddressData
)
);
}
checkoutProvider
.
on
(
'shippingAddress'
,
function
(
shippingAddrsData
)
{
checkoutData
.
setShippingAddressFromData
(
shippingAddrsData
);
});
shippingRatesValidator
.
initFields
(
fieldsetName
);
});
return
this
;
},
/**
* Navigator change hash handler.
*
* @param {Object} step - navigation step
*/
navigate
:
function
(
step
)
{
step
&&
step
.
isVisible
(
true
);
},
/**
* @return {*}
*/
getPopUp
:
function
()
{
var
self
=
this
,
buttons
;
if
(
!
popUp
)
{
buttons
=
this
.
popUpForm
.
options
.
buttons
;
this
.
popUpForm
.
options
.
buttons
=
[
{
text
:
buttons
.
save
.
text
?
buttons
.
save
.
text
:
$t
(
'Save Address'
),
class
:
buttons
.
save
.
class
?
buttons
.
save
.
class
:
'action primary action-save-address'
,
click
:
self
.
saveNewAddress
.
bind
(
self
)
},
{
text
:
buttons
.
cancel
.
text
?
buttons
.
cancel
.
text
:
$t
(
'Cancel'
),
class
:
buttons
.
cancel
.
class
?
buttons
.
cancel
.
class
:
'action secondary action-hide-popup'
,
/** @inheritdoc */
click
:
this
.
onClosePopUp
.
bind
(
this
)
}
];
/** @inheritdoc */
this
.
popUpForm
.
options
.
closed
=
function
()
{
self
.
isFormPopUpVisible
(
false
);
};
this
.
popUpForm
.
options
.
modalCloseBtnHandler
=
this
.
onClosePopUp
.
bind
(
this
);
this
.
popUpForm
.
options
.
keyEventHandlers
=
{
escapeKey
:
this
.
onClosePopUp
.
bind
(
this
)
};
/** @inheritdoc */
this
.
popUpForm
.
options
.
opened
=
function
()
{
// Store temporary address for revert action in case when user click cancel action
self
.
temporaryAddress
=
$
.
extend
(
true
,
{},
checkoutData
.
getShippingAddressFromData
());
};
popUp
=
modal
(
this
.
popUpForm
.
options
,
$
(
this
.
popUpForm
.
element
));
}
self
.
autoFillAddress
(
this
.
popUpForm
.
element
);
return
popUp
;
},
/**
* Revert address and close modal.
*/
onClosePopUp
:
function
()
{
checkoutData
.
setShippingAddressFromData
(
$
.
extend
(
true
,
{},
this
.
temporaryAddress
));
this
.
getPopUp
().
closeModal
();
},
/**
* Show address form popup
*/
showFormPopUp
:
function
()
{
this
.
isFormPopUpVisible
(
true
);
},
/**
* Save new shipping address
*/
saveNewAddress
:
function
()
{
var
addressData
,
newShippingAddress
;
this
.
source
.
set
(
'params.invalid'
,
false
);
this
.
triggerShippingDataValidateEvent
();
if
(
!
this
.
source
.
get
(
'params.invalid'
))
{
addressData
=
this
.
source
.
get
(
'shippingAddress'
);
// if user clicked the checkbox, its value is true or false. Need to convert.
addressData
[
'save_in_address_book'
]
=
this
.
saveInAddressBook
?
1
:
0
;
// New address must be selected as a shipping address
newShippingAddress
=
createShippingAddress
(
addressData
);
selectShippingAddress
(
newShippingAddress
);
checkoutData
.
setSelectedShippingAddress
(
newShippingAddress
.
getKey
());
checkoutData
.
setNewCustomerShippingAddress
(
$
.
extend
(
true
,
{},
addressData
));
this
.
getPopUp
().
closeModal
();
this
.
isNewAddressAdded
(
true
);
}
},
/**
* Shipping Method View
*/
rates
:
shippingService
.
getShippingRates
(),
isLoading
:
shippingService
.
isLoading
,
isSelected
:
ko
.
computed
(
function
()
{
return
quote
.
shippingMethod
()
?
quote
.
shippingMethod
()[
'carrier_code'
]
+
'_'
+
quote
.
shippingMethod
()[
'method_code'
]
:
null
;
}),
/**
* @param {Object} shippingMethod
* @return {Boolean}
*/
selectShippingMethod
:
function
(
shippingMethod
)
{
selectShippingMethodAction
(
shippingMethod
);
checkoutData
.
setSelectedShippingRate
(
shippingMethod
[
'carrier_code'
]
+
'_'
+
shippingMethod
[
'method_code'
]);
return
true
;
},
/**
* Set shipping information handler
*/
setShippingInformation
:
function
()
{
if
(
this
.
validateShippingInformation
())
{
setShippingInformationAction
().
done
(
function
()
{
stepNavigator
.
next
();
}
);
}
},
/**
* @return {Boolean}
*/
validateShippingInformation
:
function
()
{
var
shippingAddress
,
addressData
,
loginFormSelector
=
'form[data-role=email-with-possible-login]'
,
emailValidationResult
=
customer
.
isLoggedIn
(),
field
;
if
(
!
quote
.
shippingMethod
())
{
this
.
errorValidationMessage
(
$t
(
'Please specify a shipping method.'
));
return
false
;
}
if
(
!
customer
.
isLoggedIn
())
{
$
(
loginFormSelector
).
validation
();
emailValidationResult
=
Boolean
(
$
(
loginFormSelector
+
' input[name=username]'
).
valid
());
}
if
(
this
.
isFormInline
)
{
this
.
source
.
set
(
'params.invalid'
,
false
);
this
.
triggerShippingDataValidateEvent
();
if
(
emailValidationResult
&&
this
.
source
.
get
(
'params.invalid'
)
||
!
quote
.
shippingMethod
()[
'method_code'
]
||
!
quote
.
shippingMethod
()[
'carrier_code'
]
)
{
this
.
focusInvalid
();
return
false
;
}
shippingAddress
=
quote
.
shippingAddress
();
addressData
=
addressConverter
.
formAddressDataToQuoteAddress
(
this
.
source
.
get
(
'shippingAddress'
)
);
//Copy form data to quote shipping address object
for
(
field
in
addressData
)
{
if
(
addressData
.
hasOwnProperty
(
field
)
&&
//eslint-disable-line max-depth
shippingAddress
.
hasOwnProperty
(
field
)
&&
typeof
addressData
[
field
]
!=
'function'
&&
_
.
isEqual
(
shippingAddress
[
field
],
addressData
[
field
])
)
{
shippingAddress
[
field
]
=
addressData
[
field
];
}
else
if
(
typeof
addressData
[
field
]
!=
'function'
&&
!
_
.
isEqual
(
shippingAddress
[
field
],
addressData
[
field
]))
{
shippingAddress
=
addressData
;
break
;
}
}
if
(
customer
.
isLoggedIn
())
{
shippingAddress
[
'save_in_address_book'
]
=
1
;
}
window
.
shippingAddress
=
shippingAddress
;
//selectShippingAddress(shippingAddress);
}
if
(
!
emailValidationResult
)
{
$
(
loginFormSelector
+
' input[name=username]'
).
focus
();
return
false
;
}
return
true
;
},
/**
* Trigger Shipping data Validate Event.
*/
triggerShippingDataValidateEvent
:
function
()
{
this
.
source
.
trigger
(
'shippingAddress.data.validate'
);
if
(
this
.
source
.
get
(
'shippingAddress.custom_attributes'
))
{
this
.
source
.
trigger
(
'shippingAddress.custom_attributes.data.validate'
);
}
},
/**
* Auto Fill Address
* @param element
*/
autoFillAddress
:
function
(
element
)
{
var
self
=
this
;
if
(
typeof
(
element
)
===
"object"
)
{
var
formId
=
element
.
id
;
}
else
if
(
typeof
(
element
)
===
"string"
)
{
var
formId
=
element
.
replace
(
"#"
,
""
);
}
if
(
this
.
isFormInline
||
typeof
(
element
)
===
"string"
)
{
setTimeout
(
function
(){
var
streetId
=
$
(
'#'
+
formId
+
' [name="street[0]"]'
).
id
;
var
street
=
$
(
'#'
+
formId
+
' [name="street[0]"]'
).
val
();
if
(
street
==
''
)
{
self
.
fillCountry
(
formId
);
}
},
500
);
}
},
/**
* Fill Address
* @param address
* @param id
*/
fillInAddress
:
function
(
address
,
id
)
{
var
componentFields
=
[
'country_id'
,
'postcode'
,
'region_id'
,
'region'
,
'city'
,
'street'
];
var
country
=
false
,
countryList
=
window
.
checkoutConfig
.
OnePageCheckout
.
googleApiListCountries
,
useRegionId
=
false
,
countryElement
=
false
,
regionIdElement
=
false
,
component
=
'checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset'
;
registry
.
get
(
component
,
function
(
formComponent
)
{
$
.
each
(
componentFields
,
function
(
index
,
field
)
{
var
element
=
formComponent
.
getChild
(
field
);
if
(
field
===
'region'
)
{
element
=
formComponent
.
getChild
(
'region_id_input'
);
}
if
(
field
==
'country_id'
&&
field
in
address
)
{
$
(
'#'
+
element
.
uid
).
find
(
'option'
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
'value'
)
==
address
[
field
])
{
var
currentCountry
=
element
.
value
();
element
.
value
(
address
[
field
]);
country
=
address
[
field
];
countryElement
=
element
;
if
((
$
.
inArray
(
currentCountry
,
countryList
)
===
-
1
&&
$
.
inArray
(
address
[
field
],
countryList
)
!==
-
1
)
||
(
$
.
inArray
(
currentCountry
,
countryList
)
!==
-
1
&&
$
.
inArray
(
address
[
field
],
countryList
)
!==
-
1
&&
currentCountry
!=
address
[
field
])
)
{
element
.
trigger
(
'change'
);
}
return
false
;
}
});
}
if
(
field
==
'region_id'
&&
field
in
address
&&
country
!=
false
&&
$
.
inArray
(
country
,
countryList
)
!==
-
1
)
{
$
(
'#'
+
element
.
uid
).
find
(
'option'
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
'data-title'
)
==
address
[
field
])
{
element
.
value
(
$
(
this
).
attr
(
'value'
));
regionIdElement
=
element
;
return
false
;
}
});
useRegionId
=
true
;
}
if
(
field
==
'region'
&&
country
!=
false
&&
useRegionId
==
false
)
{
if
(
'region_id'
in
address
)
{
element
.
value
(
address
[
'region_id'
]);
}
else
{
element
.
value
(
''
);
}
}
if
(
field
==
'street'
&&
field
in
address
)
{
element
=
formComponent
.
getChild
(
field
).
getChild
(
0
);
element
.
value
(
address
[
field
]);
}
if
((
field
==
'postcode'
||
field
==
'city'
))
{
if
(
field
in
address
)
{
element
.
value
(
address
[
field
]);
}
else
{
element
.
value
(
''
);
}
}
});
});
if
(
country
!=
''
&&
component
==
shipping
)
{
if
(
useRegionId
==
true
&&
regionIdElement
!=
false
)
{
regionIdElement
.
trigger
(
'change'
);
}
else
{
if
(
countryElement
!=
false
)
{
countryElement
.
trigger
(
'change'
);
}
}
}
},
/**
* Fill Country
* @param id
* @param countryCode
*/
fillCountry
:
function
(
formId
)
{
var
countryCode
=
window
.
checkoutConfig
.
OnePageCheckout
.
googleApiCustomerCountry
,
countrySelector
=
$
(
'#'
+
formId
+
' [name="country_id"]'
),
currentCountry
=
countrySelector
.
val
();
if
(
currentCountry
==
countryCode
)
{
return
;
}
countrySelector
.
find
(
'option'
).
each
(
function
()
{
if
(
$
(
this
).
attr
(
'value'
)
==
countryCode
)
{
countrySelector
.
val
(
countryCode
);
countrySelector
.
trigger
(
'change'
);
return
false
;
}
});
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view-1/summary/item/details.js
deleted
100644 → 0
View file @
c43a4ddc
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
;
}
});
});
app/code/Rokanthemes/OnePageCheckout/view/frontend/web/js/view/payment/method-renderer/in-context/checkout-expres.js
View file @
486b8f14
...
...
@@ -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
=
{
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment