Warning: unlink(/home/storiesfromindia/storage/cache/cache.catalog.language.1764421811): No such file or directory in /home/storiesfromindia/public_html/system/library/cache/file.php on line 68Warning: Cannot modify header information - headers already sent by (output started at /home/storiesfromindia/public_html/system/framework.php:42) in /home/storiesfromindia/public_html/catalog/controller/startup/startup.php on line 99Warning: Cannot modify header information - headers already sent by (output started at /home/storiesfromindia/public_html/system/framework.php:42) in /home/storiesfromindia/public_html/catalog/controller/startup/startup.php on line 157Warning: Cannot modify header information - headers already sent by (output started at /home/storiesfromindia/public_html/system/framework.php:42) in /home/storiesfromindia/public_html/catalog/controller/extension/module/live_product.php on line 614/* This file is subject to the terms and conditions defined in the "EULA.txt" file, which is part of this source code package and is also available on the page: https://raw.githubusercontent.com/ocmod-space/license/main/EULA.txt. */ 'use strict'; var g_product_id = String('345'); var g_duration = Number('0'); var g_log = Boolean(Number('')); var g_quantity_buttons = Boolean(Number('')); var g_product_total = Boolean(Number('')); var g_content_id; var g_price_id; var g_special_id; var g_discount_id; var g_tax_id; var g_points_id; var g_reward_id; var g_option_id; var tag_quantity; var tag_quantity_val; var refreshQty; if (g_log) { console.log('-- Live Product+ > Start...'); } if ($(g_content_id + ' input[name="quantity"]').length) { tag_quantity = 'input[name="quantity"]'; tag_quantity_val = $(tag_quantity).val(); if (g_quantity_buttons) { let prev_qty = Number($(tag_quantity).val()) || 1; let next_qty; refreshQty = setInterval(function() { next_qty = Number($(tag_quantity).val()) || 1; if (isNaN(prev_qty) || isNaN(next_qty)) { clearInterval(refreshQty); } else { if (prev_qty != next_qty) { update(); } prev_qty = next_qty; } }, 100); } else { $(document).off('input paste change', tag_quantity).on('input paste change', tag_quantity, function (ev) { update(); }); } } else if ($(g_content_id + ' select[name="quantity"]').length) { tag_quantity = 'select[name="quantity"]'; tag_quantity_val = $(tag_quantity + ' option:selected').val(); $(document).off('change', tag_quantity).on('change', tag_quantity, function (ev) { update(); }); } else { tag_quantity = '[name="quantity"]'; tag_quantity_val = $(tag_quantity).val(); $(document).off('input paste change', tag_quantity).on('input paste change', tag_quantity, function (ev) { update(); }); } var tags_options = [ '[id^="input-option"] input[type="checkbox"]', '[id^="input-option"] input[type="radio"]', 'select[id^="input-option"]', ]; $(document).off('change', tags_options.join(',')).on('change', tags_options.join(','), function (ev) { update(); }); $(document).ready(function() { // Force update product price after page onload if (tag_quantity_val) { update(); } }); function update() { setGTags(); var url = 'index.php?route=extension/module/live_product&id=' + g_product_id; var tags_post_data = [ g_content_id + '[id^="input-option"] input[type="checkbox"]:checked', g_content_id + '[id^="input-option"] input[type="radio"]:checked', g_content_id + 'select[id^="input-option"]', g_content_id + 'input[type="hidden"]', g_content_id + 'input[type="number"]', g_content_id + 'input[type="text"]', g_content_id + '[name="quantity"]', ]; var data = $(tags_post_data.join(',')); $.ajax({ type: 'POST', url: url, data: data, dataType: 'json', beforeSend: function () {}, complete: function () { tags_post_data = null; }, success: function (json) { if (json.success) { showSummary(json); showOptions(json); if (g_log) { console.log('-- Live Product+ > ajax response:'); console.dir(json); } } else { if (g_log) { console.log('-- Live Product+ > something wrong:'); console.dir(json); } } }, error: function (error) { console.log('-- Live Product+ > ajax error:'); console.dir(error); } }); }; function setGTags() { g_content_id = 'content'; if (g_content_id) { g_content_id = '#' + g_content_id +' '; } g_price_id = g_content_id + '#live-price'; g_special_id = g_content_id + '#live-special'; g_discount_id = g_content_id + '#live-discount'; g_tax_id = g_content_id + '#live-tax'; g_points_id = g_content_id + '#live-points'; g_reward_id = g_content_id + '#live-reward'; g_option_id = g_content_id + '#live-option'; } // Update summary info on product page function showSummary(json) { showEl(g_price_id, json.product.price); if (json.product.special) { showEl(g_special_id, json.product.special); } if (json.product.extax) { showEl(g_tax_id, json.product.extax); } if (json.product.reward) { showEl(g_reward_id, json.product.reward); } if (json.product.points) { showEl(g_points_id, json.product.points); } if (json.product.discounts) { for (let qty in json.product.discounts) { showEl(g_discount_id + '-' + qty, json.product.discounts[qty]); } if (json.product.discount_qty) { $(g_content_id + ' [id^="live-discount-"]') .css('font-weight', 'normal') .css('color', 'inherit'); $(g_discount_id + '-' + json.product.discount_qty) .css('font-weight', 'bold') .css('color', 'red'); } else { $(g_content_id + ' [id^="live-discount-"]') .css('font-weight', 'normal') .css('color', 'inherit'); } } } // Show available options on product page function showOptions(json) { if (json.product.options) { // IE11 fix: json.product.options.forEach(option => { [].forEach.call(json.product.options, function (option) { if (option.type === 'checkbox' || option.type === 'radio' || option.type === 'select') { let option_id = option.product_option_id; let option_type = option.type; // IE11 fix: option.product_option_value.forEach(option_value => { [].forEach.call(option.product_option_value, function (option_value) { let id = g_option_id + '-' + option_id + '-' + option_value.product_option_value_id; let text = ''; // text = option_value._price ? '(' + option_value._price + ')' : text; text = option_value.price ? '(' + option_value.price + ')' : text; text = (option_type === 'select') ? [option_value.name, text].join(' ') : text; showEl(id, text); }); } }); } } function showEl(el, content) { if (content && $(el).length) { if (content != $(el).html()) { $(el).fadeOut(0, function () { $(this) .html(content) .fadeIn(g_duration); }); } } else { $(el).fadeOut(g_duration, function () { $(this).empty(); }); } } function htmlDecode(value) { return $("