-
Re: Attribute image replaces main product image on selecting attribute
Hey MC, I think I catch a bug.
Everything was working fine until today 2 items had the alternative color "1st" in the options list. The main picture will change to the LAST option of the list (even if is not the default). I thought that uploading the image for that option will fix the issue (since customer is not uploading picture for the attribute if the option is the main image); but that didn't fix it.
I also tried using the "default" button for the attribute, and doesn't work neither.
I can sen you by PM the links for you to take a look.
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
ideasgirl
Hey MC, I think I catch a bug.
Everything was working fine until today 2 items had the alternative color "1st" in the options list. The main picture will change to the LAST option of the list (even if is not the default). I thought that uploading the image for that option will fix the issue (since customer is not uploading picture for the attribute if the option is the main image); but that didn't fix it.
I also tried using the "default" button for the attribute, and doesn't work neither.
I can sen you by PM the links for you to take a look.
Please do.
-
Re: Attribute image replaces main product image on selecting attribute
If I understand correctly (not yet having received the link(s)), there are two or more attributes (option names), each has at least one option value that has an attribute image. When chosen or set, the image for the last option name is what is presented?
Or is it option 2, where the image of the last available selection is the one presented? (ie. 2 or more option names and it is the last option value out of all of the option names that shows the replaced image.)
Again, I expect to understand better once the link(s) received, but helps to identify the issue if a little more clarity can be provided. :)
-
Re: Attribute image replaces main product image on selecting attribute
Okay, I have some answers now.
Basic description is a single option name, multiple option values.
Now, for the "fun" part...
When page is loaded and ALLLLLL javascript has completed, each of the option values have been selected and Attribute Image Swap has attempted to resolve the image for each such selection. The source of this event is one of many javascript operations that execute onload. Additionally, there are three versions of jquery loaded, there are html validation errors, and I am not sure which type of viewer is used to make the image larger, but it does not look like the colorbox version available for download from the plugins, also it is using an older javascript version of the colorbox javascript. I imagine it is something to do with whatever javascript compression/loader is being used, but there is something that seems to systematically select each of the attribute options. With so many scripts involved and such a long load time for the entire page (144.95 seconds to load 4,397.91 KB with 116 requests) then on a page reload: 98 requests 5,164.76 KB, 91.30 seconds.
Ohhh.. And might suggest using the latest version of the plugin. The version installed/edited does not include the use of the ZC zcJS javascript variable (even if that variable is not present), which means that the issue(s) identified, corrected, and associated with the previous version remain.
-
Re: Attribute image replaces main product image on selecting attribute
Correct. There is 1 option name, few options value; and the last option value is the presented.
Quote:
Or is it option 2, where the image of the last available selection is the one presented? (ie. 2 or more option names and it is the last option value out of all of the option names that shows the replaced image.)
How should I know which one to eliminate?
Quote:
Additionally, there are three versions of jquery loaded, ...
Lightbox is the viewer for larger image (and IH4 ins installed). I will check the colorbox scripts and versions.
Quote:
... there are html validation errors, and I am not sure which type of viewer is used to make the image larger, but it does not look like the colorbox version available for download from the plugins, also it is using an older javascript version of the colorbox javascript.
Correct. That was my thought at the beginning, but since it changes the image AFTER all the loading it threw me off. :wacko:
Quote:
I imagine it is something to do with whatever javascript compression/loader is being used, but there is something that seems to systematically select each of the attribute options.
I will see if programmer that created template and did the integration of the plugin will do that.
Quote:
Ohhh.. And might suggest using the latest version of the plugin. The version installed/edited does not include the use of the ZC zcJS javascript variable (even if that variable is not present), which means that the issue(s) identified, corrected, and associated with the previous version remain.
-
Re: Attribute image replaces main product image on selecting attribute
Sorry, on a mobile device making "part" answers time consuming:
Quote:
Originally Posted by
ideasgirl
Correct. There is 1 option name, few options value; and the last option value is the presented.
How should I know which one to eliminate?
Lightbox is the viewer for larger image (and IH4 ins installed). I will check the colorbox scripts and versions.
Correct. That was my thought at the beginning, but since it changes the image AFTER all the loading it threw me off. :wacko:
I will see if programmer that created template and did the integration of the plugin will do that.
Generally speaking, there should only be the latest version needed to support operation installed... but, there are "tools" that make it possible for multiple versions which it appears to be the case, though 1.4.4 I think it was, is significantly old and whatever is requiring that should be updated or abandoned (in my opinion).
As to lightbox, if discussing the version that is available for download (which it looks like it is), there is software upon which it depends (slimbox) that has been abandoned and not being updated at least as of a few years ago. Colorbox and it's foundation continue to be supported.
Regarding the last two items, if memory serves (and based on the change notes for the most recent version), the problem seen (last option value of an option name always becoming active on initial load) was a reason for the most recent version being published. As other issues were corrected (js error on initial page load that did not have the product in the cart), the code was seeking through all checkbox and radio selections to land or ultimately go with the last one. This was corrected in the ais_init() function around line 176 where a check was performed to see if the selection had been checked before attempting to execute the associated onclick action. At least adding that if around the area would resolve the described issue, but would suggest a full update instead of just that line change. Update is to simply replace the files and as necessary incorporate any modifications that may have been made. Based on the visible javascript code, version 1.5.7 is installed with v1.5.8 released a few weeks ago (5 days after the version currently installed) that corrected the identified issue.
-
Re: Attribute image replaces main product image on selecting attribute
Thank you very much MC :hug:I managed to update those jscripts and upgrade the module and that not only made the trick it also made the loading time much faster. :smartalec:
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
ideasgirl
Thank you very much MC :hug:I managed to update those jscripts and upgrade the module and that not only made the trick it also made the loading time much faster. :smartalec:
Glad that it all worked for the better. :)
-
Re: Attribute image replaces main product image on selecting attribute
zc 1.5.5f new install test site; clone of responsive_classic template, IH5, newest Colorbox, newest SbyA, newest Attrib Image Swap
I'm playing with this Attrib Image Swap version July 2017 on test site. In Beyond Compare I'm looking at a difference I don't know how to merge in includes/modules/YOUR_TEMPLATE/attributes.php
In the Image Swap Version, around line #188:
Code:
$products_options_array[sizeof($products_options_array)-1]['text'] .= $products_options_display_price;
// collect weight information if it exists
if (($flag_show_weight_attrib_for_this_prod_type=='1' and $products_options->fields['products_attributes_weight'] != '0')) {
$products_options_display_weight = ATTRIBUTES_WEIGHT_DELIMITER_PREFIX . $products_options->fields['products_attributes_weight_prefix'] . round($products_options->fields['products_attributes_weight'],2) . TEXT_PRODUCT_WEIGHT_UNIT . ATTRIBUTES_WEIGHT_DELIMITER_SUFFIX;
$products_options_array[sizeof($products_options_array)-1]['text'] .= $products_options_display_weight;
In the same file I previously merged with Stock by Attributes, the same lines are:
Code:
$products_options_array[count($products_options_array)-1]['text'] .= $products_options_display_price;
// collect weight information if it exists
if (($flag_show_weight_attrib_for_this_prod_type=='1' and $products_options->fields['products_attributes_weight'] != '0')) {
$products_options_display_weight = ATTRIBUTES_WEIGHT_DELIMITER_PREFIX . $products_options->fields['products_attributes_weight_prefix'] . round($products_options->fields['products_attributes_weight'],2) . TEXT_PRODUCT_WEIGHT_UNIT . ATTRIBUTES_WEIGHT_DELIMITER_SUFFIX;
$products_options_array[count($products_options_array)-1]['text'] .= $products_options_display_weight;
} else {
Which should I use?
Thanks!
-
Re: Attribute image replaces main product image on selecting attribute
At this very moment, it does not matter which. There has been some discussion by the php powers that be that sizeof (alias to count) will go away in future php versions. It was thought (and at one point voted) to be removed in php 7.2, but as of yet has not.
That said, I would suggest that count be used if either of them are to be used. Again it mostly likely is a non-issue either way, but certainly makes it easier to be consistent.
-
Re: Attribute image replaces main product image on selecting attribute
Thanks for answer to previous q.
New question.
Using test site on wamp with zc1.5.5f, IH5, clone of responsive_classic, SbyA 1.54 for zc 1.5.5f, Colorbox 2.1.2. , One Page Checkout most current, wamp php 7.1.13, one category with one product. Product has 4 size attributes with stock. Product info has 4 additional images (not attribute). Size attribute photos installed via attributes controller. All photos are jpg.
Dynamic Dropdowns set to 0 (off)
SbyA config in Stock - Display Attribute images set to 1. (tried setting as on with single attribute option and radio selected)
Attribute Settings - Enable attribute images set to true.
IH5 set to resize images, on. (also tried with set to off)
Option Name controller- Size attribute set to radio, and display option 6 selected with images per row left blank (also tried 1, 4). (also tried display option 7 and 8)
When clicking on the size radio button on the product page the attribute image is not swapping in. Also tried removing the non-attribute additional images from the propduct info page.
The following error gets logged when attempting to select an attribute:
Code:
05-Feb-2018 01:08:42 UTC] PHP Fatal error: Uncaught Error: Call to a member function notify() on null in C:\wamp\www\includes\modules\doug_responsive\main_product_image.php:19
Stack trace:
#0 C:\wamp\www\includes\classes\ajax\zcAttrib_prod_info.php(48): require_once()
#1 C:\wamp\www\ajax.php(76): zcAttrib_prod_info->swap_image()
#2 {main}
thrown in C:\wamp\www\includes\modules\doug_responsive\main_product_image.php on line 19
I note that main_prodcut_image.php line 19 is a merged change from IH5. Beyond that, I haven't a clue what the error means ;-)
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
soxophoneplayer
Thanks for answer to previous q.
New question.
Using test site on wamp with zc1.5.5f, IH5, clone of responsive_classic, SbyA 1.54 for zc 1.5.5f, Colorbox 2.1.2. , One Page Checkout most current, wamp php 7.1.13, one category with one product. Product has 4 size attributes with stock. Product info has 4 additional images (not attribute). Size attribute photos installed via attributes controller. All photos are jpg.
Dynamic Dropdowns set to 0 (off)
SbyA config in Stock - Display Attribute images set to 1. (tried setting as on with single attribute option and radio selected)
Attribute Settings - Enable attribute images set to true.
IH5 set to resize images, on. (also tried with set to off)
Option Name controller- Size attribute set to radio, and display option 6 selected with images per row left blank (also tried 1, 4). (also tried display option 7 and 8)
When clicking on the size radio button on the product page the attribute image is not swapping in. Also tried removing the non-attribute additional images from the propduct info page.
The following error gets logged when attempting to select an attribute:
Code:
05-Feb-2018 01:08:42 UTC] PHP Fatal error: Uncaught Error: Call to a member function notify() on null in C:\wamp\www\includes\modules\doug_responsive\main_product_image.php:19
Stack trace:
#0 C:\wamp\www\includes\classes\ajax\zcAttrib_prod_info.php(48): require_once()
#1 C:\wamp\www\ajax.php(76): zcAttrib_prod_info->swap_image()
#2 {main}
thrown in C:\wamp\www\includes\modules\doug_responsive\main_product_image.php on line 19
I note that main_prodcut_image.php line 19 is a merged change from IH5. Beyond that, I haven't a clue what the error means ;-)
So the error message above:
Code:
05-Feb-2018 01:08:42 UTC] PHP Fatal error: Uncaught Error: Call to a member function notify() on null in C:\wamp\www\includes\modules\doug_responsive\main_product_image.php:19
Stack trace:
#0 C:\wamp\www\includes\classes\ajax\zcAttrib_prod_info.php(48): require_once()
#1 C:\wamp\www\ajax.php(76): zcAttrib_prod_info->swap_image()
#2 {main}
thrown in C:\wamp\www\includes\modules\doug_responsive\main_product_image.php on line 19
is reporting an issue with this line:
Code:
$zco_notifier->notify('NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_START');
Specifically saying that member function notify() is being called on an undefined variable. The "undefined" variable is $zco_notifier. In ZC this is defined as a "global" type variable and in "normal" operation (viewing of a product) the main_product_image.php module file is in the global space and therefore $zco_notifier is defined. The way that this module has been put together, that module file is called within a class so that the operations performed by that module do not have to be rewritten and historically have fallen in line with the initial provided data to give a final result. That said, though, IH5 introduced notifiers into the module file, which in design is not a problem, but this module did not previously include all of the ZC defined "global" variables that are possible (not needed, don't include them right?)
So, to resolve this there are two approaches that can be taken. One specifically for this plugin, one that could be done for the modified main_product_file, although the modification suggested for that file would not be historically consistent with other files that are expected to be in the global space.
For this module (or of course any module that was including the main_product_image.php file outside of the global space) look at includes/classes/ajax/zcAttrib_prod_info.php and modify this portion
from:
Code:
function swap_image()
{
global $db;
to:
Code:
function swap_image()
{
global $db, $zco_notifier;
And that will resolve the issue.
Another supposedly "acceptable" modification would be to define $zco_notifier to be equal to the current class because the current class extends the base class and that means that the current class also has access to the notify member function, so:
Code:
function swap_image()
{
global $db;
$products_options_values_id = (int)$_POST['products_options_values_id'];
could become:
Code:
function swap_image()
{
global $db;
$zco_notifier = $this;
$products_options_values_id = (int)$_POST['products_options_values_id'];
But then below this point $zco_notifier could be accessed like: $zco_notifier->swap_image() which may not seem right... :P
or it could be rewritten like this:
Code:
function swap_image()
{
global $db;
$zco_notifier = $GLOBALS['zco_notifier'];
$products_options_values_id = (int)$_POST['products_options_values_id'];
For the time being, I'd go with the first suggestion. :)
The other alternative suggestion which doesn't exactly go in line with other modules using an notifier would be to modify the includes/modules/YOUR_TEMPLATE/main_product_image.php file from:
Code:
// This notifier lets an observer know that the module has begun its processing.
//
$zco_notifier->notify('NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_START');
to:
Code:
// This notifier lets an observer know that the module has begun its processing.
//
if (!isset($zco_notifier)) {
global $zco_notifier;
}
$zco_notifier->notify('NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_START');
or similar to bring $zco_notifier into the space of the module. Thing is, generally speaking whatever the module needs to be able to operate, the calling/including/requiring code probably should be sure to provide to it, even if there has been a change in how the module operates/is written. For example if the module did something with money, then likely the $currencies global variable would need to be made available for it to do its business.
Thank you for identifying this issue, I am incorporating the first suggestion above into the file on github as addressed in issue #2 and this commit.
-
Re: Attribute image replaces main product image on selecting attribute
I tried suugestion #1 and that indeed worked. Many thanks!
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
soxophoneplayer
I tried suugestion #1 and that indeed worked. Many thanks!
Glad that worked. It's incorporated into the github distribution for the next version.
Hopefully also revisited the settings for SBA as a few of those described (understandably set at time of posting to just try anything to get it to work) would not support the expected operation at least as provided in the fileset. Thank you though for identifying all the interconnected modules and that things are working. It certainly is a lot to have all together.
-
Re: Attribute image replaces main product image on selecting attribute
I hope you can help me with this plugin as well. I have a custom theme that I purchased elsewhere, and it is causing me all sorts of headaches as they don't seem to be following the ZC convention for some things. Basically, so far I managed to get most div ids and tags changed to make it compatible, however the theme handles the onchange events via custom script to update price.
Here is the snippet from the init() function that handles such events:
Code:
var n=theForm.elements.length;
for (var i=0; i<n; i++) {
switch (theForm.elements[i].type) {
case 'select':
case 'select-one':
theForm.elements[i].onchange = function () { xhr.getPrice(); }
break;
case 'text':
theForm.elements[i].onkeyup = function () { xhr.getPrice(); }
break;
case 'checkbox':
case 'radio':
theForm.elements[i].onclick = function () { xhr.getPrice(); }
break;
}
}
What I am trying to do is to add the getattribimage() function to each of the above and pass the right parameneters but I am hitting the limits of my knowledge.
Could you please suggest the fix?
Thank you!
Dave
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
dvtalk
I hope you can help me with this plugin as well. I have a custom theme that I purchased elsewhere, and it is causing me all sorts of headaches as they don't seem to be following the ZC convention for some things. Basically, so far I managed to get most div ids and tags changed to make it compatible, however the theme handles the onchange events via custom script to update price.
Here is the snippet from the init() function that handles such events:
Code:
var n=theForm.elements.length;
for (var i=0; i<n; i++) {
switch (theForm.elements[i].type) {
case 'select':
case 'select-one':
theForm.elements[i].onchange = function () { xhr.getPrice(); }
break;
case 'text':
theForm.elements[i].onkeyup = function () { xhr.getPrice(); }
break;
case 'checkbox':
case 'radio':
theForm.elements[i].onclick = function () { xhr.getPrice(); }
break;
}
}
What I am trying to do is to add the getattribimage() function to each of the above and pass the right parameneters but I am hitting the limits of my knowledge.
Could you please suggest the fix?
Thank you!
Dave
I'd suggest upgrading the special "price" program to use Dynamic Price Updater or at least for it to use similar code.
For example the above portion was changed to:
Code:
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;
}
}
One reason for this change was that the use of .onchange prevented other javascript from executing which is basically what you seem to be describing.
-
Re: Attribute image replaces main product image on select [Support Thread]
Sorry, I think I should have copied the entire function:
Code:
var xhr = new objXHR;
function init() {
var n=document.forms.length;
for (var i=0; i<n; i++) {
if (document.forms[i].name == theFormName) {
theForm = document.forms[i];
continue;
}
}
var n=theForm.elements.length;
for (var i=0; i<n; i++) {
switch (theForm.elements[i].type) {
case 'select':
case 'select-one':
theForm.elements[i].onchange = function () { xhr.getPrice(); }
theForm.elements[i].onchange = function () { getattribimage(); }
break;
case 'text':
theForm.elements[i].onkeyup = function () { xhr.getPrice(); }
break;
case 'checkbox':
case 'radio':
theForm.elements[i].onclick = function () { xhr.getPrice(); }
break;
}
}
<?php
$show_dynamic_price_updater_sidebox = true;
if ($show_dynamic_price_updater_sidebox == true)
{
?>
createSB();
<?php
}
?>
xhr.getPrice();
}
Their select tab does not have an "onchange". Instead, this is what a select menu looks like (example product):
Code:
<select name="id[4]" id="attrib-4" class="form-control">
<option value="1">4 mb</option>
<option value="2">8 mb ( +$50.00 )</option>
<option value="3">16 mb ( +$70.00 )</option>
</select>
Thanks for your help.
-
Re: Attribute image replaces main product image on select [Support Thread]
Please ignore line:
Code:
theForm.elements[i].onchange = function () { getattribimage(); }
It was an artifact of a test I was performing.
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
dvtalk
Sorry, I think I should have copied the entire function:
Code:
var xhr = new objXHR;
function init() {
var n=document.forms.length;
for (var i=0; i<n; i++) {
if (document.forms[i].name == theFormName) {
theForm = document.forms[i];
continue;
}
}
var n=theForm.elements.length;
for (var i=0; i<n; i++) {
switch (theForm.elements[i].type) {
case 'select':
case 'select-one':
theForm.elements[i].onchange = function () { xhr.getPrice(); }
theForm.elements[i].onchange = function () { getattribimage(); }
break;
case 'text':
theForm.elements[i].onkeyup = function () { xhr.getPrice(); }
break;
case 'checkbox':
case 'radio':
theForm.elements[i].onclick = function () { xhr.getPrice(); }
break;
}
}
<?php
$show_dynamic_price_updater_sidebox = true;
if ($show_dynamic_price_updater_sidebox == true)
{
?>
createSB();
<?php
}
?>
xhr.getPrice();
}
Their select tab does not have an "onchange". Instead, this is what a select menu looks like (example product):
Code:
<select name="id[4]" id="attrib-4" class="form-control">
<option value="1">4 mb</option>
<option value="2">8 mb ( +$50.00 )</option>
<option value="3">16 mb ( +$70.00 )</option>
</select>
Thanks for your help.
I'm very familiar with the way that code is/was written, again it is from Dynamic Price Updater. That section of code currently looks like:
Code:
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();
}
Regarding the "select" tab onchange statement, I think there is a lack of understanding in the whole situation.
In javascript, by setting the onchange event for a specific object (theForm.elements[I]) the event described on the right side dedicates the operation to occur for that event. When discussing a select menu item, the javascript onchange event is triggered any time the selection within the dropdown (select box) is changed. Hence onchange... By using "theForm.elements[I].onchange =" instead of "theForm.elements[I].addEventListener" any other "onchange" events defined by/for other javascript are basically cancelled unless the others can load later/after... It is this type of coding that is causing your issue (and one reason DPU was modified).
The price updater as previously written takes control of all of the attribute type selectors (select (dropdown), text box, checkbox, radio button, etc...) preventing any other javascript code from being able to respond... The above code modifies that operation so that instead of taking the event monitoring over it instead adds to the event list so that DPU can work WITH other javascript code not take it over...
The updated DPU code also takes advantage of ZCs ajax processing and offers a number of other improvements from where it was a while ago...
-
Re: Attribute image replaces main product image on select [Support Thread]
Here is the way this code renders:
Code:
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;
}
}
xhr.createSB();
xhr.getPrice();
}
Uncaught TypeError: xhr.createSB is not a function
at init (matrox-g200-mms-p-1.html:1329)
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
dvtalk
Here is the way this code renders:
Code:
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;
}
}
xhr.createSB();
xhr.getPrice();
}
Uncaught TypeError: xhr.createSB is not a function
at init (matrox-g200-mms-p-1.html:1329)
That would be because the third to last line is different between the two sets of code. There are also significant differences in the remainder of the code.
This particular forum thread is not about how to properly install/update some other plugin (in this case dynamic price updater) and while the version installed to the purchased template is causing problems with this plugin it would with almost any other that happens to load before DPU. Again, I encourage you to update Dynamic Price Updater in its entirety (not just to patch a line here or there) for several reasons such as previous versions (similar to what appears to be installed to that template) would not pass javascript page validation, do not take advantage of the ZC ajax process which in itself as I understand helps extend the users session time by recognizing that the user is taking action on the page, and also offers additional screen/content updating features that did not exist in previous versions.
I encourage that the issue be resolved; however, also suggest continuing to do that in a separate forum thread that is either directly applicable to DPU or in a newly started thread within the ZC forum. Ultimately, the custom theme developer should be approached to address these issues and that individual/organization should support resolving the problem that they have created.
-
Re: Attribute image replaces main product image on select [Support Thread]
I understand what you are saying. I misunderstood your first reply, I thought you were showing a fix. I checked DPU version and it's 3.0 which I understand is several versions behind. I will try to update the DPU to 3.2.0 first, and then try and go back to Image Swap fix. IUnfortunately the template maker is not cooperating so that avenue is not available to me.
Thanks again, will post with an update.
David
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
mc12345678
Again, I encourage you to update Dynamic Price Updater in its entirety (not just to patch a line here or there) for several reasons such as previous versions (similar to what appears to be installed to that template) would not pass javascript page validation, do not take advantage of the ZC ajax process which in itself as I understand helps extend the users session time by recognizing that the user is taking action on the page, and also offers additional screen/content updating features that did not exist in previous versions.
Thanks for pointing me to the right direction. After updating the DPU, adding back the <div id="productMainImage"> to the tpl_modules_main_product_image.php that the theme authors have omitted, and installing the Attribute image plugin, it is finally working!
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
dvtalk
Thanks for pointing me to the right direction. After updating the DPU, adding back the <div id="productMainImage"> to the tpl_modules_main_product_image.php that the theme authors have omitted, and installing the Attribute image plugin, it is finally working!
Glad that worked out. Yeah, I had considered adding a field to the configuration to support use of an alternate id field, but had been working to make improvements in some relative steps.
If you have the "time" I would suggest comparing other template files for that template to see what, if anything else, is missing. Of course it will be affected by the associated css, so keep that in mind as you go along.
-
Re: Attribute image replaces main product image on select [Support Thread]
Here is what I had to do to successfully install this plugin with third party theme (claiming to be ZC 1.5.5.f compatible):
Copy/overwrite admin/includes/languages/english/options_name_manager.php
Copy/overwrite admin/options_name_manager.php
Copy/overwrite includes/modules/alto/attributes.php
Copy admin/includes/auto_loaders/config.attribute_image_swap.php
Copy includes/classes/observers/auto.attrib_image_swap.php
Copy includes/modules/pages/product_info/jscript_ais.php
Did not copy includes/modules/pages/product_info/on_load_ais.js - not sure what this does
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
dvtalk
Here is what I had to do to successfully install this plugin with third party theme (claiming to be ZC 1.5.5.f compatible):
Copy/overwrite admin/includes/languages/english/options_name_manager.php
Copy/overwrite admin/options_name_manager.php
Copy/overwrite includes/modules/alto/attributes.php
Copy admin/includes/auto_loaders/config.attribute_image_swap.php
Copy includes/classes/observers/auto.attrib_image_swap.php
Copy includes/modules/pages/product_info/jscript_ais.php
Did not copy includes/modules/pages/product_info/on_load_ais.js - not sure what this does
Without this (when the plugin is installed on its own), effectively by omitting that file when returning to the product from the shopping cart the image will not update to what was identified as the current selection until one of the options is changed.
It establishes an action to be performed when the page has been loaded (on_load event).
As to the other files, the changes made to support the plugin should be incorporated into the existing files rather than "blindly" overwriting/replacing the files. That is relatively true for all plugins.
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
mc12345678
Without this (when the plugin is installed on its own), effectively by omitting that file when returning to the product from the shopping cart the image will not update to what was identified as the current selection until one of the options is changed.
It establishes an action to be performed when the page has been loaded (on_load event).
As to the other files, the changes made to support the plugin should be incorporated into the existing files rather than "blindly" overwriting/replacing the files. That is relatively true for all plugins.
I actually did that, but decided that overwriting was the best course of action (there were minimal to no changes in files overwritten).
As far as on_load_ais.js, even after copying this to the site, I am not getting the image updated when I click the product with attributes ion shopping cart. All attribuites get populated properly. I made sure that only the one that affects the image is set to Type: 8, and rest are set to 7 (also tried 0).
Not sure if this is relevant but I am getting these errors from Chrome dev console, when I load that product page with attributes string (without attributes, no errors).
TypeError: theForm.elements[i].onclick is not a function
at ais_init (index.php?main_page=product_info&products_id=341:4e7c3b0ed19dda8c9e17d0ed3c3a1a 30:1683)
at onload (index.php?main_page=product_info&products_id=341:4e7c3b0ed19dda8c9e17d0ed3c3a1a 30:111)
Can you please help me track this (hopefully), final problem down?
Thanks,
David
-
Re: Attribute image replaces main product image on select [Support Thread]
Did a lot of digging but still cannot figure out. It sems that
Quote:
TypeError: theForm.elements[i].onclick is not a function
is pointing to this section of the ais_init() function:
Code:
case "radio":
if (document.getElementById(theForm.elements[i].id).checked) {
theForm.elements[i].onclick();
}
break;
All attributes get populated properly, just not the image swap.
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
dvtalk
Did a lot of digging but still cannot figure out. It sems that is pointing to this section of the ais_init() function:
Code:
case "radio":
if (document.getElementById(theForm.elements[i].id).checked) {
theForm.elements[i].onclick();
}
break;
All attributes get populated properly, just not the image swap.
Had looked into this issue/situation (not only yesterday but I seem to recall some time ago as well). So here's the thing(s).
AIS applies actions only to applicable attributes that are to cause an image swap, and this is done when generating the attribute list. Therefore, it is possible that a product having attributes may not have an attribute image swap update request for all attributes. I saw two central ways to address/prevent this as far as just this plugin is concerned, one is to move the application of the action to outside of the attribute generation and into more of the ajax arena which should then also make that initial call more adaptable to only try to update the element(s) that are a part of the image swap. The other is to apply some action of some type to all attributes, whether the action causes an update or not.
Considering that DPU is also installed, the second option is relatively present assuming that the load/execution sequence of the javascript can be "controlled" if by nothing than alphabetical sorting. Might I suggest attempting to rename includes/modules/pages/product_info/on_load_ais.js to something like on_load_zais.js and seeing if that resolves the issue for now?
Another option which would involve minimal redevelopment would be to use try/catch style code in the ais_init function (prevents the need to identify/lookup the event(s) to see if they exist against the element.)
Ie. in includes/modules/pages/product_info/jscript_ais.php change:
Code:
switch (theForm.elements[i].type) {
case "select":
case "select-one":
theForm.elements[i].onchange();
break;
case "text":
theForm.elements[i].onkeyup();
break;
case "checkbox":
case "radio":
if (document.getElementById(theForm.elements[i].id).checked) {
theForm.elements[i].onclick();
}
break;
case "number":
theForm.elements[i].onchange();
theForm.elements[i].onkeyup();
theForm.elements[i].oninput();
break;
}
to:
Code:
switch (theForm.elements[i].type) {
case "select":
case "select-one":
try {
theForm.elements[i].onchange();
} catch(err) {
// Action not associated with element.
}
break;
case "text":
try {
theForm.elements[i].onkeyup();
} catch(err) {
// Action not associated with element.
}
break;
case "checkbox":
case "radio":
if (document.getElementById(theForm.elements[i].id).checked) {
try {
theForm.elements[i].onclick();
} catch(err) {
// Action not associated with element.
}
}
break;
case "number":
try {
theForm.elements[i].onchange();
} catch(err) {
// Action not associated with element.
}
try {
theForm.elements[i].onkeyup();
} catch(err) {
// Action not associated with element.
}
try {
theForm.elements[i].oninput();
} catch(err) {
// Action not associated with element.
}
break;
}
-
Re: Attribute image replaces main product image on select [Support Thread]
#1 made no difference.
#2 try/catch blocks worked! - Thank you!
So, seems to be a conflict with DPU, or maybe the way my custom theme is handling it. Hope this can be fixed in the future versions.
Thanks again! Now can go back to rebuilding the rest of the modules.
David
-
Re: Attribute image replaces main product image on select [Support Thread]
Just a quick follow up, and this may be too much to ask, but what would it take to display the swapped image in the cart?
I think that would be a great addition to the script and will avoid potential confusion with the customer.
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
dvtalk
Just a quick follow up, and this may be too much to ask, but what would it take to display the swapped image in the cart?
I think that would be a great addition to the script and will avoid potential confusion with the customer.
I actually already started working on it. Will share when I have something, and may be you can impllement it in the next version, if it's worthy of implementation. I am not the cleanest coder. :)
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
dvtalk
Just a quick follow up, and this may be too much to ask, but what would it take to display the swapped image in the cart?
I think that would be a great addition to the script and will avoid potential confusion with the customer.
Quote:
Originally Posted by
dvtalk
I actually already started working on it. Will share when I have something, and may be you can impllement it in the next version, if it's worthy of implementation. I am not the cleanest coder. :)
So, I have/had already incorporated something into Stock By Attributes that does that, guess could add to this plugin a way to incorporate the functionality if it didn't/doesn't already exist.
See the function that begins here: https://github.com/mc12345678/Stock_...stock.php#L936
With the "meat" between lines 1024 and 1071 (though need to get through a few if statements to activate that code portion)
-
Re: Attribute image replaces main product image on select [Support Thread]
Here is what I came up with that works for me, with my limited hobbyist coding level.
includes/functions/extra_functions/functions_ais_cart.php
PHP Code:
<?php
/**
* includes/functions/extra_functions/functions_ais_cart.php
* ais
*
* @author DavidV
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License V2.0
* @version $Id: functions_ais_cart.php,v 1.0 Rev 1 2018-04-06 13:52:50
* Last modified by DavidV 2018-04-06 13:52:50
*/
/**
* Displays attribute images in cart for Attribute Image Swap 6 (AIS)
*/
function ais_cart_img_data($id,$attr){
global $db;
$sql = "SELECT attributes_image,options_values_id
from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib
where patrib.products_id=" . (int)$id . "
and patrib.options_id = popt.products_options_id
and popt.language_id = " . (int)$_SESSION['languages_id'] . "
and (popt.products_options_images_style = 6 OR popt.products_options_images_style = 8)";
$result = $db->Execute($sql);
return $result;
}
function ais_cart_img($id,$attr,$img,$img_name) {
$ais_support = defined('ATTRIBUTES_ENABLED_IMAGES') && ATTRIBUTES_ENABLED_IMAGES == 'true' && zen_has_product_attributes((int)$id);
if ($ais_support) {
$result = ais_cart_img_data($id,$attr);
if ($result->RecordCount() > 0){
$attr_cart = array();
foreach ($attr as $attrval)
array_push($attr_cart[$attrval['options_values_id']]);
$attr_all = array();
while (!$result->EOF) {
$attr_all[$result->fields['options_values_id']] = $result->fields['attributes_image'];
$result->MoveNext();
}
$img_attr = current(array_intersect_key($attr_all,$attr_cart));
if($img_attr)
return zen_image(DIR_WS_IMAGES.$img_attr,$img_name);
else
return $img;
}
else
return $img;
}
else
return $img;
}
LINE 67 tpl_shopping_cart_default.php
Replaced:
PHP Code:
<?php echo $product['productsImage']; ?>
With:
PHP Code:
<?php echo ais_cart_img($product['id'],$product['attributes'],$product['productsImage'],$product['productsName']); ?>
I am sure there is a more elegant way to do this but it serves the purpose for now.
Once again, thankls for all your help!
-
Re: Attribute image replaces main product image on select [Support Thread]
Slight change to functions_ais_cart.php
ais_cart_img_data only needs an $id argument.
Also further consolidated the code.
PHP Code:
<?php
/**
* includes/functions/extra_functions/functions_ais_cart.php
* @author DavidV (dvtalk)
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License V2.0
* @version $Id: functions_ais_cart.php,v 1.0.1 2018-04-07
* Displays attribute images in cart for Attribute Image Swap 6 (AIS)
*/
function ais_cart_img_data($id){
global $db;
$sql = "SELECT attributes_image,options_values_id
from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib
where patrib.products_id=" . (int)$id . "
and patrib.options_id = popt.products_options_id
and popt.language_id = " . (int)$_SESSION['languages_id'] . "
and (popt.products_options_images_style = 6 OR popt.products_options_images_style = 8)";
return $db->Execute($sql);
}
function ais_cart_img($id,$attr,$img,$img_name) {
$img_attr = false;
$ais_support = defined('ATTRIBUTES_ENABLED_IMAGES') && ATTRIBUTES_ENABLED_IMAGES == 'true' && zen_has_product_attributes((int)$id);
if ($ais_support) {
$result = ais_cart_img_data($id);
if ($result->RecordCount() > 0){
$attr_cart = array();
foreach ($attr as $attrval)
array_push($attr_cart[$attrval['options_values_id']]);
$attr_all = array();
while (!$result->EOF) {
$attr_all[$result->fields['options_values_id']] = $result->fields['attributes_image'];
$result->MoveNext();
}
$img_attr = current(array_intersect_key($attr_all,$attr_cart));
}
}
if($img_attr)
return zen_image(DIR_WS_IMAGES.$img_attr,$img_name);
else
return $img;
}
-
Re: Attribute image replaces main product image on select [Support Thread]
One more edit. array_push() was improperly used.
PHP Code:
<?php
/**
* includes/functions/extra_functions/functions_ais_cart.php
* @author DavidV (dvtalk)
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License V2.0
* @version $Id: functions_ais_cart.php,v 1.0.1 2018-04-07
* Displays attribute images in cart for Attribute Image Swap 6 (AIS)
*/
function ais_cart_img_data($id){
global $db;
$sql = "SELECT attributes_image,options_values_id
from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib
where patrib.products_id=" . (int)$id . "
and patrib.options_id = popt.products_options_id
and popt.language_id = " . (int)$_SESSION['languages_id'] . "
and (popt.products_options_images_style = 6 OR popt.products_options_images_style = 8)";
return $db->Execute($sql);
}
function ais_cart_img($id,$attr,$img,$img_name) {
$img_attr = false;
$ais_support = defined('ATTRIBUTES_ENABLED_IMAGES') && ATTRIBUTES_ENABLED_IMAGES == 'true' && zen_has_product_attributes((int)$id);
if ($ais_support) {
$result = ais_cart_img_data($id);
if ($result->RecordCount() > 0){
$attr_cart = array();
foreach ($attr as $attrval)
$attr_cart[$attrval['options_values_id']]=1;
$attr_all = array();
while (!$result->EOF) {
$attr_all[$result->fields['options_values_id']] = $result->fields['attributes_image'];
$result->MoveNext();
}
$img_attr = current(array_intersect_key($attr_all,$attr_cart));
}
}
if($img_attr)
return zen_image(DIR_WS_IMAGES.$img_attr,$img_name);
else
return $img;
}
-
Re: Attribute image replaces main product image on select [Support Thread]
Used a different approach but have incorporated some similar operation into what is to be considered version 1.5.9 of this plugin (including other corrections/changes). This uses the notifier for the shopping_cart page (no template file editing) to replace the product image with the attribute image swapped image. Can see this arrangement at: https://github.com/mc12345678/Attrib...ap/tree/v1.5.9
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
mc12345678
Used a different approach but have incorporated some similar operation into what is to be considered version 1.5.9 of this plugin (including other corrections/changes). This uses the notifier for the shopping_cart page (no template file editing) to replace the product image with the attribute image swapped image. Can see this arrangement at:
https://github.com/mc12345678/Attrib...ap/tree/v1.5.9
This is great. While my approach serves the purpose for now, I will use updated version as soon as it is released. Thanks for considering, and support.
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
mc12345678
Used a different approach but have incorporated some similar operation into what is to be considered version 1.5.9 of this plugin (including other corrections/changes). This uses the notifier for the shopping_cart page (no template file editing) to replace the product image with the attribute image swapped image. Can see this arrangement at:
https://github.com/mc12345678/Attrib...ap/tree/v1.5.9
Thank you for this. I went ahead and downloaded the 1.5.9 from Github. Everything seems to be working woderfully, but I wonder if you can help me figure this out:
I am using an image plugin that displays a product zoom and I am attempting to merge the attributes.php file.
Your code is inserting $params into the select field, outputting:
<div class="select-wrapper"><select name="id[35]" id="attrib-35" onchange="getattribimage('id[35]', 450, 0, this.value, 508);">
Their code is simply:
<div class="select-wrapper"><select name="id[35]" id="attrib-35">
If I add the $params to the select, it breaks their code. If I don't insert the $params, then the image swap doesn't work.
Can you please point me to the right direction on where to lok for the conflict?
Thanks,
David
-
Re: Attribute image replaces main product image on select [Support Thread]
Quote:
Originally Posted by
dvtalk
Thank you for this. I went ahead and downloaded the 1.5.9 from Github. Everything seems to be working woderfully, but I wonder if you can help me figure this out:
I am using an image plugin that displays a product zoom and I am attempting to merge the attributes.php file.
Your code is inserting $params into the select field, outputting:
<div class="select-wrapper"><select name="id[35]" id="attrib-35" onchange="getattribimage('id[35]', 450, 0, this.value, 508);">
Their code is simply:
<div class="select-wrapper"><select name="id[35]" id="attrib-35">
If I add the $params to the select, it breaks their code. If I don't insert the $params, then the image swap doesn't work.
Can you please point me to the right direction on where to lok for the conflict?
Thanks,
David
"Their" method uses the standard attribute build which means that they also use javascript to initiate the action. How the javascript attaches and loads should help to resolve the issue. Would look to follow the javascript from page load to attribute change. (Most browsers support such action/operation.)
-
Re: Attribute image replaces main product image on select [Support Thread]
Thank you. Looks like this is quite complicated to integrate, so for now, giving up on this. One other thing I was curious about. The theme I am using has a Quick View mode, where you can order from within a product list page, via modal div. I was able to get the image and attributes to load correctly, however, how do I load the observer script that'll answer to the getattribimage() function?
-
Re: Attribute image replaces main product image on select [Support Thread]
Oh, that was easy. I just copied jscript_ais.php and on_load_ais.js to the /includes/modules/pages/index/ based on the page location I was on:
index.php?main_page=index&cPath=xxx_yyy
-
Re: Attribute image replaces main product image on selecting attribute
I used this plugin above 1.55, without any effect
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
jiji2018
I used this plugin above 1.55, without any effect
Welcome to Zen Cart. Please understand that in order to provide assistance, if any is needed, that the existing condition needs to be described. This is generally facilitated by addressing the posting tips items.
Explaining what has been done, possibly including a link to the site, the result(s) of taking action, etc... should make it possible to reproduce the issue so that time can be spent resolving the issue rather than having to pull out the details. Ie. Using the plugin without any effect, doesn't explain very much. If it were installed correctly and attribute images applied correctly and the settings modified by this plugin were selected (which has an effect on the system) then there should be some observable effect in the html code even if the image(s) don't swap. Further, even if all of that html code appears correctly, there may be other javascript on the page that doesn't play nicely or the page could not validate and cause other issues besides just with this plugin.
There's a lot of possibilities, but with your assistance of defining the conditions, issues, and results, then a solution to the problem experienced can be found. Help others help you.
-
4 Attachment(s)
Re: Attribute image replaces main product image on selecting attribute
Hello,
I have finished installing the plugin,my version is 1.5.5,but it is not work when select color option
below is the step i installed
1.I upload all files with ftp,and recover all files with same filename
2. I run sql_run.txt,&sql_run_missing_dropdowns.txt,after checking my database ,they are correct running.
3.then i add 'color' in admin--catelog-option name manager,radio button,input attribute 6
4. go to attriabutes controller and add 2 colors black ,blue to one of my product with product_id 1492
and add 2 attriabute images match black and blue
5.when i return the product page Hello,
I have finished installing the plugin,my version is 1.5.5,but it is not work when select color option
below is the step i installed
1.I upload all files with ftp,and recover all files with same filename
2. I run sql_run.txt,&sql_run_missing_dropdowns.txt,after checking my database ,they are correct running.
3.then i add 'color' in admin--catelog-option name manager,radio button,input attribute 6
4. go to attriabutes controller and add 2 colors black ,blue to one of my product with product_id 1492
and add 2 attriabute images match black and blue
5.when i return the product page ,there is not any changed to main page when i click black or blue
6 i tried changed the attriabute to dropdown and checkbox,same issue as above radio button
Attachment 17842Attachment 17843Attachment 17844
-
4 Attachment(s)
Re: Attribute image replaces main product image on selecting attribute
-
Re: Attribute image replaces main product image on selecting attribute
Although my email response did not seem to leave my outbox, I had evaluated the condition with the following response (please ignore cases of hashtags (#), they were generated when pasting the content and were not part of the original message):
Now that I have been able to see the page and evaluate the configuration as presented to a browser, I am able to identify the many changes that have been made to the standard template that are preventing operation of the plugin.
So, here are the things that I see.
1. It appears that the includes/modules/YOUR_TEMPLATE/attributes.php file or the changes made to it as compared to the default version provided in ZC 1.5.5 have not been incorporated into includes/modules/yourstore/attributes.php. If the file has been uploaded/incorporated, then either the observer file has not been uploaded or there is something else installed that is preventing application of the onchange event to the associated attribute(s).
2. The id for the main product image has been removed (should be mainProductImage). ##All that is present is:##<div class="back product-main-image__item main-img-zoom">.
3. I am not able at the moment to review the javascript to see if there is or would be a conflict. The plugin is written to add actions to existing actions when selecting an attribute; however, existing code if loaded after Attribute Image Swap may be written to replace existing actions. The issues above would need to be addressed and tested to further identify the presence of that issue.
##
Respectfully,
mc12345678
-
Re: Attribute image replaces main product image on selecting attribute
Over the weekend, submitted version 1.5.10 to this plugin. A version 1.5.9 was independently maintained in github with the changes from that incorporated into this.
The posted description was:
Quote:
Attribute image replaces main product image on sel ## - ## Version: v1.5.10
This update incorporates the changes made to support version 1.5.9 and 1.5.10.
Updated 06/16/19, V1.5.10: (mc12345678)
- Primarily updated what is now considered 1_Main_Files.
- Moved files into sub-folders to improve clarity of installation and to identify Zen Cart version specific files.
- Moved admin language defines out of the core language file for options_name_manager.php and placed in a separate file.
- Updated ajax.php file to the Zen Cart V1.5.6b version.
- Addressed a few minor PHP 7.3 related issues.
- Improved incorporation with Zen Colorbox.
- Added display of images for option type 6 when applied to radio buttons and checkboxes as if the image type had been set to 0.
- Added scope declaration for methods in the observer class.
- Updated install and remove SQL, including comments for understanding.
Updated 04/07/18, V1.5.9: (mc12345678)
- Added try/catch javascript style code to support return from shopping cart where attributes do not have an assigned action.
- Added observer to modify the shopping_cart image based on selections made when adding the product to the cart.
- Corrected an encoding issue with the ajax file (Changed from UTF-8 with BOM to ANSI)
- Added the $zco_notifier to the ajax file to support changes made in the module main_product_images to offer the use of observers.
- Reworked the ajax file to offer up-front processing.
- Added a function (get_attrib_image) to the observer class to reduce code redundancy and to offer a consistent image retrieval method.
Github location:
https://github.com/mc12345678/Attribute_image_Swap
This change has been posted for download at: https://www.zen-cart.com/downloads.php?do=file&id=699
-
Re: Attribute image replaces main product image on selecting attribute
Fresh install 1.5.6c
Installed AIS 1_5_10
Using 8 for Attribute style, image swapping working fine for radio button option values.
problem: 1 long vertical list of radio button option values is the result (30 values of Color Names).
Question: Would like to convert that one column to 3 or 4 columns with CSS .
Any help would be appreciated
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
mikebr
Fresh install 1.5.6c
Installed AIS 1_5_10
Using 8 for Attribute style, image swapping working fine for radio button option values.
problem: 1 long vertical list of radio button option values is the result (30 values of Color Names).
Question: Would like to convert that one column to 3 or 4 columns with CSS .
Any help would be appreciated
Doing an internet search on the concept I found in stackoverflow some references to how the number of columns can be forced with CSS and supposedly provided multiple columns (assuming all else about the page supports the additional columns).
The following was what I used to force 2 columns when looking at the Zen Cart demo data product with products_id 132 (uses check boxes instead of radios, but similar markup is expected):
Code:
.wrapperAttribsOptions {
column-count: 2;
}
where column-count was added to whatever else existed there. In my case it was found in the responsive_classic template's CSS folder for file stylesheet.css at or around line 374, though I don't claim that my css file is up-to-date as I have not ensured that it has remained up-to-date in my current testing environment.
-
1 Attachment(s)
Re: Attribute image replaces main product image on selecting attribute
thanks
worked like a charm
Attachment 18813
-
Re: Attribute image replaces main product image on selecting attribute
ZenCart 1.5.6c
PHP 7.1
AIS 1.5.10
Great module.
AIS has introduced Image Style choices 6,7, and 8 within option_manager to be entered in the Attribute Styles field.
All these choices (6,8) operate on and replace the Main Product Foreground Image.
Question:
Can additional choices such as 9,10, and 11 be developed to operate on and replace the Main Product Background Image?
thanx
mike
-
1 Attachment(s)
Re: Attribute image replaces main product image on selecting attribute
Attachment 18901
The attribute picture can replace the main picture normally, but the main picture after replacement cannot be displayed normally.
not work at Image Handler 5 (Zen Cart 1.5.5+).
Enlarged picture cannot be displayed.
Uninstall Image Handler 5 (Zen Cart 1.5.5+) and it works:(
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
ikirin
Attachment 18901
The attribute picture can replace the main picture normally, but the main picture after replacement cannot be displayed normally.
not work at Image Handler 5 (Zen Cart 1.5.5+).
Enlarged picture cannot be displayed.
Uninstall Image Handler 5 (Zen Cart 1.5.5+) and it works:(
I thought I remembered seeing an issue in the IH5 forum thread about issues with the suffix _LRG being added to filenames when that file did not exist. While this seems to occur when using this software, because it doesn't work with IH5 and does without, it would seem that there is an issue with the particular version of IH5 installed. When you go to that thread, after searching for the similar issue, if posting, please identify what specific version of IH5 is installed.
-
1 Attachment(s)
Re: Attribute image replaces main product image on selecting attribute
Thanks for the response,I am looking for help on IH5 thread,IH5(V.5.1.8) does not seem to be able to compress attribute images.
Attachment 18903
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
ikirin
Thanks for the response,I am looking for help on IH5 thread,IH5(V.5.1.8) does not seem to be able to compress attribute images.
Attachment 18903
See this IH-5 support-thread posting for the change needed to provide interoperation between IH-5 and this plugin.
-
Re: Attribute image replaces main product image on selecting attribute
Works perfectly, thank you very much for your response:cool:
-
Re: Attribute image replaces main product image on selecting attribute
Quote:
Originally Posted by
lat9
See
this IH-5 support-thread posting for the change needed to provide interoperation between IH-5 and this plugin.
Works perfectly, thank you very much for your response:cool:
-
Re: Attribute image replaces main product image on selecting attribute
ZC1.5.7
PHP7.4
AIS1.5.10
Dynamic Price Updater v3.2.1
on a testing server with many other mods..
The product page keeps refreshing with a alert popup "Status returned - parsererror" .. think it's similar to DPU before you updated it.
Some of the Console log:
Code:
Object { cache: false, type: "POST", traditional: true, dataType: "json", timeout: 30000, data: {…}, url: "ajax.php?act=attrib_prod_info&method=swap_image&products_id=73" }
onload@https://localhost/public_html/zen157/index.php?main_page=product_info&cPath=10_9&products_id=73:7:3
Object { readyState: 4, getResponseHeader: getResponseHeader(e), getAllResponseHeaders: getAllResponseHeaders(), setRequestHeader: setRequestHeader(e, t), overrideMimeType: overrideMimeType(e), statusCode: statusCode(e), abort: abort(e), state: state(), always: always(), catch: catch(e), … }
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
jQuery 5
deferred https://localhost/public_html/zen157/index.php?main_page=product_info&cPath=10_9&products_id=73:106
Deferred jQuery
ajax https://localhost/public_html/zen157/index.php?main_page=product_info&cPath=10_9&products_id=73:72
getattribimage https://localhost/public_html/zen157/index.php?main_page=product_info&cPath=10_9&products_id=73:333
onclick https://localhost/public_html/zen157/index.php?main_page=product_info&cPath=10_9&products_id=73:1
ais_init https://localhost/public_html/zen157/index.php?main_page=product_info&cPath=10_9&products_id=73:397
onload https://localhost/public_html/zen157/index.php?main_page=product_info&cPath=10_9&products_id=73:2
-
Re: Attribute image replaces main product image on select [Support Thread] ZC 2.0.1
Good morning!
I'm working locally.
I renamed the template and admin folders in 1_Main_Files and 2_ZC_Version.
I copied the contents of both folders to my ZC folder. I used ZC156 from the 2_ZC_Version folder.
When I checked Option Name Manager, there were no options (the page was blank).
I then ran the following (and it said it was successful):
Code:
SELECT @products_options_types_id := pot.products_options_types_id+1 FROM `products_options_types` pot order by pot.products_options_types_id desc limit 1;
When I ran the following, I received the message: WARNING: An Error occurred, please let us know! If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you entered valid data.
Code:
INSERT INTO `products_options_types` (products_options_types_id, products_options_types_name) VALUES (@products_options_types_id, 'Link');
INSERT INTO `configuration` (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ('Link product option type', 'PRODUCTS_OPTIONS_TYPE_LINK', @products_options_types_id, 'Numeric value of the link product option type', 6, 0, now(), NULL, NULL);
and my Option Name Manager screen was still blank.
Backup to the rescue!
Can anyone tell me where I've gone wrong?
Thanks in advance.
-
Re: Attribute image replaces main product image on select [Support Thread] ZC 2.0.1
Quote:
Originally Posted by
Cath
Good morning!
I'm working locally.
I renamed the template and admin folders in 1_Main_Files and 2_ZC_Version.
I copied the contents of both folders to my ZC folder. I used ZC156 from the 2_ZC_Version folder.
When I checked Option Name Manager, there were no options (the page was blank).
I then ran the following (and it said it was successful):
Code:
SELECT @products_options_types_id := pot.products_options_types_id+1 FROM `products_options_types` pot order by pot.products_options_types_id desc limit 1;
When I ran the following, I received the message: WARNING: An Error occurred, please let us know! If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you entered valid data.
Code:
INSERT INTO `products_options_types` (products_options_types_id, products_options_types_name) VALUES (@products_options_types_id, 'Link');
INSERT INTO `configuration` (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ('Link product option type', 'PRODUCTS_OPTIONS_TYPE_LINK', @products_options_types_id, 'Numeric value of the link product option type', 6, 0, now(), NULL, NULL);
and my Option Name Manager screen was still blank.
Backup to the rescue!
Can anyone tell me where I've gone wrong?
Thanks in advance.
Well a couple of things at least to try to help. It's hard to say what if anything was done wrong without first knowing what version of Zen cart is involved. Then there is the question of what else might have been installed as an edit or additional plugin. Lastly and perhaps most helpful if attempting to again apply the files, is to report back what information is provided in the debug logs when either experiencing a black screen, partial blank or one of those errors in the SQL statement reports.
Ultimately what is needed to be applied for this module should be commented in the file(s) that are merged with original Zen cart code.