Skip to content

Commit

Permalink
Restore product pack JS
Browse files Browse the repository at this point in the history
  • Loading branch information
firstred committed Jul 23, 2017
1 parent 667ef56 commit 79e9855
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions js/admin/products.js
Expand Up @@ -1194,6 +1194,7 @@ window.product_tabs.Informations = new function () {
};

this.switchProductType = function () {
window.product_type = parseInt(window.product_type, 10);
if (window.product_type === window.product_type_pack) {
$('#pack_product').attr('checked', true);
} else if (window.product_type === window.product_type_virtual) {
Expand All @@ -1204,19 +1205,19 @@ window.product_tabs.Informations = new function () {
$('#simple_product').attr('checked', true);
}

$('input[name="type_product"]').on('click', function (e) {
$('input[name="type_product"]').on('click', function(e) {
// Reset settings
$('a[id*="VirtualProduct"]').hide();

$('#product-pack-container').hide();

$('div.is_virtual_good').hide();
$('#is_virtual').val(0);
window.tabs_manager.onLoad('VirtualProduct', function () {
window.tabs_manager.onLoad('VirtualProduct', function(){
$('#is_virtual_good').removeAttr('checked');
});

window.product_type = $(this).val();
window.product_type = parseInt($(this).val(), 10);
$('#warn_virtual_combinations').hide();
$('#warn_pack_combinations').hide();
// until a product is added in the pack
Expand All @@ -1228,10 +1229,10 @@ window.product_tabs.Informations = new function () {
} else {
$('#product-pack-container').show();
// If the pack tab has not finished loaded the changes will be made when the loading event is triggered
$('#product-tab-content-Pack').bind('loaded', function () {
$('#product-tab-content-Pack').on('loaded', function () {
$('#ppack').val(1).attr('checked', true).attr('disabled', true);
});
$('#product-tab-content-Quantities').bind('loaded', function () {
$('#product-tab-content-Quantities').on('loaded', function () {
$('.stockForVirtualProduct').show();
});

Expand All @@ -1251,19 +1252,19 @@ window.product_tabs.Informations = new function () {
$('a[id*="VirtualProduct"]').show();
$('#is_virtual').val(1);

window.tabs_manager.onLoad('VirtualProduct', function () {
window.tabs_manager.onLoad('VirtualProduct', function() {
$('#is_virtual_good').attr('checked', true);
$('#virtual_good').show();
});

window.tabs_manager.onLoad('Quantities', function () {
window.tabs_manager.onLoad('Quantities', function() {
$('.stockForVirtualProduct').hide();
});

$('a[id*="Combinations"]').hide();
$('a[id*="Shipping"]').hide();

window.tabs_manager.onLoad('Informations', function () {
window.tabs_manager.onLoad('Informations', function() {
$('#condition').attr('disabled', true);
$('#condition option[value=refurbished]').removeAttr('selected');
$('#condition option[value=used]').removeAttr('selected');
Expand All @@ -1281,6 +1282,7 @@ window.product_tabs.Informations = new function () {
handleSaveButtons();
});
};

this.onReady = function () {
loadPack();
self.bindAvailableForOrder();
Expand Down Expand Up @@ -1378,10 +1380,10 @@ window.product_tabs.Pack = new function () {
});

function addPackItem() {
if (window.selectedProduct) {
if (selectedProduct) {
var $curPackItemQty = $('#curPackItemQty');
window.selectedProduct.qty = $curPackItemQty.val();
if (!window.selectedProduct.id || !window.selectedProduct.name && $curPackItemQty.valid()) {
selectedProduct.qty = $curPackItemQty.val();
if ((!selectedProduct.id || !selectedProduct.name) && $curPackItemQty.valid()) {
window.error_modal(window.error_heading_msg, window.msg_select_one);

return false;
Expand Down Expand Up @@ -1424,7 +1426,7 @@ window.product_tabs.Pack = new function () {
$('#curPackItemName').select2('val', '');
$('.pack-empty-warning').hide();
} else {
window.error_modal(error_heading_msg, msg_select_one);
window.error_modal(window.error_heading_msg, window.msg_select_one);

return false;
}
Expand Down

0 comments on commit 79e9855

Please sign in to comment.