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

Dynamic Price Updater

Views: 342,340

Results 1,321 to 1,340 of 1,701
12 Jun 2017, 1:32 PM
#1321
mc12345678 avatar

mc12345678

Totally Zenned

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

Dynamic Price Updater

diamond1:

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


You haven't stated what "it" is. I.e. don't know how to do what?

The code snippet above is the first part of the handlePrice function and to explain what it does is:
1. set a variable thePrice to be the DOM object that has the id of whatever is entered in the database for DPU_PRICE_ELEMENT_ID which is a field in the configuration->Dynamic Price Updater settings.
2. basically, if a loadImg has been defined and it was added/displayed such that it was in addition to the price instead of replacing it, then remove the image.  Later if the image *did* replace the text, then the new text would again replace the image.  This is/was all to support the possibility of a "load image" being displayed that would need to be cleared when the results came back for display.

So, again, what is being displayed on the screen that is desired to be modified and what change is to be made or how is it to look different than the way it is provided?
13 Jun 2017, 7:00 AM
#1322
diamond1 avatar

diamond1

Zen Follower

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

Re: Dynamic Price Updater

Since I had to activate the currency symbol to have the comma in place of the decimal point, I realized that you could modify a little bit of php code to show the decimal places with the comma by removing the currency symbol.

13 Jun 2017, 7:08 AM
#1323
diamond1 avatar

diamond1

Zen Follower

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

Re: Dynamic Price Updater

Another thing, how do I remove UPDATER_PREFIX_TEXT (Your price:) without deleting it on the language file

/*

  • Prepares the shoppingCart contents for transmission
  • @return void
    */
    protected function prepareOutput() {
    global $currencies, $db;
    $prefix = '';
    switch (true) {
    case (!isset($_POST['pspClass'])):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productSpecialPrice"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productSalePrice"):
    $prefix = PRODUCT_PRICE_SALE;
    break;
    case ($_POST['pspClass'] == "productSpecialPriceSale"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productPriceDiscount"):
    $prefix = PRODUCT_PRICE_DISCOUNT_PREFIX;
    break;
    case ($_POST['pspClass'] == "normalprice"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productFreePrice"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productBasePrice"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    default:
    $prefix = UPDATER_PREFIX_TEXT;
    // Add a notifier to allow updating this prefix if the ones above do not exist.
    $this->notify('NOTIFY_DYNAMIC_PRICE_UPDATER_PREPARE_OUTPUT_PSP_CLASS');
    break;
    }
13 Jun 2017, 10:40 AM
#1324
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

diamond1:

Since I had to activate the currency symbol to have the comma in place of the decimal point, I realized that you could modify a little bit of php code to show the decimal places with the comma by removing the currency symbol.

So, the process incorporated into DPU for currencies is if it is desired to show values fully in the selected currency they will be displayed as defined by/within ZenCart with regards to all of the factors defined. If it is desired to not display the prices using the ZC currency format, then the values will be displayed as controlled by php for using the function number_format with only two parameters. (if more are desired, then they can be added into the class file for dpu to support whatever result is desired. Ideally, one would consider the possibility of showing the information to those both in and out of the primary "currency" or current language.

See for those that use the comma (,) for thousands and decimal (.) for parts of a whole, turning off currency appears to only remove the currency symbol(s).

Basically, there are some things that have been written into the code that offer places to modify to suit as well as to use the ZC default code.

13 Jun 2017, 12:00 PM
#1325
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

diamond1:

Another thing, how do I remove UPDATER_PREFIX_TEXT (Your price:) without deleting it on the language file

/*

  • Prepares the shoppingCart contents for transmission
  • @return void
    */
    protected function prepareOutput() {
    global $currencies, $db;
    $prefix = '';
    switch (true) {
    case (!isset($_POST['pspClass'])):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productSpecialPrice"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productSalePrice"):
    $prefix = PRODUCT_PRICE_SALE;
    break;
    case ($_POST['pspClass'] == "productSpecialPriceSale"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productPriceDiscount"):
    $prefix = PRODUCT_PRICE_DISCOUNT_PREFIX;
    break;
    case ($_POST['pspClass'] == "normalprice"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productFreePrice"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    case ($_POST['pspClass'] == "productBasePrice"):
    $prefix = UPDATER_PREFIX_TEXT;
    break;
    default:
    $prefix = UPDATER_PREFIX_TEXT;
    // Add a notifier to allow updating this prefix if the ones above do not exist.
    $this->notify('NOTIFY_DYNAMIC_PRICE_UPDATER_PREPARE_OUTPUT_PSP_CLASS');
    break;
    }
I'm not exactly sure what you mean by "without deleting it on the language file". The proper way to control the content that is to replace UPDATER_PREFIX_TEXT and to minimize the differences between the distributed software and what is on your system is to define that text as nothing (blank) which is an empty string.

So the define would go from:

define('UPDATER_PRICE_PREFIX', 'Your price: ');

To:

define('UPDATER_PRICE_PREFIX', '');

And then anywhere for the language displayed that UPDATER_PRICE_PREFIX is presented it would be nothing.

Alternatively and currently left for those that wish to personalize the data, a new define could added for the individual class type(s) depending on the particular setup. These may get updated/modified as new ones are identified to apply, but at initial insertion, I didn't want to unnecessarily add x defines all having the same text and instead inserted one define used in x locations. 

In review of the above code I did also realize that the notifier won't serve the function intended and have added a branch in github to address it for the next release as well as some additional code to address "personalization" of the various parts recently discussed of not using the currency symbol feature.
3 Jul 2017, 8:59 AM
#1326
diamond1 avatar

diamond1

Zen Follower

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

Re: Dynamic Price Updater

I noticed that if the product does not have attributes the price shown is zero as ever?

3 Jul 2017, 12:55 PM
#1327
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

diamond1:

I noticed that if the product does not have attributes the price shown is zero as ever?
What version is installed and is the product setup to default to a zero quantity when the customer is first presented the product? There was a discovered issue with 3.0.6 that was corrected in 3.0.7 similar to what you describe.

Basically, a javascript error had been previously occurring that would prevent updating the price of a product without attributes, once the javascript error was properly addressed, then the price update review would occur with all product, well. The code was only trying to handle product with attributes and therefore calculated a 0 price for product without attributes. Once that was identified as occurring the "solution" was to go ahead and use DPU in all places when looking at the product info page, this way the display of information would/could be consistent and reduce the "flash" of changing from say starting at to minimum price or something like that. And prices for quantities (with or without attributes) could be displayed.

So... recommend updating to the latest version of at least 3.0.7.

4 Jul 2017, 10:56 AM
#1328
diamond1 avatar

diamond1

Zen Follower

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

Re: Dynamic Price Updater

I have version 3.07, maybe it was badly agued which would be the java file to be corrected

Thank you MC

14 Jul 2017, 12:44 PM
#1329
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Dynamic Price Updater

Hello,

I upgraded a client's website to the latest version 1.5.5e
I installed Dynamic Price Updater module but it keeps sending the following warning in the logs

@Dr Byte kindly help

[14-Jul-2017 12:37:22 UTC] Request URI: /ajax.php?act=DPU_Ajax&method=dpu_update, IP address: 192.168.200.28
#1 header() called at [/home/yabba1/public_html/includes/classes/dynamic_price_updater.php:463]
#2 DPU->dumpOutput() called at [/home/yabba1/public_html/includes/classes/dynamic_price_updater.php:68]
#3 DPU->getDetails() called at [/home/yabba1/public_html/includes/classes/ajax/zcDPU_Ajax.php:16]
#4 zcDPU_Ajax->dpu_update()
#5 call_user_func() called at [/home/yabba1/public_html/ajax.php:72]

[14-Jul-2017 12:37:22 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/yabba1/public_html/includes/classes/ajax/zcDPU_Ajax.php:1) in /home/yabba1/public_html/includes/classes/dynamic_price_updater.php on line 463

14 Jul 2017, 1:02 PM
#1330
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

mani:

Hello,

I upgraded a client's website to the latest version 1.5.5e
I installed Dynamic Price Updater module but it keeps sending the following warning in the logs

@Dr Byte kindly help

[14-Jul-2017 12:37:22 UTC] Request URI: /ajax.php?act=DPU_Ajax&method=dpu_update, IP address: 192.168.200.28
#1 header() called at [/home/yabba1/public_html/includes/classes/dynamic_price_updater.php:463]
#2 DPU->dumpOutput() called at [/home/yabba1/public_html/includes/classes/dynamic_price_updater.php:68]
#3 DPU->getDetails() called at [/home/yabba1/public_html/includes/classes/ajax/zcDPU_Ajax.php:16]
#4 zcDPU_Ajax->dpu_update()
#5 call_user_func() called at [/home/yabba1/public_html/ajax.php:72]

[14-Jul-2017 12:37:22 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/yabba1/public_html/includes/classes/ajax/zcDPU_Ajax.php:1) in /home/yabba1/public_html/includes/classes/dynamic_price_updater.php on line 463
I'm not the good DrByte, but it appears that somehow there is a character before the opening <?php in the file: includes/classes/ajax/zcDPU_Ajax.php that is on your server. I have just downloaded the plugin and at least in the file viewer I am looking at such a character does not exist. How was the file uploaded/installed?

14 Jul 2017, 1:16 PM
#1331
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

mc12345678:

I'm not the good DrByte, but it appears that somehow there is a character before the opening <?php in the file: includes/classes/ajax/zcDPU_Ajax.php that is on your server. I have just downloaded the plugin and at least in the file viewer I am looking at such a character does not exist. How was the file uploaded/installed?

Further assistance regarding the warning message of Headers already sent can be found at this FAQ: https://www.zen-cart.com/content.php?129-warning-headers-already-sent

Please report back what you find as it would be nice to know if the original fileset was found to cause this issue so that it could be prevented for others. I don't have those error messages in the installation that I have so would have to figure out what caused the introduction of an additional character (visible or non-printed) at least to ensure it wouldn't be present for others.

17 Jul 2017, 9:55 AM
#1332
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Dynamic Price Updater

I just checked and there is no character at the opening

<?php class zcDPU_Ajax extends base { function dpu_update() What else could be the reason for this?
17 Jul 2017, 10:00 AM
#1333
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Dynamic Price Updater

here is a complete log file

[17-Jul-2017 09:57:47 UTC] Request URI: /ajax.php?act=DPU_Ajax&method=dpu_update, IP address: 192.168.200.28
#1 header() called at [/home/*****/public_html/includes/classes/dynamic_price_updater.php:463]
#2 DPU->dumpOutput() called at [/home/yabba1/public_html/includes/classes/dynamic_price_updater.php:68]
#3 DPU->getDetails() called at [/home/yabba1/public_html/includes/classes/ajax/zcDPU_Ajax.php:15]
#4 zcDPU_Ajax->dpu_update()
#5 call_user_func() called at [/home/yabba1/public_html/ajax.php:72]

[17-Jul-2017 09:57:47 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/******/public_html/includes/classes/ajax/zcDPU_Ajax.php:1) in /home/yabba1/public_html/includes/classes/dynamic_price_updater.php on line 463

Any help will be appreciated

18 Jul 2017, 3:37 AM
#1334
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

mani:

here is a complete log file

[17-Jul-2017 09:57:47 UTC] Request URI: /ajax.php?act=DPU_Ajax&method=dpu_update, IP address: 192.168.200.28
#1 header() called at [/home/*****/public_html/includes/classes/dynamic_price_updater.php:463]
#2 DPU->dumpOutput() called at [/home/yabba1/public_html/includes/classes/dynamic_price_updater.php:68]
#3 DPU->getDetails() called at [/home/yabba1/public_html/includes/classes/ajax/zcDPU_Ajax.php:15]
#4 zcDPU_Ajax->dpu_update()
#5 call_user_func() called at [/home/yabba1/public_html/ajax.php:72]

[17-Jul-2017 09:57:47 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/******/public_html/includes/classes/ajax/zcDPU_Ajax.php:1) in /home/yabba1/public_html/includes/classes/dynamic_price_updater.php on line 463

Any help will be appreciated

The file was somehow uploaded with the incorrect file encoding (UTF-8/BOM) so there is an "invisible" character at the beginning of that file. I have uploaded to github just the change to the encoding (ANSI) to: https://github.com/mc12345678/Dynamic_Price_Updater/commit/9857cf302f2ec06562dc40d60b79eea406dd84cf.

18 Jul 2017, 6:54 AM
#1335
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Dynamic Price Updater

It appears using your file has fixed the problem!

Thanks a lot :)
Much appreciated!

18 Jul 2017, 6:59 AM
#1336
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Dynamic Price Updater

Now got one more warning

[18-Jul-2017 06:57:14 UTC] Request URI: /ajax.php?act=DPU_Ajax&method=dpu_update, IP address: 192.168.200.28
#1 DPU->removeExtraSelections() called at [/home/yabba1/public_html/includes/classes/dynamic_price_updater.php:62]
#2 DPU->getDetails() called at [/home/yabba1/public_html/includes/classes/ajax/zcDPU_Ajax.php:14]
#3 zcDPU_Ajax->dpu_update()
#4 call_user_func() called at [/home/yabba1/public_html/ajax.php:72]

[18-Jul-2017 06:57:14 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/yabba1/public_html/includes/classes/dynamic_price_updater.php on line 150

How do I get this fixed?

18 Jul 2017, 7:24 AM
#1338
mani avatar

mani

New Zenner

Join Date:
Aug 2008
Location:
Abbottabad, Pakistan
Posts:
62
Plugin Contributions:
0

Re: Dynamic Price Updater

I copied the contents of the file from classes/dynamic_price_updater.php from

https://github.com/mc12345678/Dynamic_Price_Updater/blob/9857cf302f2ec06562dc40d60b79eea406dd84cf/Installation%20files/includes/classes/dynamic_price_updater.php

and now it doesnt create a log file
Is it the right approach?

Module version installed is downloaded from
https://www.zen-cart.com/downloads.php?do=file&id=1301

and only
classes/dynamic_price_updater.php has been updated from github!

18 Jul 2017, 2:19 PM
#1339
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Dynamic Price Updater

mani:

Is this version of this module GitHub
https://github.com/Zen4All-nl/Zen-Cart-Dynamic-Price-Updater/releases/tag/v3.1

Same as this one
https://www.zen-cart.com/downloads.php?do=file&id=1301 ?

In Github version there is no ajax folder in includes/classes

If I install GitHub version will it work with 1.5.5e?
No those two versions are no longer the same. While Design75 and I have been talking about moving forward with DPU, we haven't synced (yet) the two distributions. They remain linked however to be able to see the branch history and to locate an updated version.

mani:

I copied the contents of the file from classes/dynamic_price_updater.php from

https://github.com/mc12345678/Dynamic_Price_Updater/blob/9857cf302f2ec06562dc40d60b79eea406dd84cf/Installation%20files/includes/classes/dynamic_price_updater.php

and now it doesnt create a log file
Is it the right approach?

Module version installed is downloaded from
https://www.zen-cart.com/downloads.php?do=file&id=1301

and only
classes/dynamic_price_updater.php has been updated from github!

After issue of 3.0.7, the bug described above was located and corrected on github in the master branch (similar location as identified above, but more "flexible" to reference because it would be up-to-date with the remainder of the software). Considering that for operations sake the only file really changed since 3.0.7 was the includes/classes/dynamic_price_updater.php file, updating the current install with that file is the way to go.

I am working on some additional functionality for the next ZC update such that the starting at: related text would/should be updated from say 'starting at:' (basically for the default values and/or no selections made) to 'at least:' (some selections have been made, but not all that are effectively required and based on attributes being included in the base price through the attributes controller) and then 'Your Price:' once all options have been selected, again somewhat based on the attribute(s) being identified as included in the base price. Still working through some of the "complexities" of options like check boxes (no requirement for one to be selected), text boxes that have pricing applied to the content, radio buttons that don't have a default value (potentially allowing submission of the product without having selected a radio button option which is a flexibility offered by the ZC software).

So yes, the action taken was a good approach to the issue identified in particular that the change(s) made to that file specifically were intended to address the issue observed here in post #1319. :) Had the solution not been there, then posting here about the issue or initiating an issue log on github should support getting the problem corrected once confirmed as an issue.

18 Jul 2017, 2:40 PM
#1340
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Dynamic Price Updater

After i am back frommy summer holiday, I will update my repos to match the MC versoin

mc12345678:

No those two versions are no longer the same. While Design75 and I have been talking about moving forward with DPU, we haven't synced (yet) the two distributions. They remain linked however to be able to see the branch history and to locate an updated version.

After issue of 3.0.7, the bug described above was located and corrected on github in the master branch (similar location as identified above, but more "flexible" to reference because it would be up-to-date with the remainder of the software). Considering that for operations sake the only file really changed since 3.0.7 was the includes/classes/dynamic_price_updater.php file, updating the current install with that file is the way to go.

I am working on some additional functionality for the next ZC update such that the starting at: related text would/should be updated from say 'starting at:' (basically for the default values and/or no selections made) to 'at least:' (some selections have been made, but not all that are effectively required and based on attributes being included in the base price through the attributes controller) and then 'Your Price:' once all options have been selected, again somewhat based on the attribute(s) being identified as included in the base price. Still working through some of the "complexities" of options like check boxes (no requirement for one to be selected), text boxes that have pricing applied to the content, radio buttons that don't have a default value (potentially allowing submission of the product without having selected a radio button option which is a flexibility offered by the ZC software).

So yes, the action taken was a good approach to the issue identified in particular that the change(s) made to that file specifically were intended to address the issue observed here in post #1319. :) Had the solution not been there, then posting here about the issue or initiating an issue log on github should support getting the problem corrected once confirmed as an issue.