Page 14 of 16 FirstFirst ... 41213141516 LastLast
Results 131 to 140 of 159
  1. #131
    Join Date
    Mar 2018
    Location
    USA
    Posts
    30
    Plugin Contributions
    0

    Default 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.

  2. #132
    Join Date
    Mar 2018
    Location
    USA
    Posts
    30
    Plugin Contributions
    0

    Default Re: Attribute image replaces main product image on select [Support Thread]

    Quote Originally Posted by dvtalk View Post
    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. :)

  3. #133
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Attribute image replaces main product image on select [Support Thread]

    Quote Originally Posted by dvtalk View Post
    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 View Post
    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)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #134
    Join Date
    Mar 2018
    Location
    USA
    Posts
    30
    Plugin Contributions
    0

    Default 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!

  5. #135
    Join Date
    Mar 2018
    Location
    USA
    Posts
    30
    Plugin Contributions
    0

    Default 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;
    }
    Last edited by dvtalk; 7 Apr 2018 at 07:25 AM.

  6. #136
    Join Date
    Mar 2018
    Location
    USA
    Posts
    30
    Plugin Contributions
    0

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

  7. #137
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default 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
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #138
    Join Date
    Mar 2018
    Location
    USA
    Posts
    30
    Plugin Contributions
    0

    Default Re: Attribute image replaces main product image on select [Support Thread]

    Quote Originally Posted by mc12345678 View Post
    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.

  9. #139
    Join Date
    Mar 2018
    Location
    USA
    Posts
    30
    Plugin Contributions
    0

    Default Re: Attribute image replaces main product image on select [Support Thread]

    Quote Originally Posted by mc12345678 View Post
    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

  10. #140
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Attribute image replaces main product image on select [Support Thread]

    Quote Originally Posted by dvtalk View Post
    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.)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 14 of 16 FirstFirst ... 41213141516 LastLast

Similar Threads

  1. Attribute image replaces main image but only pop up larger image
    By welchyboy in forum Setting Up Categories, Products, Attributes
    Replies: 15
    Last Post: 26 Nov 2010, 11:56 PM
  2. Replies: 0
    Last Post: 7 Oct 2009, 07:11 PM
  3. Replies: 0
    Last Post: 16 Jul 2009, 06:07 AM
  4. Replies: 1
    Last Post: 5 Oct 2008, 11:45 PM
  5. Attribute image replaces main product image on selecting attribute
    By pegog in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 19 Jun 2008, 07:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR