Re: Price Updater - plugin keeps disabling
Quote:
Originally Posted by
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?
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.
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);
}
Re: Dynamic Price Updater
Quote:
Originally Posted by
diamond1
I have this but I do not know how to do it
Code:
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?
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.
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;
}
Re: Dynamic Price Updater
Quote:
Originally Posted by
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.
Re: Dynamic Price Updater
Quote:
Originally Posted by
diamond1
Another thing, how do I remove UPDATER_PREFIX_TEXT (Your price:) without deleting it on the language file
Code:
/*
* 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:
Code:
define('UPDATER_PRICE_PREFIX', 'Your price: ');
To:
Code:
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.
Re: Dynamic Price Updater
I noticed that if the product does not have attributes the price shown is zero as ever?
Re: Dynamic Price Updater
Quote:
Originally Posted by
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.