Skip to content

Instantly share code, notes, and snippets.

var product = {
id: 33005,
quantity: 1,
options: {
checkboxOption: "test",
checkboxOption2: "111,222",
checkboxOption3: ["aaa", "ccc"]
},
callback: function(success, product, cart) {
console.log(success); // true or false
@riq363
riq363 / ecwid-cash-on-delivery.js
Last active December 2, 2016 15:47 — forked from makfruit/ecwid-cash-on-delivery.js
Hide or show payment methods in Ecwid depending on the delivery methods selected
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
Ecwid.paymentOptionElement = function(caption) {
return jQuery("label:contains('" + caption + "')").parents('.ecwid-PaymentMethodsBlock-PaymentOption');
};
Ecwid.OnPageLoaded.add(function(page) {
if (page.type === 'CHECKOUT_PAYMENT_DETAILS') {
Ecwid.Cart.get(function(cart) {
//if customer selects 'Local delivery' shipping method
if (cart.shippingMethod === 'Local delivery') {
@riq363
riq363 / reset-product-options-ecwid.js
Last active April 13, 2018 22:37
reset product options ecwid
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
Ecwid.OnPageLoaded.add(function(page) {
function clearFields() {
jQuery("input.ecwid-productBrowser-details-optionTextField").val("");
jQuery("select.ecwid-productBrowser-details-optionSelectBox").val($("option:first").val());
jQuery("span.ecwid-productBrowser-details-optionCheckbox input").prop("checked", false);
jQuery("span.ecwid-productBrowser-details-optionRadioButton:first input").click();
jQuery("input.ecwid-productBrowser-details-optionDateField").val("");
@riq363
riq363 / clear-address-fields.js
Created January 27, 2015 16:22
Clear address fields on Shipping address step Ecwid
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
if (typeof(Ecwid) == 'object') {
Ecwid.OnPageLoaded.add(function(page) {
if ('CHECKOUT_SHIPPING_ADDRESS' == page.type) {
$('input[type=text]').val('');
$('input[type=tel]').val('');
$("select[name='country-list']").val('');
$("select[name='state-list']").val('');
$("select[name='state-suggest']").val('');
@riq363
riq363 / clear-address-fields-and-checkbox.js
Created January 27, 2015 16:26
Clear address fields on Billing address step and unselect checkbox 'My billing address is the same as the shipping address'
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>if (typeof(Ecwid) == 'object') {
Ecwid.OnPageLoaded.add(function(page) {
if ('CHECKOUT_PAYMENT_DETAILS' == page.type) {
$('input[type=checkbox]').prop('checked', false);
$("input[type=text]").prop('disabled', false);
$("input[type=tel]").prop('disabled', false);
$("select[name='country-list']").prop("disabled", false);
$("select[name='state-list']").prop("disabled", false);
$("select[name='state-suggest']").prop("disabled", false);
@riq363
riq363 / disable-loop.js
Created February 3, 2015 13:35
Disable back button loop
<script>
if (document.location.hash != '' ) {
history.pushState('', document.title, window.location.pathname);
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
Ecwid.paymentOptionElement = function(caption) {
return jQuery("label:contains('" + caption + "')").parents('.ecwid-PaymentMethodsBlock-PaymentOption');
};
Ecwid.OnPageLoaded.add(function(page) {
if (page.type === 'CHECKOUT_PAYMENT_DETAILS') {
Ecwid.Cart.get(function(cart) {
if ( $("body").hasClass("ecwid-customer-group-1794001") ) {
Ecwid.paymentOptionElement('Demo payment').show();
@riq363
riq363 / order comments.js
Created April 15, 2015 14:34
Add placeholder for Order Comments in Ecwid
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
Ecwid.OnPageLoad.add(function(page) {
if (page.type == 'CHECKOUT_PAYMENT_DETAILS') {
$('textarea.ecwid-PaymentCommentsBlock-textarea').attr('placeholder', 'row 1\nrow2\nrow3');
}
});
</script>
Ecwid.OnPageLoaded.add(function(page){
if ('ORDER_CONFIRMATION' == page.type) {
setTimeout(function(){
var order_obj = document.getElementsByClassName('ecwid-Invoice-Header-OrderNumber')[0];
var onumber= order_obj.getElementsByTagName('span')[0].textContent;
var script = document.createElement('script');
onumber = onumber.replace(/\#/g,'');
alert(onumber);
},2000);
}
@riq363
riq363 / cash-on-delivery-shipping-fields.js
Last active August 29, 2015 14:21
Cash on delivery script, hides shipping address fields depending on method selected
//Don't forget about jQuery!
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
if (1 || window.location.href.indexOf('key=showMeTheCheckoutMods') != -1) {
processCheckoutShippingPage = function() {
//prefill your desired data
fields = {
'address1':'Specify the address',