Re: Dynamic Price Updater
Quote:
Originally Posted by
mc12345678
This is more than likely a jQuery related issue which is a different set of skills than php. :) If can identify what those changes were, perhaps they could be identified as helpful or otherwise further corrected.
Ah! I wouldn't know at all about that.
These are the files I mentioned we modified back then.
includes/modules/pages/product_info/jscript_dynamic_price_updater.php
PHP Code:
<?php
/**
* @package Dynamic Price Updater
* @copyright Dan Parry (Chrome) / Erik Kerkhoven (Design75)
* @original author Dan Parry (Chrome)
* @version 3.0
* @licence This module is released under the GNU/GPL licence
*/
if (defined('DPU_STATUS') && DPU_STATUS === 'true') {
$load = true; // if any of the PHP conditions fail this will be set to false and DPU won't be fired up
$pid = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0);
if (0 == $pid) {
$load = false;
} elseif (zen_get_products_price_is_call($pid) || zen_get_products_price_is_free($pid) || STORE_STATUS > 0) {
$load = false;
}
$pidp = zen_get_products_display_price($pid);
if (empty($pidp)) {
$load = false;
}
if ($load) {
if (!defined('DPU_PRODUCTDETAILSLIST_PRODUCT_INFO_QUANTITY')) define('DPU_PRODUCTDETAILSLIST_PRODUCT_INFO_QUANTITY', 'productDetailsList_product_info_quantity');
?>
<script type="text/javascript">
// <![CDATA[
// Set some global vars
var theFormName = "<?php echo DPU_PRODUCT_FORM; ?>";
var theForm = false;
var theURL = "<?php echo DIR_WS_CATALOG; ?>ajax.php";
// var theURL = "<?php echo DIR_WS_CATALOG; ?>dpu_ajax.php";
var _secondPrice = <?php echo (DPU_SECOND_PRICE !== '' ? '"' . DPU_SECOND_PRICE . '"' : 'false'); ?>;
var objSP = false; // please don't adjust this
var DPURequest = [];
// Updater sidebox settings
var objSB = false;<?php // this holds the sidebox object // IE. Left sidebox false should become document.getElementById('leftBoxContainer');
// For right sidebox, this should equal document.getElementById('rightBoxContainer');
// Perhaps this could be added as an additional admin configuration key. The result should end up being that a new SideBox is added
// before whatever is described in this "search". So this may actually need to be a div within the left or right boxes instead of the
// left or right side box.
// May also be that this it is entirely unnecessary to create a sidebox when one could already exist based on the file structure.
if (DPU_SHOW_LOADING_IMAGE === 'true') { // create the JS object for the loading image ?>
var imgLoc = "replace"; // Options are "replace" or , "" (empty)
var origPrice;
var loadImg = document.createElement("img");
loadImg.src = "<?php echo DIR_WS_IMAGES; ?>ajax-loader.gif";
loadImg.id = "DPULoaderImage";
var loadImgSB = document.createElement("img");
loadImgSB.src = "<?php echo DIR_WS_IMAGES; ?>ajax-loader.gif";
loadImgSB.id = "DPULoaderImageSB";
loadImgSB.style.margin = "auto";
// loadImg.style.display = 'none';
<?php } ?>
function objXHR() { // scan the function clicked and act on it using the Ajax interthingy
var url; // URL to send HTTP DPURequests to
var timer; // timer for timing things
var XHR; // XMLHttpDPURequest object
var responseXML; // holds XML formed responses from the server
var responseText; // holds any textual response from the server
// var DPURequest = []; // associative array to hold DPURequests to be sent
// DPURequest = new Array();
this.createXHR();
}
objXHR.prototype.createXHR = function () { // this code has been modified from the Apple developers website
this.XHR = false;
// branch for native XMLHttpDPURequest object
if(window.XMLHttpRequest) { // decent, normal, law abiding browsers
try { // make sure the object can be created
this.XHR = new XMLHttpRequest();
} catch(e) { // it can't
this.XHR = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) { // this does stuff too
var tryNext = false;
try {
this.XHR = new ActiveXObject("Msxml2.XMLHTTP");
} catch(f) {
tryNext = true;
}
if (tryNext) {
try {
this.XHR = new ActiveXObject("Microsoft.XMLHTTP");
} catch(g) {
this.XHR = false;
}
}
}
};
objXHR.prototype.getData = function(strMode, resFunc, combinedData) { // send a DPURequest to the server in either GET or POST
strMode = (strMode.toLowerCase() === "post" ? "post" : "get");
var _this = this; // scope resolution
if (((typeof zcJS === "undefined" || !zcJS) ? this.XHR : zcJS)) {
if (typeof zcJS === "undefined" || !zcJS) {
this.createXHR();
this.XHR.onreadystatechange = function () {
if (_this.XHR.readyState === 4) {
// only if "OK"
if (_this.XHR.status === 200) {
_this.responseXML = _this.XHR.responseXML;
_this.responseText = _this.XHR.responseText;
_this.responseHandler(resFunc, _this);
} else {
console.log("Status returned - " + _this.XHR.statusText);
}
}
};
this.XHR.open(strMode.toLowerCase(), "<?php echo zen_decode_specialchars(zen_href_link('ajax.php', zen_get_all_get_params(array('action','pid')) . 'act=DPU_Ajax&method=dpu_update', $request_type, true, true, true)); ?>" + (strMode.toLowerCase() === "get" ? "&" + this.compileRequest() : ""), true);
/* this.XHR.open(strMode.toLowerCase(), this.url+"?act=DPU_Ajax&method=dpu_update"+(strMode.toLowerCase() == "get" ? "&" + this.compileRequest() : ""), true);*/
if (strMode.toLowerCase() === "post") {
this.XHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
this.XHR.setRequestHeader("X-Requested-With", "XMLHttpRequest");
}
this.XHR.send(combinedData.XML);
} else {
var option = {
url: "<?php echo zen_decode_specialchars(zen_href_link('ajax.php', zen_get_all_get_params(array('action','pid')) . 'act=DPU_Ajax&method=dpu_update', $request_type, true, true, true)); ?>",
data: combinedData.JSON,
timeout : 30000
};
zcJS.ajax(option).done(
function (response,textStatus,jqXHR) {
_this.responseJSON = jqXHR.responseJSON;
_this.responseText = jqXHR.responseText;
if (!_this.responseJSON && _this.responseText) {
try {
_this.responseJSON = JSON.parse(_this.responseText);
} catch (e) {
console.log(e.stack);
}
}
_this.responseHandler(resFunc, _this);
}
).fail( function(jqXHR,textStatus,errorThrown) {
<?php if (DPU_SHOW_LOADING_IMAGE === 'true') { ?>
var thePrice = document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>");
var test = thePrice.getElementsByTagName("span");
var psp = false;
var a;
var b = test.length;
for (a = 0; a < b; a += 1) {
if (test[a].className === "productSpecialPrice" || test[a].className === "productSalePrice" || test[a].className === "productSpecialPriceSale") {
psp = test[a];
}
}
if (typeof(loadImg) !== "undefined" && loadImg.parentNode !== null && loadImg.parentNode.id === thePrice.id && imgLoc !== "replace") {
if (psp) {
psp.removeChild(loadImg);
} else {
thePrice.removeChild(loadImg);
}
} else if (typeof(loadImg) !== "undefined" && imgLoc === "replace") {
_this.updateInnerHTML(origPrice, psp, thePrice);
}
if (_secondPrice !== false) {
_this.updSP();
}
<?php } ?>
//alert("Status returned - " + textStatus);
});
}
} else {
var mess = "I couldn't contact the server!\n\nIf you use IE please allow ActiveX objects to run";
alert (mess);
}
};
objXHR.prototype.compileRequest = function () {
// parse the DPURequest array into a URL encoded string
var ret = ""; // return DPURequest string
var e;
for (e in DPURequest) {
ret += e + "=" + DPURequest[e] + "&";
}
return (ret.substr(0, ret.length - 1));
};
objXHR.prototype.responseHandler = function (theFunction, results) { // redirect responses from the server to the right function
DPURequest = new Array();
this[theFunction](results); // Eliminates concern of improper evaluation; however, does limit the response value(s)
};
objXHR.prototype.getPrice = function () {
var pspClass = false;
<?php if (DPU_SHOW_LOADING_IMAGE === 'true') { ?>
var psp = false;
// if (imgLoc === "replace") {
var thePrice = document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>");
var test = false;
if (thePrice) {
test = thePrice.getElementsByTagName("span");
}
var a;
var b = test.length;
for (a = 0; a < b; a += 1) {
if (test[a].className === "productSpecialPrice" || test[a].className === "productSalePrice" || test[a].className === "productSpecialPriceSale") {
psp = test[a];
}
}
if (!psp) {
psp = thePrice;
}
if (psp) {
pspClass = psp.className;
origPrice = psp.innerHTML;
}
// }
if (psp && imgLoc === "replace") {
if (thePrice) {
loadImg.style.display = "inline"; //'block';
// pspClass = psp.className;
var pspStyle = psp.currentStyle || window.getComputedStyle(psp);
loadImg.style.height = pspStyle.lineHeight; // Maintains the height so that there is not a vertical shift of the content.
origPrice = psp.innerHTML;
this.updateInnerHTML(loadImg.outerHTML, false, psp, true);
}
} else {
document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>").appendChild(loadImg);
}
if (document.getElementById("dynamicpriceupdatersidebox")) {
var theSB = document.getElementById("dynamicpriceupdatersideboxContent");
// theSB.innerHTML = "";
this.updateInnerHTML("", false, theSB, true);
theSB.style.textAlign = "center";
theSB.appendChild(loadImgSB);
}
<?php } ?>
this.url = theURL;
var n=theForm.elements.length;
var temp = "";
var jsonData = {};
var combinedData = {};
var el;
var i;
for (i = 0; i < n; i += 1) {
el = theForm.elements[i];
switch (el.type) { <?php /* I'm not sure this even needed as a switch; testing needed*/ ?>
case "select":
case "select-one":
case "textarea":
case "text":
case "number":
case "hidden":
temp += el.name+"="+encodeURIComponent(el.value)+"&";
if (!(el.name in jsonData)) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
jsonData[el.name] = el.value;
}
break;
case "checkbox":
case "radio":
if (true === el.checked) {
temp += el.name+"="+encodeURIComponent(el.value)+"&";
if (!(el.name in jsonData)) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
jsonData[el.name] = el.value;
}
}
break;
}
}
if (!("products_id" in jsonData)) {
temp += "products_id=<?php echo (int)$pid; ?>&";
jsonData.products_id = <?php echo (int)$pid; ?>;
}
if (pspClass) {
temp += "pspClass="+encodeURIComponent(pspClass)+"&";
jsonData.pspClass = pspClass;
}
temp += "stat=main&";
jsonData.stat = "main";
temp += "outputType=XML&";
jsonData.outputType = "JSON";
temp = temp.substr(0, temp.length - 1);
combinedData.XML = temp;
combinedData.JSON = jsonData;
this.getData("post", "handlePrice", combinedData);
//temp = temp.substr(0, temp.length - 1)
//this.getData("post", "handlePrice", temp);
};
objXHR.prototype.updateInnerHTML = function (storeVal, psp, obj, replace) {
if (typeof(replace) === "undefined") {
replace = true;
}
if (storeVal !== "") {
if (psp) {
if (replace) {
psp.innerHTML = storeVal;
} else {
psp.innerHTML += storeVal;
}
} else {
if (replace) {
obj.innerHTML = storeVal;
} else {
obj.innerHTML += storeVal;
}
}
if (_secondPrice !== false) {
this.updSP();
}
}
};
objXHR.prototype.handlePrice = function (results) {
var thePrice = document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>");
if (typeof(loadImg) !== "undefined" && loadImg.parentNode !== null && loadImg.parentNode.id === thePrice.id && imgLoc !== "replace") {
thePrice.removeChild(loadImg);
}
// use the spans to see if there is a discount occuring up in this here house
var test = thePrice.getElementsByTagName("span");
var psp = false;
var a;
var b = test.length;
var pdpt = false;
for (a = 0; a < b; a += 1) {
if (test[a].className === "normalprice") {
pdpt = test[a];
}
if (test[a].className === "productSpecialPrice" || test[a].className === "productSalePrice" || test[a].className === "productSpecialPriceSale") {
psp = test[a];
}
}
// var type = this.responseXML.getElementsByTagName("responseType")[0].childNodes[0].nodeValue;
var type;
var updateSidebox;
if (results.responseXML) {
type = results.responseXML.getElementsByTagName("responseType")[0].childNodes[0].nodeValue;
} else if (results.responseJSON) {
type = results.responseJSON.responseType;
}
if (document.getElementById("dynamicpriceupdatersidebox")) {
var theSB = document.getElementById("dynamicpriceupdatersideboxContent");
theSB.style.textAlign = "left";
var sbContent = "";
updateSidebox = true;
} else {
updateSidebox = false;
}
if (type === "error") {
this.showErrors();
} else {
// var temp = this.responseXML.getElementsByTagName("responseText");
var temp;
if (results.responseXML) {
temp = results.responseXML.getElementsByTagName("responseText");
} else if (results.responseJSON) {
temp = results.responseJSON.data;
}
/* for(var i=0, n=temp.length; i<n; i++) {
var type = temp[i].getAttribute("type");*/
var storeVal;
var i;
for(i in temp) {
if (results.responseXML) {
if (!(temp.hasOwnProperty(i))) {
continue;
}
type = temp[i].getAttribute("type");
storeVal = temp[i].childNodes[0].nodeValue;
} else if (results.responseJSON) {
type = i;
storeVal = temp[i];
}
switch (type) {<?php // the 'type' attribute defines what type of information is being provided ?>
case "preDiscPriceTotal":
if (pdpt) {
this.updateInnerHTML(storeVal, pdpt, thePrice, true);
}
break;
case "preDiscPriceTotalText":
if (pdpt) {
// $(thePrice).contents().first()[0].textContent = storeVal;
if (thePrice.firstChild.nodeType === 3) {
thePrice.firstChild.nodeValue = storeVal;
}
}
break;
case "priceTotal":
/*if (psp) {
psp.innerHTML = temp[i].childNodes[0].nodeValue;
} else {
thePrice.innerHTML = temp[i].childNodes[0].nodeValue;
}
if (_secondPrice !== false) {
this.updSP();
}*/
this.updateInnerHTML(storeVal, psp, thePrice, true);
break;
case "quantity":
/* with (temp[i].childNodes[0]) {
if (nodeValue != "") {
if (psp) {
psp.innerHTML += nodeValue;
} else {
thePrice.innerHTML += nodeValue;
}
this.updSP();
}
}*/
this.updateInnerHTML(storeVal, psp, thePrice, false);
break;
case "weight":
var theWeight = document.getElementById("<?php echo DPU_WEIGHT_ELEMENT_ID; ?>");
if (theWeight) {
// theWeight.innerHTML = temp[i].childNodes[0].nodeValue;
this.updateInnerHTML(storeVal, false, theWeight, true);
}
break;
case "sideboxContent":
if (updateSidebox) {
// sbContent += temp[i].childNodes[0].nodeValue;
sbContent += storeVal;
}
break;
case "stock_quantity":
var theStockQuantity = document.getElementById("<?php echo DPU_PRODUCTDETAILSLIST_PRODUCT_INFO_QUANTITY; ?>");
if (theStockQuantity) {
this.updateInnerHTML(storeVal, false, theStockQuantity, true);
}
break;
}
}
}
if (updateSidebox) {
// theSB.innerHTML = sbContent;
this.updateInnerHTML(sbContent, false, theSB, true);
}
};
objXHR.prototype.updSP = function () {
// adjust the second price display; create the div if necessary
var flag = false; // error tracking flag
if (_secondPrice !== false) { // second price is active
var centre = document.getElementById("productGeneral");
var temp = document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>");
var itemp = document.getElementById(_secondPrice);
flag = false;
if (objSP === false) { // create the second price object
if (!temp || !itemp) {
flag = true;
}
if (!flag) {
objSP = temp.cloneNode(true);
objSP.id = temp.id + "Second";
itemp.parentNode.insertBefore(objSP, itemp.nextSibling);
}
}
objSP.innerHTML = temp.innerHTML;
}
};
<?php
$show_dynamic_price_updater_sidebox = true;
if ($show_dynamic_price_updater_sidebox === true)
{
?>
objXHR.prototype.createSB = function () { // create the sidebox for the attributes info display
if (!(document.getElementById("dynamicpriceupdatersidebox")) && objSB) {
var tempC = document.createElement("div");
tempC.id = "dynamicpriceupdatersideboxContent";
tempC.className = "sideBoxContent";
tempC.innerHTML = "If you can read this Chrome has broken something";
objSB.appendChild(tempC);
temp.parentNode.insertBefore(objSB, temp);
}
};
<?php
}
?>
objXHR.prototype.showErrors = function () {
// var errorText = this.responseXML.getElementsByTagName("responseText");
var alertText = "";
var errVal;
var errorText;
var i;
if (typeof zcJS === "undefined" || !zcJS) {
errorText = this.responseXML.getElementsByTagName("responseText");
} else {
errorText = this.responseJSON.responseText;
}
//var n=errorText.length;
for (i in errorText/*var i=0; i<n; i++*/) {
if (!(errorText.hasOwnProperty(i))) {
continue;
}
if (typeof zcJS === "undefined" || !zcJS) {
errVal = errorText[i].childNodes[0].nodeValue;
} else {
errVal = i;
}
alertText += "\n- "+errVal;
}
alert ("Error! Message reads:\n\n"+alertText);
};
var xhr = new objXHR;
function init() {
var n=document.forms.length;
var i;
for (i = 0; i < n; i += 1) {
if (document.forms[i].name === theFormName) {
theForm = document.forms[i];
//continue; // Unnecessary though had originally thought of building more into this area.
}
}
n=theForm.elements.length;
for (i = 0; i < n; i += 1) {
switch (theForm.elements[i].type) {
case "select":
case "select-one":
theForm.elements[i].addEventListener("change", function () {
xhr.getPrice();
});
break;
case "textarea":
case "text":
theForm.elements[i].addEventListener("input", function () {
xhr.getPrice();
});
break;
case "checkbox":
case "radio":
theForm.elements[i].addEventListener("click", function () {
xhr.getPrice();
});
break;
case "number":
theForm.elements[i].addEventListener("change", function () {
xhr.getPrice();
});
theForm.elements[i].addEventListener("keyup", function () {
xhr.getPrice();
});
theForm.elements[i].addEventListener("input", function () {
xhr.getPrice();
});
break;
}
}
<?php
$show_dynamic_price_updater_sidebox = true;
if ($show_dynamic_price_updater_sidebox === true)
{
?>
xhr.createSB();
<?php
}
?>
xhr.getPrice();
}
<?php
// the following statements should allow multiple onload handlers to be applied
// I know this type of event registration is technically deprecated but I decided to use it because I haven't before
// There shouldn't be any fallout from the downsides of this method as only a single function is registered (and in the bubbling phase of each model)
// For backwards compatibility I've included the traditional DOM registration method ?>
<?php /*try { // the IE event registration model
window.attachEvent('onload', init);
} catch (e) { // W3C event registration model
window.addEventListener('load', init, false);
} finally {
window.onload = init;
}*/ ?>
// ]]></script>
<?php
}
}
1 Attachment(s)
Re: Dynamic Price Updater
The other file was too big to insert in the comments area
includes/classes/dynamic_price_updater.php
Attachment 19926
I don't believe we changed any other files, but I'll look just to make sure.
Re: Dynamic Price Updater
Quote:
Originally Posted by
mvstudio
Ah! I wouldn't know at all about that.
These are the files I mentioned we modified back then.
includes/modules/pages/product_info/jscript_dynamic_price_updater.php
PHP Code:
<?php
/**
* @package Dynamic Price Updater
* @copyright Dan Parry (Chrome) / Erik Kerkhoven (Design75)
* @original author Dan Parry (Chrome)
* @version 3.0
* @licence This module is released under the GNU/GPL licence
*/
if (defined('DPU_STATUS') && DPU_STATUS === 'true') {
$load = true; // if any of the PHP conditions fail this will be set to false and DPU won't be fired up
$pid = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0);
if (0 == $pid) {
$load = false;
} elseif (zen_get_products_price_is_call($pid) || zen_get_products_price_is_free($pid) || STORE_STATUS > 0) {
$load = false;
}
$pidp = zen_get_products_display_price($pid);
if (empty($pidp)) {
$load = false;
}
if ($load) {
if (!defined('DPU_PRODUCTDETAILSLIST_PRODUCT_INFO_QUANTITY')) define('DPU_PRODUCTDETAILSLIST_PRODUCT_INFO_QUANTITY', 'productDetailsList_product_info_quantity');
?>
<script type="text/javascript">
// <=!=[=C=D=A=T=A=[
// Set some global vars
var theFormName = "<?php echo DPU_PRODUCT_FORM; ?>";
var theForm = false;
var theURL = "<?php echo DIR_WS_CATALOG; ?>ajax.php";
// var theURL = "<?php echo DIR_WS_CATALOG; ?>dpu_ajax.php";
var _secondPrice = <?php echo (DPU_SECOND_PRICE !== '' ? '"' . DPU_SECOND_PRICE . '"' : 'false'); ?>;
var objSP = false; // please don't adjust this
var DPURequest = [];
// Updater sidebox settings
var objSB = false;<?php // this holds the sidebox object // IE. Left sidebox false should become document.getElementById('leftBoxContainer');
// For right sidebox, this should equal document.getElementById('rightBoxContainer');
// Perhaps this could be added as an additional admin configuration key. The result should end up being that a new SideBox is added
// before whatever is described in this "search". So this may actually need to be a div within the left or right boxes instead of the
// left or right side box.
// May also be that this it is entirely unnecessary to create a sidebox when one could already exist based on the file structure.
if (DPU_SHOW_LOADING_IMAGE === 'true') { // create the JS object for the loading image ?>
var imgLoc = "replace"; // Options are "replace" or , "" (empty)
var origPrice;
var loadImg = document.createElement("img");
loadImg.src = "<?php echo DIR_WS_IMAGES; ?>ajax-loader.gif";
loadImg.id = "DPULoaderImage";
var loadImgSB = document.createElement("img");
loadImgSB.src = "<?php echo DIR_WS_IMAGES; ?>ajax-loader.gif";
loadImgSB.id = "DPULoaderImageSB";
loadImgSB.style.margin = "auto";
// loadImg.style.display = 'none';
<?php } ?>
function objXHR() { // scan the function clicked and act on it using the Ajax interthingy
var url; // URL to send HTTP DPURequests to
var timer; // timer for timing things
var XHR; // XMLHttpDPURequest object
var responseXML; // holds XML formed responses from the server
var responseText; // holds any textual response from the server
// var DPURequest = []; // associative array to hold DPURequests to be sent
// DPURequest = new Array();
this.createXHR();
}
objXHR.prototype.createXHR = function () { // this code has been modified from the Apple developers website
this.XHR = false;
// branch for native XMLHttpDPURequest object
if(window.XMLHttpRequest) { // decent, normal, law abiding browsers
try { // make sure the object can be created
this.XHR = new XMLHttpRequest();
} catch(e) { // it can't
this.XHR = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) { // this does stuff too
var tryNext = false;
try {
this.XHR = new ActiveXObject("Msxml2.XMLHTTP");
} catch(f) {
tryNext = true;
}
if (tryNext) {
try {
this.XHR = new ActiveXObject("Microsoft.XMLHTTP");
} catch(g) {
this.XHR = false;
}
}
}
};
objXHR.prototype.getData = function(strMode, resFunc, combinedData) { // send a DPURequest to the server in either GET or POST
strMode = (strMode.toLowerCase() === "post" ? "post" : "get");
var _this = this; // scope resolution
if (((typeof zcJS === "undefined" || !zcJS) ? this.XHR : zcJS)) {
if (typeof zcJS === "undefined" || !zcJS) {
this.createXHR();
this.XHR.onreadystatechange = function () {
if (_this.XHR.readyState === 4) {
// only if "OK"
if (_this.XHR.status === 200) {
_this.responseXML = _this.XHR.responseXML;
_this.responseText = _this.XHR.responseText;
_this.responseHandler(resFunc, _this);
} else {
console.log("Status returned - " + _this.XHR.statusText);
}
}
};
this.XHR.open(strMode.toLowerCase(), "<?php echo zen_decode_specialchars(zen_href_link('ajax.php', zen_get_all_get_params(array('action','pid')) . 'act=DPU_Ajax&method=dpu_update', $request_type, true, true, true)); ?>" + (strMode.toLowerCase() === "get" ? "&" + this.compileRequest() : ""), true);
/* this.XHR.open(strMode.toLowerCase(), this.url+"?act=DPU_Ajax&method=dpu_update"+(strMode.toLowerCase() == "get" ? "&" + this.compileRequest() : ""), true);*/
if (strMode.toLowerCase() === "post") {
this.XHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
this.XHR.setRequestHeader("X-Requested-With", "XMLHttpRequest");
}
this.XHR.send(combinedData.XML);
} else {
var option = {
url: "<?php echo zen_decode_specialchars(zen_href_link('ajax.php', zen_get_all_get_params(array('action','pid')) . 'act=DPU_Ajax&method=dpu_update', $request_type, true, true, true)); ?>",
data: combinedData.JSON,
timeout : 30000
};
zcJS.ajax(option).done(
function (response,textStatus,jqXHR) {
_this.responseJSON = jqXHR.responseJSON;
_this.responseText = jqXHR.responseText;
if (!_this.responseJSON && _this.responseText) {
try {
_this.responseJSON = JSON.parse(_this.responseText);
} catch (e) {
console.log(e.stack);
}
}
_this.responseHandler(resFunc, _this);
}
).fail( function(jqXHR,textStatus,errorThrown) {
<?php if (DPU_SHOW_LOADING_IMAGE === 'true') { ?>
var thePrice = document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>");
var test = thePrice.getElementsByTagName("span");
var psp = false;
var a;
var b = test.length;
for (a = 0; a < b; a += 1) {
if (test[a].className === "productSpecialPrice" || test[a].className === "productSalePrice" || test[a].className === "productSpecialPriceSale") {
psp = test[a];
}
}
if (typeof(loadImg) !== "undefined" && loadImg.parentNode !== null && loadImg.parentNode.id === thePrice.id && imgLoc !== "replace") {
if (psp) {
psp.removeChild(loadImg);
} else {
thePrice.removeChild(loadImg);
}
} else if (typeof(loadImg) !== "undefined" && imgLoc === "replace") {
_this.updateInnerHTML(origPrice, psp, thePrice);
}
if (_secondPrice !== false) {
_this.updSP();
}
<?php } ?>
//alert("Status returned - " + textStatus);
});
}
} else {
var mess = "I couldn't contact the server!\n\nIf you use IE please allow ActiveX objects to run";
alert (mess);
}
};
objXHR.prototype.compileRequest = function () {
// parse the DPURequest array into a URL encoded string
var ret = ""; // return DPURequest string
var e;
for (e in DPURequest) {
ret += e + "=" + DPURequest[e] + "&";
}
return (ret.substr(0, ret.length - 1));
};
objXHR.prototype.responseHandler = function (theFunction, results) { // redirect responses from the server to the right function
DPURequest = new Array();
this[theFunction](results); // Eliminates concern of improper evaluation; however, does limit the response value(s)
};
objXHR.prototype.getPrice = function () {
var pspClass = false;
<?php if (DPU_SHOW_LOADING_IMAGE === 'true') { ?>
var psp = false;
// if (imgLoc === "replace") {
var thePrice = document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>");
var test = false;
if (thePrice) {
test = thePrice.getElementsByTagName("span");
}
var a;
var b = test.length;
for (a = 0; a < b; a += 1) {
if (test[a].className === "productSpecialPrice" || test[a].className === "productSalePrice" || test[a].className === "productSpecialPriceSale") {
psp = test[a];
}
}
if (!psp) {
psp = thePrice;
}
if (psp) {
pspClass = psp.className;
origPrice = psp.innerHTML;
}
// }
if (psp && imgLoc === "replace") {
if (thePrice) {
loadImg.style.display = "inline"; //'block';
// pspClass = psp.className;
var pspStyle = psp.currentStyle || window.getComputedStyle(psp);
loadImg.style.height = pspStyle.lineHeight; // Maintains the height so that there is not a vertical shift of the content.
origPrice = psp.innerHTML;
this.updateInnerHTML(loadImg.outerHTML, false, psp, true);
}
} else {
document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>").appendChild(loadImg);
}
if (document.getElementById("dynamicpriceupdatersidebox")) {
var theSB = document.getElementById("dynamicpriceupdatersideboxContent");
// theSB.innerHTML = "";
this.updateInnerHTML("", false, theSB, true);
theSB.style.textAlign = "center";
theSB.appendChild(loadImgSB);
}
<?php } ?>
this.url = theURL;
var n=theForm.elements.length;
var temp = "";
var jsonData = {};
var combinedData = {};
var el;
var i;
for (i = 0; i < n; i += 1) {
el = theForm.elements[i];
switch (el.type) { <?php /* I'm not sure this even needed as a switch; testing needed*/ ?>
case "select":
case "select-one":
case "textarea":
case "text":
case "number":
case "hidden":
temp += el.name+"="+encodeURIComponent(el.value)+"&";
if (!(el.name in jsonData)) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
jsonData[el.name] = el.value;
}
break;
case "checkbox":
case "radio":
if (true === el.checked) {
temp += el.name+"="+encodeURIComponent(el.value)+"&";
if (!(el.name in jsonData)) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
jsonData[el.name] = el.value;
}
}
break;
}
}
if (!("products_id" in jsonData)) {
temp += "products_id=<?php echo (int)$pid; ?>&";
jsonData.products_id = <?php echo (int)$pid; ?>;
}
if (pspClass) {
temp += "pspClass="+encodeURIComponent(pspClass)+"&";
jsonData.pspClass = pspClass;
}
temp += "stat=main&";
jsonData.stat = "main";
temp += "outputType=XML&";
jsonData.outputType = "JSON";
temp = temp.substr(0, temp.length - 1);
combinedData.XML = temp;
combinedData.JSON = jsonData;
this.getData("post", "handlePrice", combinedData);
//temp = temp.substr(0, temp.length - 1)
//this.getData("post", "handlePrice", temp);
};
objXHR.prototype.updateInnerHTML = function (storeVal, psp, obj, replace) {
if (typeof(replace) === "undefined") {
replace = true;
}
if (storeVal !== "") {
if (psp) {
if (replace) {
psp.innerHTML = storeVal;
} else {
psp.innerHTML += storeVal;
}
} else {
if (replace) {
obj.innerHTML = storeVal;
} else {
obj.innerHTML += storeVal;
}
}
if (_secondPrice !== false) {
this.updSP();
}
}
};
objXHR.prototype.handlePrice = function (results) {
var thePrice = document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>");
if (typeof(loadImg) !== "undefined" && loadImg.parentNode !== null && loadImg.parentNode.id === thePrice.id && imgLoc !== "replace") {
thePrice.removeChild(loadImg);
}
// use the spans to see if there is a discount occuring up in this here house
var test = thePrice.getElementsByTagName("span");
var psp = false;
var a;
var b = test.length;
var pdpt = false;
for (a = 0; a < b; a += 1) {
if (test[a].className === "normalprice") {
pdpt = test[a];
}
if (test[a].className === "productSpecialPrice" || test[a].className === "productSalePrice" || test[a].className === "productSpecialPriceSale") {
psp = test[a];
}
}
// var type = this.responseXML.getElementsByTagName("responseType")[0].childNodes[0].nodeValue;
var type;
var updateSidebox;
if (results.responseXML) {
type = results.responseXML.getElementsByTagName("responseType")[0].childNodes[0].nodeValue;
} else if (results.responseJSON) {
type = results.responseJSON.responseType;
}
if (document.getElementById("dynamicpriceupdatersidebox")) {
var theSB = document.getElementById("dynamicpriceupdatersideboxContent");
theSB.style.textAlign = "left";
var sbContent = "";
updateSidebox = true;
} else {
updateSidebox = false;
}
if (type === "error") {
this.showErrors();
} else {
// var temp = this.responseXML.getElementsByTagName("responseText");
var temp;
if (results.responseXML) {
temp = results.responseXML.getElementsByTagName("responseText");
} else if (results.responseJSON) {
temp = results.responseJSON.data;
}
/* for(var i=0, n=temp.length; i<n; i++) {
var type = temp[i].getAttribute("type");*/
var storeVal;
var i;
for(i in temp) {
if (results.responseXML) {
if (!(temp.hasOwnProperty(i))) {
continue;
}
type = temp[i].getAttribute("type");
storeVal = temp[i].childNodes[0].nodeValue;
} else if (results.responseJSON) {
type = i;
storeVal = temp[i];
}
switch (type) {<?php // the 'type' attribute defines what type of information is being provided ?>
case "preDiscPriceTotal":
if (pdpt) {
this.updateInnerHTML(storeVal, pdpt, thePrice, true);
}
break;
case "preDiscPriceTotalText":
if (pdpt) {
// $(thePrice).contents().first()[0].textContent = storeVal;
if (thePrice.firstChild.nodeType === 3) {
thePrice.firstChild.nodeValue = storeVal;
}
}
break;
case "priceTotal":
/*if (psp) {
psp.innerHTML = temp[i].childNodes[0].nodeValue;
} else {
thePrice.innerHTML = temp[i].childNodes[0].nodeValue;
}
if (_secondPrice !== false) {
this.updSP();
}*/
this.updateInnerHTML(storeVal, psp, thePrice, true);
break;
case "quantity":
/* with (temp[i].childNodes[0]) {
if (nodeValue != "") {
if (psp) {
psp.innerHTML += nodeValue;
} else {
thePrice.innerHTML += nodeValue;
}
this.updSP();
}
}*/
this.updateInnerHTML(storeVal, psp, thePrice, false);
break;
case "weight":
var theWeight = document.getElementById("<?php echo DPU_WEIGHT_ELEMENT_ID; ?>");
if (theWeight) {
// theWeight.innerHTML = temp[i].childNodes[0].nodeValue;
this.updateInnerHTML(storeVal, false, theWeight, true);
}
break;
case "sideboxContent":
if (updateSidebox) {
// sbContent += temp[i].childNodes[0].nodeValue;
sbContent += storeVal;
}
break;
case "stock_quantity":
var theStockQuantity = document.getElementById("<?php echo DPU_PRODUCTDETAILSLIST_PRODUCT_INFO_QUANTITY; ?>");
if (theStockQuantity) {
this.updateInnerHTML(storeVal, false, theStockQuantity, true);
}
break;
}
}
}
if (updateSidebox) {
// theSB.innerHTML = sbContent;
this.updateInnerHTML(sbContent, false, theSB, true);
}
};
objXHR.prototype.updSP = function () {
// adjust the second price display; create the div if necessary
var flag = false; // error tracking flag
if (_secondPrice !== false) { // second price is active
var centre = document.getElementById("productGeneral");
var temp = document.getElementById("<?php echo DPU_PRICE_ELEMENT_ID; ?>");
var itemp = document.getElementById(_secondPrice);
flag = false;
if (objSP === false) { // create the second price object
if (!temp || !itemp) {
flag = true;
}
if (!flag) {
objSP = temp.cloneNode(true);
objSP.id = temp.id + "Second";
itemp.parentNode.insertBefore(objSP, itemp.nextSibling);
}
}
objSP.innerHTML = temp.innerHTML;
}
};
<?php
$show_dynamic_price_updater_sidebox = true;
if ($show_dynamic_price_updater_sidebox === true)
{
?>
objXHR.prototype.createSB = function () { // create the sidebox for the attributes info display
if (!(document.getElementById("dynamicpriceupdatersidebox")) && objSB) {
var tempC = document.createElement("div");
tempC.id = "dynamicpriceupdatersideboxContent";
tempC.className = "sideBoxContent";
tempC.innerHTML = "If you can read this Chrome has broken something";
objSB.appendChild(tempC);
temp.parentNode.insertBefore(objSB, temp);
}
};
<?php
}
?>
objXHR.prototype.showErrors = function () {
// var errorText = this.responseXML.getElementsByTagName("responseText");
var alertText = "";
var errVal;
var errorText;
var i;
if (typeof zcJS === "undefined" || !zcJS) {
errorText = this.responseXML.getElementsByTagName("responseText");
} else {
errorText = this.responseJSON.responseText;
}
//var n=errorText.length;
for (i in errorText/*var i=0; i<n; i++*/) {
if (!(errorText.hasOwnProperty(i))) {
continue;
}
if (typeof zcJS === "undefined" || !zcJS) {
errVal = errorText[i].childNodes[0].nodeValue;
} else {
errVal = i;
}
alertText += "\n- "+errVal;
}
alert ("Error! Message reads:\n\n"+alertText);
};
var xhr = new objXHR;
function init() {
var n=document.forms.length;
var i;
for (i = 0; i < n; i += 1) {
if (document.forms[i].name === theFormName) {
theForm = document.forms[i];
//continue; // Unnecessary though had originally thought of building more into this area.
}
}
n=theForm.elements.length;
for (i = 0; i < n; i += 1) {
switch (theForm.elements[i].type) {
case "select":
case "select-one":
theForm.elements[i].addEventListener("change", function () {
xhr.getPrice();
});
break;
case "textarea":
case "text":
theForm.elements[i].addEventListener("input", function () {
xhr.getPrice();
});
break;
case "checkbox":
case "radio":
theForm.elements[i].addEventListener("click", function () {
xhr.getPrice();
});
break;
case "number":
theForm.elements[i].addEventListener("change", function () {
xhr.getPrice();
});
theForm.elements[i].addEventListener("keyup", function () {
xhr.getPrice();
});
theForm.elements[i].addEventListener("input", function () {
xhr.getPrice();
});
break;
}
}
<?php
$show_dynamic_price_updater_sidebox = true;
if ($show_dynamic_price_updater_sidebox === true)
{
?>
xhr.createSB();
<?php
}
?>
xhr.getPrice();
}
<?php
// the following statements should allow multiple onload handlers to be applied
// I know this type of event registration is technically deprecated but I decided to use it because I haven't before
// There shouldn't be any fallout from the downsides of this method as only a single function is registered (and in the bubbling phase of each model)
// For backwards compatibility I've included the traditional DOM registration method ?>
<?php /*try { // the IE event registration model
window.attachEvent('onload', init);
} catch (e) { // W3C event registration model
window.addEventListener('load', init, false);
} finally {
window.onload = init;
}*/ ?>
// ]=]=></script>
<?php
}
}
Effectively there are no changes to this file that "add" value to the existing problem. The change made was to eliminate the CDATA encapsulation on the script. That CDATA was added to permit the file to be parsed as XML... Not an issue with the newer implementation as it is not encapsulated with CDATA and also as far as I can tell is not expected to be parsed as XML.
Re: Dynamic Price Updater
Quote:
Originally Posted by
mvstudio
The other file was too big to insert in the comments area
includes/classes/dynamic_price_updater.php
Attachment 19926
I don't believe we changed any other files, but I'll look just to make sure.
And as for this file, the only change(s) really were in the default text constants (as compared to the master version of the file in github) where that difference may just be "temporary" or recent. I would not expect that difference to really cause an issue though I would suggest checking to see if you have any debug logs generated as a result of using the plugin. I wouldn't be surprised if there is a missing definition that execution of the ajax code may stop and that could be preventing the next step from occurring and leaving the spinning circle... Just an idea...
Note that if no debug logs exist then there may be a separate issue preventing debug logs from being generated/written. I often will then try to force a debug log to be generated just to prove that it *can* happen which validates that the absence of a log is because there isn't a log worthy event occurring... Sort of "backwards" thinking but a logic principle.
Re: Dynamic Price Updater
Quote:
Originally Posted by
mc12345678
And as for this file, the only change(s) really were in the default text constants (as compared to the master version of the file in github) where that difference may just be "temporary" or recent. I would not expect that difference to really cause an issue though I would suggest checking to see if you have any debug logs generated as a result of using the plugin. I wouldn't be surprised if there is a missing definition that execution of the ajax code may stop and that could be preventing the next step from occurring and leaving the spinning circle... Just an idea...
Note that if no debug logs exist then there may be a separate issue preventing debug logs from being generated/written. I often will then try to force a debug log to be generated just to prove that it *can* happen which validates that the absence of a log is because there isn't a log worthy event occurring... Sort of "backwards" thinking but a logic principle.
Oh, and absent all of that logging issue/problem, while the initial claim was that this happened under version "3", was corrected and now is happening in version "4", indicates that if all else is good and correct (page validates, java code is sound, no php errors), then there is some problem with the way the data is being "handled" or processed that needs to be corrected... The fun part of that is figuring out what is erroring or not processing, when, and why...
Ideally though, perhaps you find some other modification had been made to the "older" site to make this work. It really could also be outside the scope of the plugin and instead something in another file that had to be modified to function. I saw that there were a lot of other scripts available/executed on the product page. Again I didn't have access to appropriate tools to follow the program flow to be able to see if one of other plugins might cause an issue with this... I mean, even loading sequence of those other plugins could make a difference as well... Etc...
Re: Dynamic Price Updater
Quote:
Originally Posted by
mc12345678
Oh, and absent all of that logging issue/problem, while the initial claim was that this happened under version "3", was corrected and now is happening in version "4", indicates that if all else is good and correct (page validates, java code is sound, no php errors), then there is some problem with the way the data is being "handled" or processed that needs to be corrected... The fun part of that is figuring out what is erroring or not processing, when, and why...
Ideally though, perhaps you find some other modification had been made to the "older" site to make this work. It really could also be outside the scope of the plugin and instead something in another file that had to be modified to function. I saw that there were a lot of other scripts available/executed on the product page. Again I didn't have access to appropriate tools to follow the program flow to be able to see if one of other plugins might cause an issue with this... I mean, even loading sequence of those other plugins could make a difference as well... Etc...
No error logs were generated. So I generated one to see what would show, and nothing did.
I removed the two files I've been working on, which I made cosmetic changes to see if maybe the plugin didn't like what I did, and that didn't do anything the behavior is still present.
So I went back to see if maybe I left some clues that would point on why I was having this issue back then. I had installed the wholesale plugin which I didn't install in this one, and the stock by attributes plugin, which I don't have on this one either. So whatever happened then, has to be unrelated to this event. Which means another one of the plugins I have installed could be the culprit.
I switched templates to the classic and the issue persists.
This is the list of all the plugins I have installed. Some of them I was able to turn off from the admin area and the issue still persisted. Do you know of any of these plugins messing with this? That would help me in narrowing down on what to look for.
About us (define page)
Admin order weight (displays the order weight in admin)
Admin notes
Average product rating
Category tab simple dropdown
Google recaptcha
Instafeed (displays an Instagram feed at the bottom of the homepage)
Invoice payment module
New item badge
One page checkout
Order comments boilerplate
Print invoice popup
Returns and refunds define page
Sitemap XML
Snap affiliates
Specials define page
Square payments
User tracking
USPS
UPS
Ultimate URL
TyPackagage tracking
Better together
Dynamic price updater
Zen colorbox
Thank you for taking the time. I truly appreciate it.
Re: Dynamic Price Updater
Quote:
Originally Posted by
mvstudio
No error logs were generated. So I generated one to see what would show, and nothing did.
I removed the two files I've been working on, which I made cosmetic changes to see if maybe the plugin didn't like what I did, and that didn't do anything the behavior is still present.
So I went back to see if maybe I left some clues that would point on why I was having this issue back then. I had installed the wholesale plugin which I didn't install in this one, and the stock by attributes plugin, which I don't have on this one either. So whatever happened then, has to be unrelated to this event. Which means another one of the plugins I have installed could be the culprit.
I switched templates to the classic and the issue persists.
This is the list of all the plugins I have installed. Some of them I was able to turn off from the admin area and the issue still persisted. Do you know of any of these plugins messing with this? That would help me in narrowing down on what to look for.
About us (define page)
Admin order weight (displays the order weight in admin)
Admin notes
Average product rating
Category tab simple dropdown
Google recaptcha
Instafeed (displays an Instagram feed at the bottom of the homepage)
Invoice payment module
New item badge
One page checkout
Order comments boilerplate
Print invoice popup
Returns and refunds define page
Sitemap XML
Snap affiliates
Specials define page
Square payments
User tracking
USPS
UPS
Ultimate URL
TyPackagage tracking
Better together
Dynamic price updater
Zen colorbox
Thank you for taking the time. I truly appreciate it.
Great to have all that information; however, I discovered that by looking at the console when accessing the "problem" product, that the issue is in fact a script related issue. The following error was in the "log":
Quote:
DPU catch error: TypeError: Cannot use 'in' operator to search for 'id[2]' in
at getPrice (https://www.byvalenti.com/ZCBASE/tinted-lip-balms-c-15_30/lip-whip-souffle-tinted-lip-balm-in-6-beautiful-colors-p-33:305:31)
at init (https://www.byvalenti.com/ZCBASE/tinted-lip-balms-c-15_30/lip-whip-souffle-tinted-lip-balm-in-6-beautiful-colors-p-33:562:9)
at onload (https://www.byvalenti.com/ZCBASE/tinted-lip-balms-c-15_30/lip-whip-souffle-tinted-lip-balm-in-6-beautiful-colors-p-33:674:3)
May I recommend attempting the following?
Change at/about line 154 of includes/modules/pages/product_info/jscript_dynamic_price_updater.php
from:
Code:
if (!(el.name in attributes) && el.name.startsWith("id[")) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
to:
Code:
if ((attributes === '' || !(el.name in attributes)) && el.name.startsWith("id[")) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
"Easy" way to modify it so that you "build" up to the final result:
start with:
Code:
if (!(el.name in attributes) && el.name.startsWith("id[")) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
add parentheses around the first term:
Code:
if ((!(el.name in attributes)) && el.name.startsWith("id[")) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
Then, just before the exclamation point (represents a logical "not" or flip the "truthiness" of the variable that follows. If it was true, then consider it false, if it was false, then consider it true) add the test to see that attributes still is an empty text string (original value) so that if that is true, then there is no need to check for el.name being in the string... (Not that I'm entirely sure that "el.name in attributes" is the right way to perform that test considering I didn't make that change and haven't done *ANY* testing on that version of DPU.)
Code:
if ((attributes === '' || !(el.name in attributes)) && el.name.startsWith("id[")) { // Ensure not to replace an existing value. I.e. drop a duplicate value.
Now, all that said, and I was *assuming* that this particular site was a development location, turning off the spinning feature would have at least allowed the base/normal price to be displayed. (I should know the exact configuration switch to change, but am drawing a blank at the moment and need to move on.)
And sorry if it doesn't resolve the issue, there's some action being done/taken in here that I didn't code and wouldn't have used for multiple reasons. I also haven't opened up a tool to test execute and see results of the way the data is being handled... What is considered desired in this line is to determine if the collected data already includes the radio item that has the name it is given where that name *SHOULD* be unique to all other objects within the group (otherwise basically there is a problem with the page) and if that named item is not already captured AND the associated attribute's "name" starts with id[, then go ahead and collect the attributes name and the value assigned to it so that later that data can be decoded to display the price... Something about the process though seems wrong because I would expect the javascript: X in Y to work for any length of text (IF that operator is the correct operator for a string of text... Problem is that the MDN instruction references use of the 'in' operator to search through an object or its prototype chain... I'm not seeing either of those in my "limited vision"... Unfortunately and further, using this method/style of looking through a string of text for matching "text" (assuming that really is what is being done) seems problematic to successfully perform: E.g. the text contains: 'test~5|run~6|test2~7', well when get to a variable that has the name 'ru', it appears that a text search for 'ru' would indicate that it already exists because 'run' is present and 'ru' is a subset of 'run'...
Anyways, I'm showing what I don't know/understand and babbling on further... Again, didn't have this issue in the version I prepared... Post back on success/failure (or at least when it has been incorporated)...
Again, the issue is not with your other plugins but specifically/directly with the javascript/jQuery code associated with a series of attributes only having radio buttons (or perhaps any radio button at all), perhaps change to another selection type if need to support operation? Not really one that does the same thing of showing the picture right in ones face without switching from one to another... Sorry, enough.. :)
Re: Dynamic Price Updater
Quote:
Originally Posted by
mc12345678
Great to have all that information; however, I discovered that by looking at the console when accessing the "problem" product, that the issue is in fact a script related issue. The following error was in the "log":
How?! Where did you find that error?? I have much to learn!
Quote:
Now, all that said, and I was *assuming* that this particular site was a development location, turning off the spinning feature would have at least allowed the base/normal price to be displayed. (I should know the exact configuration switch to change, but am drawing a blank at the moment and need to move on.)
Yes. It's on development, not a live store, yet. I was finishing a few cosmetic details and playing around to make sure everything was working fine before launching it when I saw the endless spinning wheel. Since it isn't a live store is not that big deal the wheel keeps spinning. The control to turn it off is in configuration/dynamic price updater/show a small loading graphic, and yes if I turned it off the wheel of course stops spinning. That worked.
I made the change you suggested, and the wheel stopped spinning, so that's progress!
So here is what's different about the live store and the one I'm working on, the one you're helping me with.
This is the live store https://www.byvalenti.com/index.php?...&products_id=6
Same product and everything, when a selection of color is made the wheel spins and stops with every selection made even if the product isn't priced by attribute. If there would be a change in price on a per color basis, the price updates. That's how it's supposed to work, or at least how it's been working for year now.
On the development store https://www.byvalenti.com/ZCBASE/tin...ul-colors-p-33 with the modification you suggested now loaded, the wheel spins while the page is being loaded and stops. If a different color is selected the wheel won't spin, that's because I'm assuming it detects the product isn't priced by attribute, so it doesn't have to. So I went to check it out to see if the price was different if it would update. So I changed the attributes on the product to price by attributes and changed the prices for each attribute and they do change perfectly.
All this to report, the changes suggested do work! You're brilliant!!!! Thank you so, so much!! Please let me know how I could donate or the least buy you a coffee?... :hug:
Re: Dynamic Price Updater
Quote:
Originally Posted by
mvstudio
How?! Where did you find that error?? I have much to learn!
Yes. It's on development, not a live store, yet. I was finishing a few cosmetic details and playing around to make sure everything was working fine before launching it when I saw the endless spinning wheel. Since it isn't a live store is not that big deal the wheel keeps spinning. The control to turn it off is in configuration/dynamic price updater/show a small loading graphic, and yes if I turned it off the wheel of course stops spinning. That worked.
I made the change you suggested, and the wheel stopped spinning, so that's progress!
So here is what's different about the live store and the one I'm working on, the one you're helping me with.
This is the live store
https://www.byvalenti.com/index.php?...&products_id=6
Same product and everything, when a selection of color is made the wheel spins and stops with every selection made even if the product isn't priced by attribute. If there would be a change in price on a per color basis, the price updates. That's how it's supposed to work, or at least how it's been working for year now.
On the development store
https://www.byvalenti.com/ZCBASE/tin...ul-colors-p-33 with the modification you suggested now loaded, the wheel spins while the page is being loaded and stops. If a different color is selected the wheel won't spin, that's because I'm assuming it detects the product isn't priced by attribute, so it doesn't have to. So I went to check it out to see if the price was different if it would update. So I changed the attributes on the product to price by attributes and changed the prices for each attribute and they do change perfectly.
All this to report, the changes suggested do work! You're brilliant!!!! Thank you so, so much!! Please let me know how I could donate or the least buy you a coffee?... :hug:
I can be reached via my signature "link" (a little bit of an unnecessary tortuous path) so long as it continues to exist on my account or you are always welcome to provide to the Zen Cart fund of which I receive like all users of the software only the benefit of its continued use and the occasional fun of fixing some new and unique issue..
As to seeing the console, like 99% of browsers have some form of "debug" view (on a PC) by pressing the F12 key. It's been a while since I've looked up/talked about macintosh, but seems that there is something similar. Anyways, there is often (and each browser is different) some sort of console that provides "feedback" about the operation(s). Some are better than others and some are easier than others, using many different ones offers the ability to "figure it all" out... :)
BTW, good work on developing *NOT* on the live site...
Re: Dynamic Price Updater
Quote:
Originally Posted by
mc12345678
As to seeing the console, like 99% of browsers have some form of "debug" view (on a PC) by pressing the F12 key. It's been a while since I've looked up/talked about macintosh, but seems that there is something similar. Anyways, there is often (and each browser is different) some sort of console that provides "feedback" about the operation(s). Some are better than others and some are easier than others, using many different ones offers the ability to "figure it all" out... :)
Oh man! I totally forgot about that one! Of course I knew about it, I just didn't think of it :wacko:
Quote:
Originally Posted by
mc12345678
BTW, good work on developing *NOT* on the live site...
Thank you!??? :laugh: I might not have *developed* the site, I praise you all for the mechanics of it, but the design aspect is most certainly all me :D