Re: Price Updater - plugin keeps disabling
Quote:
Originally Posted by
mc12345678
So here are the changes I recommend to support the inc/excl VAT module.
First, update the includes/functions/extra_functions/inc_ex_functions.php file to change this:
Code:
if ($product_check->fields['product_is_free']=='1')
$show_normal_price='<s>'.display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])).'</s>';
else
$show_normal_price=display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id']));
Around line 112 to this (in red):
Code:
if ($product_check->fields['product_is_free']=='1')
$show_normal_price='<s>'.display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])).'</s>';
else
$show_normal_price='<span class="normalprice">'.display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])).'</span>';
Then in includes/modules/pages/product_info/jscript_dynamic_price_updater.php:
At and around line 222:
Code:
for (var a=0,b=test.length; a<b; a++) {
if (test[a].className == "productSpecialPrice" || test[a].className == "productSalePrice" || test[a].className == "productSpecialPriceSale") {
psp = test[a];
}
}
Add: a check for the className normalprice and a check for the "alternate tax" display possibilities:
Code:
var pspInclEx = false;
var pspEx = false;
var pspIncl = false;
for (var a=0,b=test.length; a<b; a++) {
if (test[a].className == "normalprice" || test[a].className == "productSpecialPrice" || test[a].className == "productSalePrice" || test[a].className == "productSpecialPriceSale") {
psp = test[a];
}
}
if (test[a].className == "productIncExTaxPrice") {
pspInclEx = test[a];
}
if (test[a].className == "productTaxExPrice") {
pspEx = test[a];
}
if (test[a].className == "productTaxPrice") {
pspIncl = test[a];
}
Then below that beginning at line 243:
Code:
switch (type) {<?php // the 'type' attribute defines what type of information is being provided ?>
case "priceTotal":
if (psp) {
psp.innerHTML = temp[i].childNodes[0].nodeValue;
} else {
thePrice.innerHTML = temp[i].childNodes[0].nodeValue;
}
if (_secondPrice !== false) {
this.updSP();
}
break;
case "quantity":
with (temp[i].childNodes[0]) {
if (nodeValue != "") {
if (psp) {
psp.innerHTML += nodeValue;
} else {
thePrice.innerHTML += nodeValue;
}
this.updSP();
}
}
break;
Insert additional cases of "priceTotalInclTax", "priceTotalExcTax", and "priceTotalIncExcTax" to support the various classes that the plugin uses.
Code:
switch (type) {<?php // the 'type' attribute defines what type of information is being provided ?>
case "priceTotal":
if (psp) {
psp.innerHTML = temp[i].childNodes[0].nodeValue;
} else {
thePrice.innerHTML = temp[i].childNodes[0].nodeValue;
}
if (_secondPrice !== false) {
this.updSP();
}
break;
case "priceTotalInclTax":
if (pspIncl) {
pspIncl.innerHTML = temp[i].childNodes[0].nodeValue;
}
break;
case "priceTotalExcTax":
if (pspEx) {
pspEx.innerHTML = temp[i].childNodes[0].nodeValue;
}
break;
case "priceTotalInclExcTax":
if (pspInclEx) {
pspInclEx.innerHTML = temp[i].childNodes[0].nodeValue;
}
break;
case "quantity":
with (temp[i].childNodes[0]) {
if (nodeValue != "") {
if (psp) {
psp.innerHTML += nodeValue;
} else {
thePrice.innerHTML += nodeValue;
}
this.updSP();
}
}
break;
Then in includes/classes/dynamic_price_updater.php within the prepareOutput function modifying (for now) the area in blue below (a similar modification will be incorporated for when not showing the currency symbols, but first am trying to get through with when they are displayed):
Code:
if (DPU_SHOW_CURRENCY_SYMBOLS == 'false') {
$decimal_places = $currencies->get_decimal_places($_SESSION['currency']);
$this->responseText['priceTotal'] .= number_format($this->shoppingCart->total, $decimal_places);
} else {
$this->responseText['priceTotal'] .= $currencies->display_price($this->shoppingCart->total, zen_get_tax_rate($product_check->fields['products_tax_class_id'])/* 0 */ /* DISPLAY_PRICE_WITH_TAX */);
}
Incorporate the following (in red, the "blue" line remains unchanged):
Code:
if (DPU_SHOW_CURRENCY_SYMBOLS == 'false') {
$decimal_places = $currencies->get_decimal_places($_SESSION['currency']);
$this->responseText['priceTotal'] .= number_format($this->shoppingCart->total, $decimal_places);
} else {
$product_tax_class_id = zen_products_lookup((int)$_POST['products_id'], 'products_tax_class_id');
$tax_rate = zen_get_tax_rate($product_tax_class_id); // Rate comes back as a "whole number" such as 20% returns 20 and NOT 0.20
if (DISPLAY_PRICE_WITH_TAX != 'false') {
$price_without_tax = 100.0 * $this->shoppingCart->total / ($tax_rate + 100.0); // Price of product without tax
$this->responseText['priceTotalInclExcTax'] = $this->responseText['priceTotal'] . $currencies->display_price($price_without_tax, 0);
$this->responseText['priceTotalExcTax'] = $currencies->display_price($price_without_tax, 0);
} else {
$this->responseText['priceTotalInclExcTax'] = $this->responseText['priceTotal'] . $currencies->display_price($this->shoppingCart->total + zen_calculate_tax($this->shoppingCart->total, $tax_rate), 0);
$this->responseText['priceTotalInclTax'] = $currencies->display_price($this->shoppingCart->total + zen_calculate_tax($this->shoppingCart->total , $tax_rate), 0);
}
$this->responseText['priceTotal'] .= $currencies->display_price($this->shoppingCart->total, 0)/* 0 */ /* DISPLAY_PRICE_WITH_TAX */;
}
I may add a "switch" to the jscript file to detect if the incl/exc VAT plugin is installed/enabled/active, but need to identify what would trigger that "knowledge". Otherwise, for non-users of that code, additional javascript is sent to a browser and possibly a little processing speed/time by calculating the opposite price of what the store is showing on page load/attribute change with no other ill effect(s) by this change.
Quote:
Originally Posted by
dharrison
I did this and as a result the including VAT price now has a strikethrough
Attachment 17049
This stopped the Price Updater working
The DPU doesn't work at the moment. I have followed your instructions clearly twice now with the same result.
It seems that there are other changes that have been made unrelated to the above suggestions to support continued display of both included and excluded taxes. Possibly something modified in the includes/classes/dynamic_price_updater.php file? Or more likely based on system response, the includes/configure.php file has been modified for this sub-directory store, because from the above link, clicking on anything there takes one to the "live" store instead of remaining in the temporary store.
I've "externally" checked what is presented at the provided link and while initially the page loads just fine, all of the links point to the main directory not to the "temporary" directory that appears to have been created. This then causes thing like the ajax to fail because it look like there is a cross browser type situation occurring. When the default sub-directory is removed, then the site loads, and as of just now, DPU is working as it originally was recently provided, but without edits suggested above being visible. So, it seems that the primary issue over the last few days related to the provided link is that it did not direct/redirect to a properly formed/generated site, therefore any other issues at that point were unrelated to DPU.
As to the line through with the normalprice class, yeah I can see how the use of that class is already designated to format with a line-through (the normalprice class is used when the normal price is displayed and some other price is present such as a special or a sale). Not using a class of some type in that area causes the overall price swap to fail/cause what is being seen of the entire "block" being replaced. Perhaps use of normalInclExcPrice as the class to be used to support swapping could work. That way at least the price is editable without a lot of text manipulation or substitution. It somewhat depends on what is desired/necessary. I have installed a version of the includes/excludes VAT price module and have been working on a solution that does not require an additional incl/exc VAT function with the current result being that on change of the attribute, both the included and excluded VAT price are shown, but the sale, special, etc.. price has been replaced as well thus far in testing. It would be nice to just replace the necessary values, which in part I have been able to do, but further ideally would be for this plugin to be provided to operate as normal without any subsequent changes and to also operate "as normal" with the incl/exc VAT plugin such that again no code changes to DPU would be necessary. It does look like though that the incl/exc VAT plugin could use a few tweaks to support being installed, to have the necessary switch adjustments to affect display, but to also be "disabled" without having to be removed. I believe countrycharm had at one point posted a slightly updated version, but even that could use a few modifications to accomplish the installed but not adding to the returned text.
Re: Price Updater - plugin keeps disabling
@dharrison - is just me or does the zenID also appear for you on every link?
To prevent that:
Admin -> Configuration -> Sessions
Cookie Domain
Force Cookie Use
- make sure they both say True
Also, you have some links in the HTML HEADER using "http://" links instead of "https://" which is causing my Browser to give Warning msgs.
Re: Price Updater - plugin keeps disabling
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
Code:
<?php if (DPU_SHOW_LOADING_IMAGE == 'true') { ?>
sections.
Re: Price Updater - plugin keeps disabling
Quote:
Originally Posted by
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
Code:
<?php if (DPU_SHOW_LOADING_IMAGE == 'true') { ?>
sections.
Danke, webchills,
Have confirmed the same lack of response when set to false, looking into the why and how to resolve.
Re: Price Updater - plugin keeps disabling
Quote:
Originally Posted by
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
Code:
<?php if (DPU_SHOW_LOADING_IMAGE == 'true') { ?>
sections.
See commits:
(includes/modules/pages/product_info)
https://github.com/mc12345678/Dynami...f6e0dc82d089b9
and:
(includes/modules/pages/product_music_info)
https://github.com/mc12345678/Dynami...d9c1ae60d810dc
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.
Re: Price Updater - plugin keeps disabling
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...
Re: Price Updater - plugin keeps disabling
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/heig...dule-p-29.html
Re: Price Updater - plugin keeps disabling
Quote:
Originally Posted by
dharrison
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:
Code:
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.
Code:
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.
Re: Price Updater - plugin keeps disabling
Thanks. The first method worked.
Re: Price Updater - plugin keeps disabling
Quote:
Originally Posted by
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:
Code:
define('CONSTANT', 'suffix text');
define('CONSTANT2', 'other suffix text');