Jump to content

[SOLVED] Show colour picker, but only for reference?


Recommended Posts

Hi,

I am creating a pack of 12 coloured paints. I would like the shopper to see all the available 100 colours in an attribute group using the colour picker, but ONLY for reference – enabling them to decide which 12 paints they'd like to add. The user will see the colour code via the 'title' tag when they hover over the colour square. The user will then type these colour codes they want into the 12 required custom text fields I've added.

At the moment, I can't get the colour picker to display all 100 colours without also making 100 separate colours available for purchase. This is obviously not what I want.

Is there anyway to display the full colour picker with all 100 colours, but only allow for one type of product to be purchased?

Any ideas how I could solve this? Thank for your help.

Link to comment
Share on other sites

Why don't you just create a single image with all the colours and names? That way, you don't need to add any attributes to the product, just the customisation. The only problem is what to do when the customer types in something that isn't one of the colours.

Link to comment
Share on other sites

Having said that, instead of including RAW HTML, how could I simply display all the colours in an attribute group as a colour picker? Surely that should be fairly simple? Something to change in the second line here (from product.tpl):

></pre>
<ul>
           {foreach from=$colors key='id_attribute' item='color'}
{if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}{/if}
           {/foreach}



Hope you can help :-)

Link to comment
Share on other sites

You need to create one product that does have all 100 colours as attributes, but disable that product so it can't be purchased. Then you need to change product.php so that it gets the attributes from that product instead of the current product. For example, change line 236 of product.php (in Prestashop v1.2.5) from:

$attributesGroups = $product->getAttributesGroups(intval($cookie->id_lang));



to:

$attributeProduct = new Product(1, true, intval($cookie->id_lang));
$attributeGroups = $attributeProduct->getAttributeGroups(intval($cookie->id_lang));



Change 1 to the id of the product with all the colour attributes.

Do any of your products have combinations? If not, try commenting out the following lines 284-285 of product.php:

'combinaisons' => $combinations, /* Kept for compatibility purpose only */
'combinations' => $combinations,



Hopefully, by passing in the colours, but not the combinations, you can access the colours without creating combinations on the product.

The next thing you need to do is remove the links on the colours by changing line 167 in product.tpl in your theme's directory (in Prestashop v1.2.5) from:

{if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}{/if}



to:

{**}{if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}{/if}{**}

Link to comment
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
×
×
  • Create New...