Color Swatches on product options

ThemeBurn SupportForumsOpenCart ThemesShoppica OpenCart ThemeColor Swatches on product options

This topic has been marked as not a support question.

Opencart has the limitation of not allowing to control stocks in a hierarchical options mode that would permit to know the stock for each product by color and size. That’s why I’ve decided to create every product color as a new product and have options for sizes.

But now I need to have a connection between the different colors of a given product. I was thinking in having little squares filled with the different colors available for a given product. Each of this squares would have a link to the product of that specific color.

Any advice on how to acomplish this?
Thanks

February 1, 2012 at 5:26 pm #5799

Just a note of my progress…

When creating product options, there is the possibility to create with the type “image”. I’ve added an option named COLOR and created the option values red, black, green, etc. For each of this options value I’ve added a square image of the corresponding color. I’ve decided to modify the product_options_tpl to have something simulating color swatches like this when the type of option is an image:


    <?php if ($option['type'] == 'image'): ?>
   <?php echo $option['name']; ?><br />
   <?php echo $product_info['product_id']; ?><br />
   
    <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
      <?php foreach ($option['option_value'] as $option_value): ?>
      <div style="float:left; margin: 3px;">
         <a href="index.php?route=product/product&product_id=<?php echo $option_value['points']; ?>">
         <img height="20" width="20" src="<?php echo $option_value['image']; ?>" title="<?php echo $option_value['name'] . ($option_value['price'] ? ' ' . $option_value['points'] . $option_value['product_option_id'] : ''); ?>" />
         </a>
      </div>
      <?php endforeach; ?>
   </div>
    <br />
    <?php endif; ?>

Since I don’t plan to use the award points functionally I was trying to use this field to put the destination product number. However I’m unable to get the rigth value when calling $option_value['points'].

I’m uploading a screenshot, so you can better understand what I need.
Hope you can help.
Thanks

February 1, 2012 at 5:37 pm #5800

Hi,

Unfortunately, you can’t use the $option_value['points'] variable as it is not defined in the controllers and taken from the database.

You will have to mod:

catalog/model/catalog/product.php
catalog/controller/product/product.php

in order to initialize it.

Best regards,
ThemeBurn team

February 7, 2012 at 10:25 am #5946
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.