Zen Cart Logo
Forums / All Other Contributions/Addons / Dynamic Price Updater

Dynamic Price Updater

Views: 342,262

Results 1,601 to 1,620 of 1,701
09 Aug 2020, 00:26
#1601
jimmie avatar

jimmie

Totally Zenned

Join Date:
Jan 2013
Location:
New Port Richey, Florida
Posts:
969
Plugin Contributions:
0

Dynamic Price Updater

also how can i get my text back that shows up b4 dpu activates. example is when customer not logged id they see Price $34.01 or if they are logged in they see Retail Price $34.01, if customer has wholesale account it says Your Price $30.29

09 Aug 2020, 04:53
#1602
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

jimmie:

zen version 1.56C php7.0
how can we make the model number change to customid on select,
also would like to add a sku or (custom fields) that change on select.
right now i have picture, price, stock and weight all changing on select. i need to have the model number change to custom id. and i want to use the description field to store barcodes and have them change on select. and have the description field incorporated to lookup of other barcodes
here is my site with example product
https://jnsflooringandsupplies.com/Tools_Equipment/Hardwood_Laminate_Tools/Floor_Nailers_Staplers/Powernail_445_16_Ga._Pneumatic_Cleat_Nailer_w_5MI_White_Mallet

jimmie
This would primarily require some custom coding, but there are areas throughout the code to perform additional data retrieval from the database and to then populate the data array that is returned. This portion is in the DPU class. Then once returned, the javascript needs to know/understand where to place the associated data. Effectively anything that is to be updated/modified needs to have some sort of unique identifier such as an id tag or a specific name in a surrounding html tag. Such could be included in your product description and be "updated" on selection change. Basically though the extra information would follow the same process as any of the other originally provided items.

09 Aug 2020, 05:07
#1603
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

jimmie:

also how can i get my text back that shows up b4 dpu activates. example is when customer not logged id they see Price $34.01 or if they are logged in they see Retail Price $34.01, if customer has wholesale account it says Your Price $30.29
The text to be displayed is assembled in the DPU class. Currently there is a different text constant depending on the status of selection. E.g. If a product has multiple selections available (2 or more option names) where each can affect the price and none have been selected the ZC standard text is provided, if one of the options is selected, but not all then a modified version of the text is displayed, if all selections have been made (that affect price) then something equivalent to "your price:" is displayed. This is meant to provide information to the customer associated with their selections. This also is built off the premise that one uses an option value as a default that is for display only...

If it is expected that different text is to be displayed for different customer status and/or inclusion to some group then that text could and should be modified appropriately. There are some notifiers in the DPU class to be able to use an observer to modify that portion of the text as desired and/or one could modify the code in the DPU class to determine the customer's "status" and use text appropriate to that, but I'd discourage slaughtering the code for that and use the notifier/observer method instead.

Note that as I recall there is one of the "wholesale" like plugins somewhat incorporated to retrieve/address pricing when doing early calculations. It too is in the DPU class when gathering the pricing data.

04 Sep 2020, 10:38
#1604
daniel65 avatar

daniel65

New Zenner

Join Date:
Dec 2019
Location:
UK
Posts:
3
Plugin Contributions:
0

Re: Dynamic Price Updater

zencart 1.5.6C
DPU version 4.0.0-beta.3

I have installed DPU on a copy of our live site and it works as expected with a product with a single drop down option
but i have products with 2 radio options (colour and size)
Colour has +0 price. size price varies eg small = 26.85, medium = 28.95 etc

there are 2 issuses

  1. when the page loads the starting price is shown correctly, for a moment, then the little place holder takes over and then the price is shown as starting at £0.00.
    this stays the same when a colour is selected (makes sense as colour has no effect on the price)
  2. when the size is selected the placeholder returns and stays there

any one have any ideas where i should begin looking?

04 Sep 2020, 11:09
#1605
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

Daniel65:

zencart 1.5.6C
DPU version 4.0.0-beta.3

I have installed DPU on a copy of our live site and it works as expected with a product with a single drop down option
but i have products with 2 radio options (colour and size)
Colour has +0 price. size price varies eg small = 26.85, medium = 28.95 etc

there are 2 issuses

  1. when the page loads the starting price is shown correctly, for a moment, then the little place holder takes over and then the price is shown as starting at £0.00.
    this stays the same when a colour is selected (makes sense as colour has no effect on the price)
  2. when the size is selected the placeholder returns and stays there

any one have any ideas where i should begin looking?
Would initially look at the settings of the attributes within attributes controller, though also would identify whether the product is priced-by-attributes or not as set in the product's information page. For attributes, consider the settings for at least: Default and Base Price.

Umm, also in second look, where is this DPU version 4.00 beta 3 obtained from? (web address) That is not a version designation that I have used and generally speaking the above issue doesn't occur unless attributes options are incorrectly set...

04 Sep 2020, 12:06
#1607
daniel65 avatar

daniel65

New Zenner

Join Date:
Dec 2019
Location:
UK
Posts:
3
Plugin Contributions:
0

Re: Dynamic Price Updater

Ok the product is deffinately set to priced by attributes

Im not too sure what you meant by "For attributes, consider the settings for at least: Default and Base Price."

all the attributes in both colour and size are set to Display only X ,Free O, Default X, Discounted O ,Base Price O,Required X
(this where a screen shot would be handy if i could get one into the post)

I have tried turning the defaults on and off, setting all but one to either x or o,with and without setting free to x or o
I have also tried setting the priority of the options so that it did size first, with exactly the same result

04 Sep 2020, 12:52
#1608
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

Daniel65:

i googled zen cart dynamic price update and found this

https://github.com/Zen4All-nl/Zen-Cart-Dynamic-Price-Updater is it not the right one?

I'm not going to say no because Design75 stepped away from the code for a period of time during which I made modifications that "presumably" are incorporated into that version which at last look appeared to be being rewritten to consider installation to the oldest of either ZC 1.5.6 or ZC 1.5.7 (I don't recall). Initial transfer appeared to incorporate the latest that I had worked on as found at: https://github.com/mc12345678/Dynamic_Price_Updater/tree/3.2.1 (Though I would recommend also incorporating https://github.com/mc12345678/Dynamic_Price_Updater/commit/16977dd13cf6b888ad74aaf4d198e98562f548cb)

Daniel65:

Ok the product is deffinately set to priced by attributes

Im not too sure what you meant by "For attributes, consider the settings for at least: Default and Base Price."

all the attributes in both colour and size are set to Display only X ,Free O, Default X, Discounted O ,Base Price O,Required X
(this where a screen shot would be handy if i could get one into the post)

I have tried turning the defaults on and off, setting all but one to either x or o,with and without setting free to x or o
I have also tried setting the priority of the options so that it did size first, with exactly the same result

Display only implies that the option should not be selected. Unfortunately I'm not sure I necessarily follow the meaning of X versus O. To me an X means that it is chosen and an O means that it is not. For a brief/quick explanation, default is intended to indicate that the attribute option will be marked for selection when the page is freshly loaded. There is a little bit of a caveat to that depending on the selection type. If it is a dropdown, then the last item marked for default is expected to be the active selection when the customer arrives at the product. If is a radio, then I believe the same is true (I've forgotten at the moment) of the last one or if made possible that all such radio buttons are selected, if it is a checkbox, then each item set as default is already selected for the customer.

If free is selected, then when the product is identified as being free (a priced-by-attributes product that has any attribute set to a non-zero price would not be considered free) then the attributes price is treated as free as well. The priority is a display situation not used to influence the "base" price. Discounted allows the discount applied to the product to also be applied to the attributes. Base Price supports identifying the lowest price of the product.

One thing identified by RixStix is that it is possible in some setups while using DPU that if a selection is not "pre-made" then the DPU response price is 0 until at least one selection is made. That said, I also just noticed that using 1.5.6c where the current released sub-version is 1.5.6f... There may be other issues in play as a result of not being up-to-date at least within the 1.5.6 series (1.5.7 has been issued as well).

All that said, for understanding, what happens with this plugin is basically, the page is displayed, the product is effectively added to the shopping cart with the "lowest priced" selections made, the price that results is returned for evaluation. At least in the work I did, there are multiple "conditions" evaluated. If no selections are made, then the customer is to basically be notified of what the smallest price expected would be, until all selections are made the customer is provided slightly different text intended to indicate that the final price hasn't been determined is provided, and once all selections have been made the "final" price of the product is displayed. Certainly the text variations can all be made the same if so desired, but I wanted to offer an opportunity to improve the customer experience in understanding their selections before attempting to add the selection(s) to the cart. I don't know if such is being carried over/on. I am sure that Design75 would appreciate more information about how to reproduce the issue so that it may be corrected, though also in looking at the github site I see that there is a development version that is being identified as 4.0.0 b4 I believe.

16 Dec 2020, 19:57
#1609
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: Dynamic Price Updater

@mc12345678: your pm message quota is full, preventing more being received.

Just to let you know I am working on this (with ZC158). I have used the Zen4All develop branch as a starting point.
What put me off previously was the two repositories for reporting issues, each with it's own branches...but since he has consolidated fixes between three sources I'm just going to report issues on Erik's and PR my changes to that one.

When I have finished my fettling for my purposes I'll let you know so you can check out unresolved issues that may have been fixed on the way.
This is a very complicated mod to test as it can/should handle so many eventualities.....

16 Dec 2020, 23:33
#1610
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

torvista:

@mc12345678: your pm message quota is full, preventing more being received.

Just to let you know I am working on this (with ZC158). I have used the Zen4All develop branch as a starting point.
What put me off previously was the two repositories for reporting issues, each with it's own branches...but since he has consolidated fixes between three sources I'm just going to report issues on Erik's and PR my changes to that one.

When I have finished my fettling for my purposes I'll let you know so you can check out unresolved issues that may have been fixed on the way.
This is a very complicated mod to test as it can/should handle so many eventualities.....
Thanks for the heads up on all fronts.

13 Jan 2021, 22:48
#1611
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: Dynamic Price Updater

I'm looking at an issue to do with restricting its operation, and I must clarify for my own sanity that this should be processing the price only:

a) if a product has attributes that contain pricing data. So if all are zero, no need for DPU.
b) for any product on a cart quantity box change. So if no quantity box (or order quantity maximum is 1), no need for DPU.

Any other situations?

03 Feb 2022, 15:25
#1612
goldbuckle avatar

goldbuckle

Zen Follower

Join Date:
Dec 2006
Location:
near Atlanta Georgia
Posts:
219
Plugin Contributions:
0

Re: Dynamic Price Updater

Any idea when the v4.0.0 will be out of beta?

17 Mar 2022, 15:12
#1613
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Dynamic Price Updater

Hello. I'm having an issue with a brand new ZC installation. ZC version is 1.5.7d and the latest of this module found in the plugin area.

DPU works fine, except on radio buttons. For some reason the wheel won't stop spinning.

I remember I had this or similar issue a few years back, and we had made changes to a few files.

The files we modified were the pages>product_info>jscript_dynamic_price_updater.php and the includes>classes>dynamic_price_updater.php.

This is the page where the issue appears https://www.byvalenti.com/ZCBASE/tinted-lip-balms-c-15_30/lip-whip-souffle-tinted-lip-balm-in-6-beautiful-colors-p-33

Would you be able to help out?

Thank you!

17 Mar 2022, 15:37
#1614
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

mvstudio:

Hello. I'm having an issue with a brand new ZC installation. ZC version is 1.5.7d and the latest of this module found in the plugin area.

DPU works fine, except on radio buttons. For some reason the wheel won't stop spinning.

I remember I had this or similar issue a few years back, and we had made changes to a few files.

The files we modified were the pages>product_info>jscript_dynamic_price_updater.php and the includes>classes>dynamic_price_updater.php.

This is the page where the issue appears https://www.byvalenti.com/ZCBASE/tinted-lip-balms-c-15_30/lip-whip-souffle-tinted-lip-balm-in-6-beautiful-colors-p-33

Would you be able to help out?

Thank you!

Unless someone else also responds before I get a chance to look into this, I will take a look but haven't personally experienced that issue (yet).

17 Mar 2022, 16:07
#1615
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Dynamic Price Updater

mc12345678:

Unless someone else also responds before I get a chance to look into this, I will take a look but haven't personally experienced that issue (yet).

Thank you! I'm trying to see if the changes we made back then would work, but the files are substantially different and my php skills quite poor :blush:

17 Mar 2022, 16:54
#1616
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

mvstudio:

Hello. I'm having an issue with a brand new ZC installation. ZC version is 1.5.7d and the latest of this module found in the plugin area.

DPU works fine, except on radio buttons. For some reason the wheel won't stop spinning.

I remember I had this or similar issue a few years back, and we had made changes to a few files.

The files we modified were the pages>product_info>jscript_dynamic_price_updater.php and the includes>classes>dynamic_price_updater.php.

This is the page where the issue appears https://www.byvalenti.com/ZCBASE/tinted-lip-balms-c-15_30/lip-whip-souffle-tinted-lip-balm-in-6-beautiful-colors-p-33

Would you be able to help out?

Thank you!

mc12345678:

Unless someone else also responds before I get a chance to look into this, I will take a look but haven't personally experienced that issue (yet).
I've looked over this to the extent that I can with the hardware immediately available. I see that the software being used is from the Beta 4.0.0 path.

I haven't gone back to review/validate this version so hopefully someone more familiar can further assist.

When I get to where I can follow the script, I might be able to identify something further about why the code stops at the initial display of the "thinking" area. There are though sufficient differences in the includes/modules/pages/product_info/jscript_dynamic_price_updater.php file to possibly cause this issue.

Ideally would suggest identifying this as an issue at the location from which the software was downloaded and then posting back here when and how it was resolved.

17 Mar 2022, 16:56
#1617
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

mvstudio:

Thank you! I'm trying to see if the changes we made back then would work, but the files are substantially different and my php skills quite poor :blush:
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.

17 Mar 2022, 17:20
#1618
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Dynamic Price Updater

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
/**
 * @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
}
}
17 Mar 2022, 17:29
#1619
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

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.

17 Mar 2022, 19:03
#1620
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Dynamic Price Updater

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 /** * @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.