Last active
January 29, 2016 12:02
-
-
Save amiskov/591ca51f417687bf89b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ajax = { | |
success: function (data) { | |
if (!data) { | |
alert('Ошибка, сервера.'); | |
return; | |
} | |
if (data.status == 'success') { | |
var shippingMethods = 'shipping_methods', | |
paymentMethods = 'payment_methods', | |
$shippingStep = $('#checkout-step-shipping_method'), | |
$paymentStep = $('#checkout-step-payment'), | |
$reviewTable = $('#checkout-review-load'), | |
$couponBlock = $('#couponBlock'); | |
if (data.content == undefined) { | |
alert('Контент не пришел'); | |
return; | |
} | |
if (data.content[shippingMethods]) { | |
$shippingStep.html(data.content[shippingMethods]); | |
checkoutObj.initShippingForm(); | |
} | |
if (data.content[paymentMethods]) { | |
$paymentStep.html(data.content[paymentMethods]); | |
checkoutObj.initPaymentMethods(); | |
} | |
if (data.content.cart) { | |
$reviewTable.html(data.content.cart); | |
} | |
if (data.content.coupon) { | |
$couponBlock.replaceWith(data.content.coupon); | |
coupon.init(checkoutObj); | |
} | |
} else if ((data.status === 'error') && data.message) { | |
$info.html(data.message).addClass('error'); | |
} | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment