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

Dynamic Price Updater

Views: 342,327

Results 1,301 to 1,320 of 1,701
16 May 2017, 11:05 AM
#1301
mc12345678 avatar

mc12345678

Totally Zenned

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

Dynamic Price Updater

webchills:

I have noticed that the config setting DPU_SHOW_LOADING_IMAGE (true to show a small loading graphic so the user knows something is happening) is misleading as if you set it to false the whole functionality is not loading anymore. There is no image loading but no price change as well :-) If the graphic is needed it would be better to remove this setting. If the graphic is not needed something must be wrong in the ```

<?php if (DPU_SHOW_LOADING_IMAGE == 'true') { ?>
Danke, webchills,

Have confirmed the same lack of response when set to false, looking into the why and how to resolve.
16 May 2017, 12:00 PM
#1302
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

webchills:

I have noticed that the config setting DPU_SHOW_LOADING_IMAGE (true to show a small loading graphic so the user knows something is happening) is misleading as if you set it to false the whole functionality is not loading anymore. There is no image loading but no price change as well :-) If the graphic is needed it would be better to remove this setting. If the graphic is not needed something must be wrong in the ```

<?php if (DPU_SHOW_LOADING_IMAGE == 'true') { ?>

See commits: 
(includes/modules/pages/product_info)
<https://github.com/mc12345678/Dynamic_Price_Updater/commit/3fa1c0677516cd1678ace748d9f6e0dc82d089b9> 

and:
(includes/modules/pages/product_music_info)
<https://github.com/mc12345678/Dynamic_Price_Updater/commit/826497348d34aea54e131d519cd9c1ae60d810dc>

For resolution.

Files affected are the jscript_dynamic_price_updater.php file for each of the pages (similar to be applied to any other page where the jscript_dynamic_price_updater.php file has been placed.
16 May 2017, 8:03 PM
#1303
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

Re: Dynamic Price Updater

Thanks for the speedy fixes. Working like a charm now. And thanks for taking care of this plugin, it came a long way since Chrome invented the first version...

24 May 2017, 12:58 PM
#1305
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

dharrison:

Hi mc

Thanks for the advice ref the ZenID. I have set this properly now.

How can I add a suffix to the 2nd price?

Just to pinpoint, this is the price which shows below the add cart button at https://sitstandforbusiness.com/height-adjustable-bench-modules-c-60/height-adjustable-2-position-bench-module-p-29.html

Unable to access your site at the moment to identify the details of what is going on; however, if all that is needed is to add something at the end of the text, then this could be done within the includes/modules/pages/product_info/jscript_dynamic_price_updater.php file within the objXHR.prototype.updSP = function () { section such as:

    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 + " suffix";

The content between the double quotes could be php provided to depend on settings of the store or to use a constant that is language dependent for example.

    objSP.innerHTML = temp.innerHTML + " <?php if ($condition) { echo CONSTANT;} else { echo CONSTANT2; } ?>";

If the suffix is to be added elsewhere within the content, then some additional javascript or other php could/would be used to split out temp.innerHTML to the desired parts in order to insert the associated text.

This area was chosen because the updSP (Second price location) is not presented until one of the attributes has been changed and that text is dependent on/reflects the content of the primary price display.

25 May 2017, 11:24 AM
#1306
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Dynamic Price Updater

Thanks. The first method worked.

25 May 2017, 11:33 AM
#1307
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

dharrison:

Thanks. The first method worked.

Glad that worked.

The "second" method is intended to support multiple languages and demonstrates a simple if/then/else comparison or operation, but requires at least one define to be added into the includes/languages file structure such as either at the base language file includes/languages/YOUR_LANGUAGE.php (overrideable at includes/languages/YOUR_TEMPLATE/YOUR_LANGUAGE.php) or the applicable product type (also overrideable) as in includes/languages/YOUR_LANGUAGE/product_info.php or preferably includes/languages/YOUR_LANGUAGE/YOUR_TEMPLATE/product_info.php for example. If placed in the individual product type file, then it would need to be duplicated across product types used on the site; however, by being placed in the probably more preferred overridden main language file, then it is entered once and applied across all product types that may be used in the store.

The define(s) would be similar to:

  define('CONSTANT', 'suffix text');
 define('CONSTANT2', 'other suffix text');
2 Jun 2017, 12:44 PM
#1308
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

Apologies for the late notification.

Last weekend, I uploaded an updated copy of DPU for review; however, in true fashion shortly after doing so I discovered a couple of issues when I attempted to use the features from a specific mobile device which ultimately was a result of using a default value in a parameter within the javascript code. By review of javascript discussions, this shouldn't have been a problem, but it would seem that the particular device wasn't playing by "today's" standards, so a resolution to that has been created. Also, in rewriting a portion of the dpu class code, I had not taken into account changes that would be needed for the provided/included sidebox. Also, the newly included installer includes a check for updated versions; however, it also expects the ability to disable version checking which was not included in the installer sql.

Anyways, all of that said, I am working on the instruction to address the updates/modifications most of which are available currently from github: https://github.com/mc12345678/Dynamic_Price_Updater

So stay tuned for version 3.0.6, I would like to have it pushed to the forum for review over the weekend, other projects pending.

Version 3.0.5:

  • Improved installation/installer
  • Previous process for installation included a delete of previous settings. This is now performed using insert ignore style sql and as necessary to update settings with a focus of configuration sort order.
  • Rewrote the data collection about a product to improve ability to compare to the active cart.
  • If using the class function of insertProducts, the resulting prid is an integer only and does not include the possibility of addressing attributes based on the change(s) made here. This is equivalent to a standard product being listed in the product listing screen being added to the cart where attributes are "typically" not selectable.
  • Modified quantity reporting to provide quantity already in cart for selected attributes if the quantity is greater than zero.
  • Incorporated forum correction for operation when DPU_SHOW_LOADING_IMAGE is set to false.
  • Added JSON response information when retrieving results.
  • Incorporated the use of Zen Cart's provided zcJS when it is available.
  • Made the DPU class part of the overall system to better support additional observers as needed.
  • Maintained the "default" XML response if JSON is not requested to align with potential historical alterations.
  • Added the restoration of the price display if the transaction fails.
  • Added jscript function to perform data/screen update/swap.
    Available here.
3 Jun 2017, 1:51 PM
#1309
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

Submitted v3.0.6, awaiting review. When posted should be available from here: https://www.zen-cart.com/downloads.php?do=file&id=1301

Description provided:

3.0.6:

  • Modified/updated the class information to provide the sidebox data.
  • Correct additional javascript errors to prevent having to catch them.
  • Modified sidebox to not display/be active if the page's javascript for dpu is not active.
  • Added additional type casting to force data to the expected type.
  • Incorporate the tax calculation correction posted in the forum into the code.
  • Removed the use of default parameters because some browsers do/did not support it.
  • Add separate control for update checking of this plugin.
  • Updated installer version check to ZC 1.5.5e version.
  • Corrected installer code to validate new version exists.

Anyone that has fully installed version 3.0.5 should be notified through their admin when version 3.0.6 is made available for download.

6 Jun 2017, 4:20 AM
#1310
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

mc12345678:

Submitted v3.0.6, awaiting review. When posted should be available from here: https://www.zen-cart.com/downloads.php?do=file&id=1301

Description provided:

Anyone that has fully installed version 3.0.5 should be notified through their admin when version 3.0.6 is made available for download.

Version 3.0.6 has been posted for download; however, there were a few additional things discovered that are addressed in version 3.0.7 (also on github):

3.0.7, What changed:

  • Corrected issue that price of product without attributes was not incorporated/considered because
    the dpu javascript code basically prevented overwriting the price until corrections were made
    in version 3.0.6 that would automatically rewrite the current price display based on what
    dpu determined based on the product. (This additional feature was added to support display of
    the appropriate information when returning to the product from the shopping cart.)
  • Because the price is automatically calculated based on arriving at a product, if a product is
    priced by attributes and not all of the "mandatory" attributes are selected then the price
    was only showing the price point of those that were selected. The code now calculates the
    lowest available price based on the selections already made. The displayed text has not been
    edited to account for this "feature" yet, but could be modified to support the condition.
    Only the dpu class file was modified in version 3.0.7 as compared to 3.0.6 and the addition of the installer "version" file.

When the software review team has made it through the review and posting of the update it should be available here: https://www.zen-cart.com/downloads.php?do=file&id=1301

Welcome further feedback/suggestions of how these additional features/calculations are presented. See at least one place where an additional notifier could maybe add some functionality to the code.

8 Jun 2017, 12:08 PM
#1311
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: Dynamic Price Updater

Good morning at all, I can not change the decimals ie I would like the decimal ones to be a spin instead of a point, and miles a point instead of a comma.

In the currency the comma is set to the decimal then it is not zen cart the problem but dpu. Thank you for the reply.

Ps
I installed version 3.07

8 Jun 2017, 1:29 PM
#1312
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

diamond1:

Good morning at all, I can not change the decimals ie I would like the decimal ones to be a spin instead of a point, and miles a point instead of a comma.

In the currency the comma is set to the decimal then it is not zen cart the problem but dpu. Thank you for the reply.

Ps
I installed version 3.07

What is your setting for: Show currency symbols?

If it is true, then all currency related values should be reflected when displaying a price (i.e. a number such as 3000 with a fraction of 1/2 would be displayed as 3.000,5 when using a decimal for the thousands place and a comma (spin) for the part of a number, or if a comma (spin) for the thousands place and a period for the part of a whole it would be 3,000.5).

As to other "units" such as miles/km, DPU should return whatever has been entered. If there is some other "special" conversion to be performed based on what attribute is being addressed then this conversion/handling would need to be incorporated into the includes/classes/dynamic_price_updater.php file. To address this in the sidebox (only place that updates with a specific attribute's option "name" or value "name"), then would suggest that if modifying the displayed attribute that it be handled in the function getSideboxContent with further suggestion of addressing in this "area"

      if (is_array($this->shoppingCart->contents[$products[$i]['id']]['attributes'])) {
//    while (isset($this->shoppingCart->contents[$_POST['products_id']]['attributes']) && list($option, $value) = each($this->shoppingCart->contents[$_POST['products_id']]['attributes'])) {
        foreach ($this->shoppingCart->contents[$products[$i]['id']]['attributes'] as $option => $value) {
          $adjust_downloads ++;
          $attribute_price = $db->Execute("SELECT *
                                    FROM " . TABLE_PRODUCTS_ATTRIBUTES . "
                                    WHERE products_id = '" . (int)$prid . "'
                                    AND options_id = '" . (int)$option . "'
                                    AND options_values_id = '" . (int)$value . "'");
          $data = $db->Execute("SELECT products_options_values_name
                         FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . "
                         WHERE products_options_values_id = " . (int)$value);
          $name = $data->fields['products_options_values_name'];

At/after this last line ($name = ...) would evaluate the options_id ($option) and options_values_id ($value) to see if either/both should be the one(s) to be manipulated to display an alternate series of comma (spin) and period... Ie. if the option name is miles and has an option_id of 27 and all available option values are numbers, then:

if ((int)$option == 27) {
  $name = /* function or code to convert the previous value of $name to use the new units */;
}

Otherwise I am not sure what you mean by the usage of miles in this context because the values presented/calculated by DPU are the cost factors and not some "unit". Such "comparison" or use of units would be or have been a modification to the core coding of ZC.

I guess it could also be possible that a "cost" could be displayed with specific units/decimals by use of the php function number_format described in the php manual here as applicable.

But would need more information to provide further guidance/assistance.

9 Jun 2017, 8:50 AM
#1313
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: Dynamic Price Updater

Titre : Euro
Code: EUR

Symbole à gauche :
Symbole à droite : €

Point décimal : ,
Séparateur des milliers : .
Nombre de décimales : 2

It's all set up as it should, without DPU everything works the prices are 3.000,50 €
With DPU the price becomes 3,000.50

9 Jun 2017, 10:27 AM
#1314
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

diamond1:

Titre : Euro
Code: EUR

Symbole à gauche :
Symbole à droite : €

Point décimal : ,
Séparateur des milliers : .
Nombre de décimales : 2

It's all set up as it should, without DPU everything works the prices are 3.000,50 €
With DPU the price becomes 3,000.50

Sorry, I should have been clearer:
What is your setting for: Show currency symbols?
As found on the admin->configuration->Dynamic Price Updater window.

Based on your report it sounds like it is set to false and should be set to true.

10 Jun 2017, 12:45 PM
#1315
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: Dynamic Price Updater

Thanks you were right I have to enable the currency to change the comma to point, although it does not make sense but you helped me solve this thanks again

10 Jun 2017, 1:57 PM
#1316
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

diamond1:

Thanks you were right I have to enable the currency to change the comma to point, although it does not make sense but you helped me solve this thanks again

I was also wondering why the code had an option to return the value without using currency symbols but then realized that the javascript that processes the response can be altered and it may be that one needs to not have currency symbols and that they would add them in.

Anyways, glad that the issue is resolved.

12 Jun 2017, 10:34 AM
#1317
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: Dynamic Price Updater

If i would like to modify it by javascript what would be the change and where?

12 Jun 2017, 10:51 AM
#1318
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

diamond1:

If i would like to modify it by javascript what would be the change and where?
The data generated by the php code is fed to the includes/modules/pages/YOUR_PRODUCT_TYPE/jscript_dynamic_price_updater.php which contains the javascript portion to present the results.

The question is what screen result is to be modified and what change is to be made?

12 Jun 2017, 11:54 AM
#1319
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

The javascript that processes (handles) the returned data as provided in this plugin is found in the function: objXHR.prototype.handlePrice. So if there is something to be modified about the returned data and to modify it within the javascript it would be in that function and then depending on what is to be modified and how, likely to be within the applicable switch case prior to assignment to this.updateInnerHTML.

12 Jun 2017, 12:58 PM
#1320
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: Dynamic Price Updater

I have this but I do not know how to do it

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);
}