Closed wrsjr closed 10 years ago
Que versão do módulo Akatus Magento você está utilizando? E qual checkout (Deivison, Checkout Simplificado ou padrão do Magento)? Esse código que você colou não diz nada. Você nem mesmo disse qual arquivo é esse. Me parece que é o javascript do checkout padrão do Magento.
Olá Diego, Bom dia !
Uso o checkout disponibilizado por vcs, a ultima versão.
Esse arquivo é o checkoutsimplificado.js
Att,
Wilson Roberto Junior
Em 07/11/2013, às 09:00, Diego Souza notifications@github.com escreveu:
Que versão do módulo Akatus Magento você está utilizando? E qual checkout (Deivison, Checkout Simplificado ou padrão do Magento)? Esse código que você colou não diz nada. Você nem mesmo disse qual arquivo é esse. Me parece que é o javascript do checkout padrão do Magento.
— Reply to this email directly or view it on GitHub.
Esse código não está presente nesse projeto, ele faz parte do One Step Checkout Simplificado: https://github.com/diegosouza/one_step_checkout_simplificado
Você possui esse arquivo porque instalou o módulo da Akatus (que inclui esse checkout) via Magento Connect. Conforme contato direto, a sua necessidade é um tanto específica, especialmente por lidar com vários intermediadores de pagamento. Quanto ao problema em atualizar o parcelamento via cartão de crédito ao selecionar mudar o tipo de frete, já está corrigido, tag 0.0.3 do One Step Checkout Simplificado:
https://github.com/diegosouza/one_step_checkout_simplificado/archive/0.0.3.zip
Pessoal, ao selecionar o tipo de frete o valor para pagamento por cartão de crédito não é atualizado e tambem se ofereço um desconto para o cliente pagar com a AKatus este valor não esta sendo atualizado, alguem pode me ajudar?
Localizei abaixo o cód que faz a atualização do checkout, mas o cartão de credito não atualiza.
var OPC = Class.create(); OPC.prototype = { initialize: function (form, urls, agreement) { this.acceptAgreementText = agreement; this.successUrl = check_secure_url(urls.success); this.saveUrl = check_secure_url(urls.save); this.updateUrl = check_secure_url(urls.update); this.failureUrl = check_secure_url(urls.failure); this.form = form; this.loadWaiting = false; this.validator = new Validation(this.form); this.sectionsToValidate = [payment]; if (typeof shippingMethod === 'object') { this.sectionsToValidate.push(shippingMethod) } this._addEventListeners() }, _addEventListeners: function () { $('login-form') && $('login-form').observe('submit', function (e) { Event.stop(e); if (!loginForm.validator.validate()) { return } $('login-please-wait').show(); $('send2').setAttribute('disabled', 'disabled'); $$('#login-form .buttons-set')[0].addClassName('disabled').setOpacity(0.5); new Ajax.Request($('login-form').action, { parameters: $('login-form').serialize(), onSuccess: function (transport) { OPC.Messenger.clear('login-form'); var response = transport.responseText.evalJSON(); if (response.error) { OPC.Messenger.add(response.error, 'login-form', 'error') } if (response.redirect) { document.location = response.redirect; return } $('login-please-wait').hide(); $('send2').removeAttribute('disabled'); $$('#login-form .buttons-set')[0].removeClassName('disabled').setOpacity(1) } }) }); $('forgot-password-form') && $('forgot-password-form').observe('submit', function (e) { Event.stop(e); if (!forgotForm.validator.validate()) { return } $('forgot-please-wait').show(); $('btn-forgot').setAttribute('disabled', 'disabled'); $$('#forgot-password-form .buttons-set')[0].addClassName('disabled').setOpacity(0.5); new Ajax.Request($('forgot-password-form').action, { parameters: $('forgot-password-form').serialize(), onSuccess: function (transport) { OPC.Messenger.clear('forgot-password-form'); $('forgot-please-wait').hide(); $('btn-forgot').removeAttribute('disabled'); $$('#forgot-password-form .buttons-set')[0].removeClassName('disabled').setOpacity(1); var response = transport.responseText.evalJSON(); if (response.error) { OPC.Messenger.add(response.error, 'forgot-password-form', 'error') } else if (response.message) { open_login(); OPC.Messenger.clear('login-form'); OPC.Messenger.add(response.message, 'login-form', 'success') } } }) }) }, ajaxFailure: function () { location.href = this.failureUrl }, _disableEnableAll: function (element, isDisabled) { var descendants = element.descendants(); for (var k in descendants) { descendants[k].disabled = isDisabled } element.disabled = isDisabled }, setLoadWaiting: function (flag) { if (flag) { var container = $('review-buttons-container'); container.addClassName('disabled'); container.setStyle({ opacity: 0.5 }); this._disableEnableAll(container, true) } else if (this.loadWaiting) { var container = $('review-buttons-container'); container.removeClassName('disabled'); container.setStyle({ opacity: 1 }); this._disableEnableAll(container, false) } this.loadWaiting = flag }, save: function () { if (this.loadWaiting != false) { return } var isValid = true; if (!this.validator.validate()) { isValid = false } for (i in this.sectionsToValidate) { if (typeof this.sectionsToValidate[i] === 'function') { continue } if (!this.sectionsToValidate[i].validate()) { isValid = false } } OPC.Messenger.clear('checkout-review-submit'); $$('#checkout-review-submit .checkout-agreements input[type="checkbox"]').each(function (el) { if (!el.checked) { OPC.Messenger.add(this.acceptAgreementText, 'checkout-review-submit', 'error'); isValid = false; throw $break } }.bind(this)); if (!isValid) { var validationMessages = $$('.validation-advice, .messages').findAll(function (el) { return el.visible() }); if (!validationMessages.length) { return } var viewportSize = document.viewport.getDimensions(); var hiddenMessages = []; var needToScroll = true; validationMessages.each(function (el) { var offset = el.viewportOffset(); if (offset.top < 0 || offset.top > viewportSize.height || offset.left < 0 || offset.left > viewportSize.width) { hiddenMessages.push(el) } else { needToScroll = false } }); if (needToScroll) { Effect.ScrollTo(validationMessages[0], { duration: 1, offset: -20 }) } return } checkout.setLoadWaiting(true); var params = Form.serialize(this.form); $('review-please-wait').show(); var request = new Ajax.Request(this.saveUrl, { method: 'post', parameters: params, onSuccess: this.setResponse.bind(this), onFailure: this.ajaxFailure.bind(this) }) }, update: function (params) { var parameters = $(this.form).serialize(true); for (var i in params) { if (!params[i]) { continue } var obj = $('checkout-' + i + '-load'); if (obj != null) { var size = obj.getDimensions(); obj.setStyle({ 'width': size.width + 'px', 'height': size.height + 'px' }).update('').addClassName('loading'); parameters[i] = params[i] } } checkout.setLoadWaiting(true); var request = new Ajax.Request(this.updateUrl, { method: 'post', onSuccess: this.setResponse.bind(this), onFailure: this.ajaxFailure.bind(this), parameters: parameters }) }, setResponse: function (response) { response = response.responseText.evalJSON(); if (response.redirect) { location.href = check_secure_url(response.redirect); return true } if (response.order_created) { window.location = this.successUrl; return } else if (response.error_messages) { var msg = response.error_messages; if (typeof (msg) == 'object') { msg = msg.join("\n") } alert(msg) } checkout.setLoadWaiting(false); $('review-please-wait').hide(); if (response.update_section) { for (var i in response.update_section) { ch_obj = $('checkout-' + i + '-load'); if (ch_obj != null) { ch_obj.setStyle({ 'width': 'auto', 'height': 'auto' }).update(response.update_section[i]).setOpacity(1).removeClassName('loading'); if (i === 'shipping-method') { shippingMethod.addObservers() } } } } if (response.duplicateBillingInfo) { shipping.syncWithBilling() } if (response.reload_totals) { checkout.update({ 'review': 1 }) } return false }, blockform: function () { $(this.form).remove(); return false } }; var BillingAddress = Class.create(); BillingAddress.prototype = { initialize: function () { $('billing:country_id') && $('billing:country_id').observe('change', function () { if ($('billing:region_id')) {function resetRegionId() { $('billing:region_id').value = ''; $('billing:region_id')[0].selected = true } resetRegionId.delay(0.2) } if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) { shipping.syncWithBilling() } checkout.update({ 'payment-method': 1, 'shipping-method': !$('shipping:same_as_billing') || $('shipping:same_as_billing').checked ? 1 : 0 }) }); $('billing_customer_address') && $('billing_customer_address').observe('change', function () { if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) { shipping.syncWithBilling() } checkout.update({ 'payment-method': 1, 'shipping-method': !$('shipping:same_as_billing') || $('shipping:same_as_billing').checked ? 1 : 0 }) }); $('billing:region_id') && $('billing:region_id').observe('change', function () { if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) { shipping.syncWithBilling(); checkout.update({ 'review': 1 }) } else if (!$('shipping:same_as_billing')) { checkout.update({ 'review': 1 }) } }); $('billing:postcode') && $('billing:postcode').observe('change', function () { if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) { shipping.syncWithBilling(); checkout.update({ 'review': 1 }) } else if (!$('shipping:same_as_billing')) { checkout.update({ 'review': 1 }) } }) }, newAddress: function (isNew) { if (isNew) { this.resetSelectedAddress(); Element.show('bill_form') } else { Element.hide('bill_form') } }, resetSelectedAddress: function () { var selectElement = $('billing_customer_address'); if (selectElement) { selectElement.value = '' } }, setCreateAccount: function (flag) { if (flag) { $('register-customer-password').show() } else { $('register-customer-password').hide() } } }; var ShippingAddress = Class.create(); ShippingAddress.prototype = { initialize: function (form) { this.form = form; $('shipping:country_id') && $('shipping:country_id').observe('change', function () { if ($('shipping:region_id')) { $('shipping:region_id').value = ''; $('shipping:region_id')[0].selected = true } checkout.update({ 'shipping-method': 1 }) }); $('shipping_customer_address') && $('shipping_customer_address').observe('change', function () { checkout.update({ 'shipping-method': 1 }) }); $('shipping:region_id') && $('shipping:region_id').observe('change', function () { checkout.update({ 'review': 1 }) }); $('shipping:postcode') && $('shipping:postcode').observe('change', function () { checkout.update({ 'review': 1 }) }) }, newAddress: function (isNew) { if (isNew) { this.resetSelectedAddress(); Element.show('ship_form') } else { Element.hide('ship_form') } }, resetSelectedAddress: function () { var selectElement = $('shipping_customer_address'); if (selectElement) { selectElement.value = '' } }, setSameAsBilling: function (flag) { $('shipping:same_as_billing').checked = flag; $('billing:use_for_shipping').value = flag ? 1 : 0; if (flag) { $('ship_address_block').hide(); this.syncWithBilling(); checkout.update({ 'shipping-method': 1 }) } else { $('ship_address_block').show() } }, syncWithBilling: function () { $('billing_customer_address') && this.newAddress(!$('billing_customer_address').value); $('shipping:same_as_billing').checked = true; $('billing:use_for_shipping').value = 1; if (!$('billing_customer_address') || !$('billing_customer_address').value) { arrElements = Form.getElements(this.form); for (var elemIndex in arrElements) { if (arrElements[elemIndex].id) { var sourceField = $(arrElements[elemIndex].id.replace(/^shipping:/, 'billing:')); if (sourceField) { arrElements[elemIndex].value = sourceField.value } } } shippingRegionUpdater.update(); $('shipping:region_id').value = $('billing:region_id').value; $('shipping:region').value = $('billing:region').value } else { $('shipping_customer_address').value = $('billing_customer_address').value } }, setRegionValue: function () { $('shipping:region').value = $('billing:region').value } }; var ShippingMethod = Class.create(); ShippingMethod.prototype = { initialize: function () { this.addObservers() }, addObservers: function () { $$('input[name="shipping_method"]').each(function (el) { el.observe('click', function () { checkout.update({ 'review': 1
}; var Payment = Class.create(); Payment.prototype = { beforeInitFunc: $H({}), afterInitFunc: $H({}), beforeValidateFunc: $H({}), afterValidateFunc: $H({}), initialize: function (container) { this.cnt = container }, addBeforeInitFunction: function (code, func) { this.beforeInitFunc.set(code, func) }, beforeInit: function () { (this.beforeInitFunc).each(function (init) { (init.value)() }) }, addObservers: function () { $$('input[name="payment[method]"]').each(function (el) { el.observe('click', function () { checkout.update({ 'payment-method': 1
}; OPC.Messenger = { add: function (message, section, type) { var s_obj = $(section); if (s_obj != null) { var ul = $(section).select('.messages')[0]; if (!ul) { $(section).insert({ top: '
' }); ul = $(section).select('.messages')[0] } var li = $(ul).select('.' + type + '-msg')[0]; if (!li) { $(ul).insert({ top: '}; function open_login() { $('onepagecheckout_forgotbox').hide(); $('onepagecheckout_loginbox').show() }function open_forgot() { $('onepagecheckout_loginbox').hide(); $('onepagecheckout_forgotbox').show() }function close_login() { $('onepagecheckout_forgotbox').hide(); $('onepagecheckout_loginbox').hide() }function check_secure_url(url) { if (http_type == 'https') { var u1 = url.substr(0, 5); if (u1 != 'https') { if (u1 == 'http:') url = 'https:' + url.substr(5); else url = 'https://' + url } } return url } window.onload = function () { checkout.update({ 'payment-method': 1, 'shipping-method': 1, 'review': 1 }) }