Jump to content
kymation

[Addon] Options with Images Module for Modular Product Page (Responsive)

Recommended Posts

Thanks for your feedback @raiwa .

I agree it would be great if the image could be removed if deleted through the product_attributes page.

I'll have a closer look at it.

Regards,

Lambros

Share this post


Link to post
Share on other sites

Hello @Tsimi, @kymation,

I added check boxes to remove and/or delete option images to admin/product_attributes.php.

Changes commented:

" //add remove image function" lines 132-135

"//add delete image function" lines 136-140

"<!--- Add remove and delete image options  --->" lines: 634-639

Another issue:

There is one change which was not commented and produced me a headache and time to find the difference to merge the changes with a modified file:

        <!--- Start attibutes images  --->
        <form name="attributes" action="<?php echo tep_href_link('products_attributes.php', 'action=' . $form_action . '&' . $page_info); ?>" method="post" enctype="multipart/form-data"><table border="0" width="100%" cellspacing="0" cellpadding="2">
        <!--- End attibutes images  --->

This part is different to a unmodified core file: enctype="multipart/form-data"

I added the comment lines in the attached file.

Please use the file for your convenience to update your packages.

I'm also preparing option images support for QTPro BS. I'll upload it soon.

 

kind regards

Rainer

 

products_attributes.php

Share this post


Link to post
Share on other sites

@raiwa

You beat me to it.

Your code looks like pieces from this addon that I was looking at for reference.

http://addons.oscommerce.com/info/1639

Just tested your code changes and they work like a charm.

I'll update the addon right away.

 

Thanks as always for your great work and effort.

Kind regards,

Lambros

Share this post


Link to post
Share on other sites

Addon updated.

All credits for the new changes to @raiwa

 

@burt @Harald Ponce de Leon

Something weird is going on in the addons section. No user names are showing and I cannot add new maintainers to my addons.

Edited by Tsimi

Share this post


Link to post
Share on other sites
3 minutes ago, Tsimi said:

 

@burt @Harald Ponce de Leon

Something weird is going on in the addons section. No user names are showing and I cannot add new maintainers to my addons.

This will be fixed over the weekend. It's due to API differences the forum software update introduced with the user integration implementation used in our main websites.


:heart:, osCommerce

Share this post


Link to post
Share on other sites
1 hour ago, Tsimi said:

Your code looks like pieces from this addon that I was looking at for reference.

http://addons.oscommerce.com/info/1639

I took it from the old 2.2rc2a categories.php, that addon may be based on it too.

 

rgds

Rainer

Share this post


Link to post
Share on other sites
1 hour ago, Harald Ponce de Leon said:

This will be fixed over the weekend. It's due to API differences the forum software update introduced with the user integration implementation used in our main websites.

Thanks Harald.

Now that I have you here did you see my PM regarding addon title edit?

I was stupid enough to add a version number in the title again which should be removed.

It should only say Options Images BS without the v1.1

http://addons.oscommerce.com/info/9565

Thanks again.

 

@raiwa

Yeah it looks like it. Some old 2.2 code still does the trick as your code showed. Well done!

Share this post


Link to post
Share on other sites

Hello @Tsimi , hello @kymation,

Sorry for the slow dropping suggestions.

Working on the QTPro option image integration, I found that there is no option to avoid dropping the "option_image" and "sort_order" columns when uninstalling the product info options images content module.

I needed this option for the QTPro integration and here is the result:

Uninstall Removes Database entries
Do you want to remove the options images database column in the products_attributes table when uninstall the module? All your existing options images entries will be lost, use this option only it you are sure that you will not use options images any more.

True
False

 

    public function install() {     
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ( 'Module Version', 'MODULE_CONTENT_PRODUCT_INFO_OPTIONS_IMAGES_VERSION', '" . $this->version . "', 'The version of this module that you are running', '6', '0', 'tep_cfg_disabled(', now() ) ");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Options Images Module', 'MODULE_CONTENT_PRODUCT_INFO_OPTIONS_IMAGES_STATUS', 'True', 'Should the product options with images block be shown on the product info page?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_PRODUCT_INFO_OPTIONS_IMAGES_SORT_ORDER', '60', 'Sort order of display. Lowest is displayed first.', '6', '2', now())");
      tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Uninstall Removes Database entries', 'MODULE_CONTENT_PRODUCT_INFO_OPTIONS_IMAGES_REMOVE_DATA', 'False', 'Do you want to remove the options images database column in the products_attributes table when uninstall the module? All your existing options images entries will be lost, use this option only it you are sure that you will not use options images any more.', '6', '3', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      // ADDED FIELDS
      if (tep_db_num_rows(tep_db_query("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='". DB_DATABASE . "' AND TABLE_NAME='products_attributes' AND COLUMN_NAME LIKE 'option_image'")) != 1 ) {
        tep_db_query("AlTER TABLE products_attributes ADD option_image varchar(127) NULL default NULL");
        tep_db_query("ALTER TABLE products_attributes ADD sort_order int(11) NOT NULL default 0");
      }
    }

    public function remove() {
      tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')");
      // DELETE ADDED FIELDS
      if ( defined('MODULE_CONTENT_PRODUCT_INFO_OPTIONS_IMAGES_REMOVE_DATA') && MODULE_CONTENT_PRODUCT_INFO_OPTIONS_IMAGES_REMOVE_DATA == 'True' ) {
        tep_db_query("ALTER TABLE products_attributes DROP COLUMN option_image");
        tep_db_query("ALTER TABLE products_attributes DROP COLUMN sort_order");
      }
	  }

Please use the modified attached file for your convenience and add it to your packages if you like.

rgds

Rainer

cm_pi_options_images.php

Share this post


Link to post
Share on other sites

Hello @Tsimi , hello @kymation,

 

Another small mod: I added the code to auto create the "images/options/" directory during installation:

      // Create image directory for options images
      if(!is_dir(DIR_FS_CATALOG_IMAGES . 'options/'))mkdir(DIR_FS_CATALOG_IMAGES . 'options/', 0755);

 

cm_pi_options_images.php

Share this post


Link to post
Share on other sites

@raiwa

You sure are on a roll right now. Keep it coming, great improvements.

I'll add your code ideas to the next update, thank you.

Edited by Tsimi

Share this post


Link to post
Share on other sites

@Tsimi ,

I'm sorry, the last file I posted didn't have the tep_image mod included. :ohmy:

Here the updated file with all my mods together and I also updated the version reference to 1.4.

Please double check yourself for any case and update the package.

 

rgds

Rainer

cm_pi_options_images.php

Share this post


Link to post
Share on other sites

@Tsimi ,

 

I have another gift for you and the community.

Finishing the option image support for QTPro, I found that there may be many occasions where the same option image and option value should be used for many different products. Best example: color samples like your included sample images.

This means adding the same image to many, maybe hundreds of products via products attributes.

So I added the image sopport to Option Values. Add the color sample once to the option value, and it will show on each product where the value is used, no need to upload the image to each product.

The main changes are in admin/products_attributes. All are commented with "option values images". I also added the possibility to add an option image at the bottom of products attributes, when a attribute is assigned to a product (I believe this was missing).

There is a minor mod in the cm_pi_options_images.php template. It looks first if a option image exists in the products_attributes table, if yes, this one is used, otherwise it looks in the products_options_values table and uses that one if exists.

So a generic option value image can be overwritten by a product attribute option image for a concrete product.

I updated already the 1.5 package, all files should be ok, but please, double check before uploading.

The instructions need to be updated !!

Hope you like it.

Jim @kymation,  of course if you like, use the update also for your modular product info version.

 

rgds

Rainer

 

PS: Would be great to get the options image supported by Attribute Manager. But this is another (big) job.s

 

Options Images BS v1.5 by Tsimi.zip

Edited by raiwa

Share this post


Link to post
Share on other sites

@raiwa

That is great news. Very clever to move the whole image stuff from the products attributes section to the option values section.

I gladly have a look at your new package.

Share this post


Link to post
Share on other sites

@raiwa

Addon has been updated to v1.5, thank you.

I tested this and it really gives you the flexibility to do what ever you like with the Options Images.

That Option Values step is a very useful improvement. Again thank you.

Share this post


Link to post
Share on other sites

 

QTpro 5.4 BS  including support for Options Images 1.5 uploaded:

QTpro BS 5.4

 

Share this post


Link to post
Share on other sites

@Tsimi and other Option Images users:

Ajax Attribute Manager beta with Option Images support for testing uploaded:

https://forums.oscommerce.com/topic/195959-ajax-attribute-manager-support/?do=findComment&comment=1757783

 

Please give it a try

rgds

Rainer

Share this post


Link to post
Share on other sites

@kymation

Hi, Jim,

Thanks for your great work.

I just tried your option image module, it reported the function error.

Couldn't this module be co-existed with product options module of product page modular?

Also I tried two options, Size and Color, the values merged together and shown in the product page.

Where should I change ?

Thanks for if you have time to answer my question.

Chuntse

Share this post


Link to post
Share on other sites

Hi @chuntse

We need to see the error message to be able to help you. Please copy and paste the error message into your post.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Hi @kymation

It reported

Fatal error: Cannot redeclare cm_pi_options_draw_pull_down_menu() (previously declared in /var/www/html/includes/modules/content/product_info/cm_pi_options_images.php:160) in /var/www/html/includes/modules/content/product_info/cm_pi_options.php on line 117

 

  if( !function_exists( 'cm_pi_options_draw_pull_down_menu' ) ) {
    function cm_pi_options_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {


I changed the function name, it worked properly. Is it only the way to change the name or there is another solution can override it?

 

Please also take a look at this photo, the test is not belonged to the color option, but it also be showned under this group.

20180705091529.png.6e89d4deb670bd89e8bb8f6d9c516ac9.png

 

Thank you.

chuntse

Share this post


Link to post
Share on other sites

The line before the function declaration is a test to see if the function has already been declared, so this error should never happen. Are you running some old version of PHP?

The text "test" is probably in one of your files. Search through your files for that text and delete it.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

@kymation

Hi,

My VPS is running PHP Version 5.4.16。The Centos is now only supported this version, I think it is hard to change it.

About the test, I forgot to chage the option name when linking to the product. it is resolved.

Does it influence the module if I changed the name of this function?(I did changed it and it work properly, but I don't know if it has other improper influence).

I also added another function and control value to make the image with radio option to display in grid.

The function is

 function cm_pi_options_images_draw_radio_menu($name, $values, $default = '', $parameters = '', $required = false) {
      global $_GET, $_POST;
         $field = '';

     if ( tep_not_null( $parameters ) ) {
        $field .= ' ' . $parameters;
      }

         $field .= '<div class="row">';

      if (empty($default) && ( (isset($_GET[$name]) && is_string($_GET[$name])) || (isset($_POST[$name]) && is_string($_POST[$name])) ) ) {
        if (isset($_GET[$name]) && is_string($_GET[$name])) {
          $default = stripslashes($_GET[$name]);
        } elseif (isset($_POST[$name]) && is_string($_POST[$name])) {
          $default = stripslashes($_POST[$name]);
        }
      }

      for ($i=0, $n=sizeof($values); $i<$n; $i++) {
    
    $option_name = tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;'));

        if( tep_not_null( $values[$i]['image'] ) ) {
          $field .= '<div class="col-xs-6 col-md-3 col-lg-2"><p class="text-center">'  . '<img alt=\'' . $option_name . '\' src=\'' . DIR_WS_IMAGES . $values[$i]['image'] . '\'' . ' height="' . MODULE_CONTENT_PRODUCT_INFO_OPTIONS_IMAGES_SET_IMAGES_HEIGHT . '"' .  ' width="' . MODULE_CONTENT_PRODUCT_INFO_OPTIONS_IMAGES_SET_IMAGES_WIDTH . '"' . ' /></p><p class="text-center"> ' . $option_name . '</p>';
        }
        $field .= '<p class="text-center"><input type="radio" name="' . tep_output_string($name) . '" value="' . tep_output_string($values[$i]['id']) . '"';
        if ($default == $values[$i]['id']) {
          $field .= ' checked';
        }
            $field .= '>' . '</p></div>';

      }

       $field .= '</div>';

      if ($required == true) {
        $field .= TEXT_FIELD_REQUIRED;
      }

      return $field;
    }

it worked, but the display is not perfect in product page as yours. Do you have ideas?

I also amended the products_attributes.php with Option Type v2 BS, Do you think I can add some codes with if() or switch() that I can make the option display properly in the product info page?

Thanks for your advices in advanced.

Best regards

chuntse

Share this post


Link to post
Share on other sites

PHP 5.4 is obsolete and no longer supported. You should not be using anything older than 5.6, and support for that is ending in about six months. It's time to plan your upgrade to PHP 7.x.

The function exists in this module and in the stock Products Options module, which is why the conflict. You should only be using one of those. If you really need both, you can delete the function from this one.

I don't know how to make Option Types work with this Addon as this one requires a pulldown menu. It should be possible, but those code modifications are way beyond what can be done in this support topic.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

@kymation

Thanks a lot for your kind support and advice.

Maybe you can keep this codes in mind and make it perfect for publishing option image module for next new version.:smile:

I will continue to study and work on it.

Thank you again.

Best regards

chuntse

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×