PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

[MODULE] Product attributes as radio buttons and checkboxes

217 replies to this topic
#1
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
This module changes the way attributes are displayed. Instead of displaying them as dropdowns, it displays the attributes in a table along with the price differences including tax. The module can be configured to also display the price differences excluding tax. Attribute groups that have attributes named "Yes" and "No" will be displayed as a checkbox with the group name as the label. All other attribute groups will be displayed as radio buttons.

By default, this module installs itself above the more information section, but it can also be displayed as a tab in the more information section by going to Modules > Positions and transplanting the module into the "Tabs on the product page" and "Content of tabs on product page" hooks, then deleting the module from the "Product footer" hook. Note that if you want to remove the module from this position, you will have to tick "Display non-positionnable hook" before you can remove it from those hooks.

You can find further instructions and see a demo of the module here.

UPDATE: v1.1

- Added option to display no prices, tax included, tax excluded or both

- Added option to hide price differences when they are zero

UPDATE: v1.2

- Fixed a few bugs

- Added option to display full price instead of just the price differences

- Added option to display label above checkboxes: enter the label at the start of the attribute group name followed by the | character

UPDATE: v1.2.1

- Fixed so that product discounts and customer discounts are now displayed in the attribute prices

UPDATE: v1.3

- Added option to display attribute images and weight

- Made description optional

- Changed so that attributes are sorted alphabetically

UPDATE: v1.3.1

- Fixed bug in calculation of price excluding tax

Download this module from my website here.

Attached Files

  • Attached File  front.png   64bytes   17134 downloads
  • Attached File  back.png   23bytes   13858 downloads

Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#2
kennyh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 171 posts
Rocky ...you are a champ.

thanks.
Ken

#3
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
Updated with more tax options and the option to hide price differences of zero.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#4
kennyh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 171 posts
Rocky

As a special request .Is it possible to get a display of total price as a option (price +attribute +tax ).

Ken.

#5
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
Good idea. I'll add that as an option when I get time. In the mean time, you can do this by giving the product a price of zero and then adding all the prices as the price differences.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#6
kennyh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 171 posts
Thanks again Rocky.

Ken

#7
yungan

    PrestaShop Newbie

  • Members
  • Pip
  • 8 posts
Hi..
Is it possible this module multiple choice.
My attributes:

Extra option 1:
cheese
tomatoes
Cheddar
Onion
Jambon
Egg

Extra option 2:
cheese
tomatoes
Cheddar
Onion
Jambon
Egg

Extra option 2:
cheese
tomatoes
Cheddar
Onion
Jambon
Egg

Extra option 3:
cheese
tomatoes
Cheddar
Onion
Jambon
Egg

Extra option 4:
cheese
tomatoes
Cheddar
Onion
Jambon
Egg


There are a lot of combinations. Only one attributes group comes out throught multi select checkbox
Sorry. I speak english but very bad ... :D

#8
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
Updated module to fix bugs, add full price option and label above checkbox option.

@yungan

Here are the two ways you could use my module:

1. You could add cheese, tomatoes, cheddar, onion, jambon and egg checkboxes and the customer can choose as many or as few as they want. Unfortunately, it does not allow you to limit them to selecting four checkboxes or to force them to choose at least one.

2. As you have written above, you could have four sets of radio buttons with all the possible options. This allows you to force the customer to select exactly four options, but the customer could select the same item more than once.

If you are happy with either of these two options, then my module can do what you want.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#9
wallacept

    PrestaShop Apprentice

  • Members
  • PipPip
  • 170 posts
not working in presta 1.1
CCampea Store- http://www.ccampea.com/lojacc - Store online motos, bikes, helmets

CCampea Twitter- http://twitter.com/ccampealoja

CCampea Facebook - CCampea Facebook - Store Online Motos, Bikes and Accessories

CCampea ThisNext - CCampea This

#10
kennyh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 171 posts
Rocky

I set up 3 checkboxes , the Attribute group name as the label is ok but when added to cart the attribute's (yes and no) is displayed. I would like the Attribute group name to display instead of the attributes .Did I go about it wrong ?

Attached Files



#11
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
@wallacept

This module is designed for Prestashop v1.2.4. What's going wrong in Prestashop v1.1?

@kennyh

Thanks for bringing that bug to my attention. Unfortunately, I don't think modules have control over that code. You would have to change the code manually.

In classes/Cart.php, change line 270-271 from:


$attributesList .= $row2['public_group_name'].' : '.$row2['attribute_name'].', ';
$attributesListSmall .= $row2['attribute_name'].', ';


to:


if (strpos($row2['public_group_name'], '|') !== FALSE)
$row2['public_group_name'] = substr($row2['public_group_name'], strpos($row2['public_group_name'], '|') + 1);
$attributesList .= $row2['public_group_name'].': '.$row2['attribute_name'].', ';
if ($row2['attribute_name'] != 'No')
$attributesListSmall .= ($row2['attribute_name'] == 'Yes' ? $row2['public_group_name'] : $row2['attribute_name']) .', ';


I'm not sure whether you made the right choice to use checkboxes. Did you intend to give your customers the option to choose multiple sizes? If you are selling t-shirts, for example, you shouldn't be able to buy a t-shirt that is both small and medium size. Unless it is your intention to choose multiple sizes, I think you should use radio buttons instead, so the customer can only choose one size.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#12
kennyh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 171 posts
Rocky

Thank you.. problem is solved with your Cart mod. I have tried the radio buttons and they are great too.The product intended for this checkbox arrangement will be sold in a weight of grams.Its not my idea, but it is a requirement for the user to be able to select one or all attributes.Yes you can force one choice by making one a default attribute.One of beauties of this module I found is the ability for the user to add to the cart quickly many variations of the same product.There isn't anything or any attempt like this module for PS .Its really helpful.
Ken

Attached Files



#13
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
You're welcome. I'm happy you've found my module useful and are using it in ways I never imagined.

Can you give me a link to your site so I can see how you are using my module?
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#14
kennyh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 171 posts
Rocky

just PM you.

#15
jhnstcks

    PrestaShop Fanatic

  • Moderators
  • 1913 posts
Hi Rocky love this module....is there a way for the module to display whether an attribute changes the price of the product. For example a t-shirt size small adds £1 but large adds £2.

Also is it possible to wrap a long column of attributes into 2 columns? I have a feeling it might not be because of the table.
Helpful hints and tips to Empower your Prestashop site - Join us on Facebook and get involved, tell us the things that help you.
If you think someone's answer helped, please give him/her a Positive Reputation vote by liking their post.
E-commerce hosting from Scotserve, fast, reliable and affordable.

#16
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
Hi jhnstcks,

Sorry, but I'm not sure that I understand what you mean. There is already an option to display price differences. Do you mean that you want to display both the full price and price difference at the same time? I'm not sure what you mean by wrapping a long column into two columns. Do you mean wrapping into 2 rows?
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#17
jhnstcks

    PrestaShop Fanatic

  • Moderators
  • 1913 posts
Hi Rocky

I sorted the price thing, i thought that option was for displaying taxes.

As for the columns i want it to look something like the image below.

If it is some css styling I cant work it out, been trying for ages.

I have a feeling it isnt possible because of the way the attributes are called using the foreach command and it will insert them all into one column.

This wont affect me but, i think it would look great if different attribute groups could be put into different columns.

Attached Files


Helpful hints and tips to Empower your Prestashop site - Join us on Facebook and get involved, tell us the things that help you.
If you think someone's answer helped, please give him/her a Positive Reputation vote by liking their post.
E-commerce hosting from Scotserve, fast, reliable and affordable.

#18
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
I'll try to add the option when I have time. Do you want the option to display each attribute group in two columns or all attributes in two columns or both?
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#19
kennyh

    PrestaShop Apprentice

  • Members
  • PipPip
  • 171 posts
Hey Jhnstks

answer the man...

Rocky strickly 2 columns would be great (I just donated you a case of beer)

Thanks again
Ken

#20
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
Hi kennyh,

Thanks for the donation. I'll work on this once I've finished the website I'm currently working on. I noticed in another thread you wanted an option to add a quantity field next to each attribute to add multiple attributes to the cart in one click. I'll see whether I can do that too.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.