CVS edit link for Fanyalla

Hello,

I am a young Drupal developper and discovered it one year ago.

As I have seen on many forums, users of the Ubercart module have asked for the possibility to change Ubercart Products Attributes directly in the cart.

For that reason, I have developped a module named "Ubercart Attributes In Cart" that allows users to have attributes displayed in their cart. They can also change these attributes in their cart.

For the moment the module only has a small administrative page where users can decide if they want to display attributes titles in their cart.

I am planning on allowing users to choose which attributes to display in cart and to set per attribute title display.

You can download the module at http://www.ece.fr/~urbanek/uc_attributes_in_cart.tar.gz

I hope you will allow me to become a Drupal developper.

Best regards,

Fanyalla.

Comments

6lv1’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.02 KB
avpaderno’s picture

Status: Needs review » Needs work
Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

As per http://drupal.org/cvs-application/requirements, the motivation message should be expanded to contain more details about the features of the proposed module, and it should include also a comparison with the existing solutions.

6lv1’s picture

As far as I know, there is no such module available.

So basically, with this module enabled, when users have Ubercart Products in their cart, they can modify these Products' attributes (if there is any) in their cart page.

If the attribute selection method is a select box, the user selects his option, then clicks on "Update cart", the page gets reloaded and then the attribute is updated.
It also works with other selection methods (radio buttons, checkboxes, ...).

The price is also updated when an attribute is changed.

For the moment, all of the attributes of a product are displayed in the cart page.

If attributes are required when adding a product to the cart, they are still required when displayed in the cart page.

Here is a link to a screenshot of a cart with this module enabled

You can also find a demo video at http://www.ece.fr/~urbanek/test.avi

Finally, administrators with the right permission can decide to show titles of attributes in the cart or not.

avpaderno’s picture

Status: Needs work » Needs review
6lv1’s picture

StatusFileSize
new2.03 KB

Forgot to add hook_perm().

Attached is the latest version of the module.

6lv1’s picture

StatusFileSize
new3.21 KB

Hello all,

Attached is a new version of the module.

Users have now the ability to choose which attributes to display in cart. They can also decide whether or not to display these attributes' title.

This module works out-of-the-box (by default, all attributes are shown in the cart page), but you can change the settings at: admin/store/settings/attributes/in-cart

Hope you enjoy.

6lv1’s picture

StatusFileSize
new3.54 KB

Enhanced version of the settings page.
Added dependencies in the .info file.
Added confirmation messages after installation/uninstallation of the module.

patchak’s picture

Sounds like a pretty cool module and something i need as well? So you have a project page for your module?

6lv1’s picture

Hi,

thanks for your support.

At the moment I don't have any project page for this module, as it needs first to be reviewed by the community before having a project page.

It works with Drupal 6, so you can test it :)

Edit : be sure to test the latest version of the module (see comment #7) .

schmook’s picture

Category: task » bug
StatusFileSize
new22.5 KB

Hello,

I am interested in this module, and this will be my 1st attempt at posting an issue!

I am getting an error on the cart page:

warning: Invalid argument supplied for foreach() in /httpdocs/includes/form.inc on line 1207.

Currently, I am running Drupal 6.16 (Apache/2.2.3, PHP 5.2.13, & MySQL 5.0.90), Ubercart 6.x-2.2, with your module from comment #7.

My attributes are set as checkboxes. The cart will show attributes and update, however any selected attributes are unchecked when you visit the cart; see the attached image. Also the error is duplicated if multiple items are in the cart.

Thank you for working on this module. I can use this module and will be willing to test and provide whatever help I can.

Thanks,
e.

6lv1’s picture

Hi,

Thanks for your report.

I will try to fix the bug as soon as possible. I'm currently working on it :)

6lv1’s picture

Ok, I think I have identified the problem.

The error comes from line #25 of the .module file.

I don't have all my tools for debugging, so maybe I'll come with a fix later this day.

6lv1’s picture

StatusFileSize
new3.58 KB

Hi,

I finally got it working (I also added a dependency to the uc_attribute module, sounds obvious :)).

Hope you enjoy :)

6lv1’s picture

StatusFileSize
new3.58 KB

Woops, sorry, there is a security issue in the last attachment.

Attached is the safe version.

avpaderno’s picture

Category: bug » task
schmook’s picture

StatusFileSize
new52.86 KB
new40.8 KB

Hello,

Thank you very much for your time and effort!!

The latest version of the module (#14) seems to work. I will test more and report back any issues.

One thing I would need to implement is some sort of collapsible attribute list in the cart. The site I need it for is gong to sell pizzas and they have many topping choices. I will attach a couple of screen shots. One will be the cart (with only a few attributes), and one the product listing page (attributes will be collapsible).

Thank you,
e.

6lv1’s picture

Hello,

I'm glad you find this module useful.

If I understand well, you want the attribute list in the cart to be collapsible and not on the product page? This is fairly easy to implement and I can do this.

But remember that this thread is just an application for a CVS account so I can create a project page for this module that you are reviewing, so one day or another, someone (maybe you :)), will have to change the status of this issue to reviewed & tested by the community.

Let me know if I understood well your demand :)

patchak’s picture

Status: Needs review » Reviewed & tested by the community

I tested this code and it seems to be working pretty well! Of course it would need to be looked at by a couple of other people maybe? Have you tried to post this as a patch to the current uc_attributes module?

6lv1’s picture

Hi,

thank you for your review.

I have seen an issue on the Ubercart issues page where someone asked for what this module does. I have asked whether it is best to have this as a module or a patch. We will see the answers :)

By the way, here is the link to the issue in Ubercart : #750540: Change attribute in cart.

avpaderno’s picture

Status: Reviewed & tested by the community » Needs review

I tested this code and it seems to be working pretty well!

That is not the only criteria used in reviewing the proposed modules. The module needs an appropriate review.

wadmiraal’s picture

For all us newbies: what is an "appropriate review" ?

That way we can be more helpfull, because this issue queue is quite long :-)

blg@bgreenaway.com’s picture

Subscribing - Have been working on a cart theme since Drupalcon SF following Johnathon Rowney's presentation. Came across the attributes issue (amongst others) and am working a solution here within our needs.

blg@bgreenaway.com’s picture

Does seem to need more work :)

After installation of module in #14, onto a working UC installation with 12 products and 5 defined Attributes with 2 or 3 options each and each Product carrying one or two attributes errors/warnings returned from the db layer as I attempted to turn of a few Attributes :-(

I saw roughly 30 messages, all SQL errors, and the new settings did not take :-(

I wish I had the time to debug the issue, but I must move on for now...

6lv1’s picture

Hi tzoben and thanks for your review.

Could you give me more details about the errors your are facing?

On which page(s) did the errors come up?
What action(s) were you doing?
What are these errors (you can upload an image)?

6lv1’s picture

StatusFileSize
new3.22 KB

Hello everyone,

I'm attaching a simplified version of the module (instead of rewriting the submit function of the "update" and "checkout" buttons, the module now adds its own).

avpaderno’s picture

  1.     $schema['uc_attributes_in_cart'] = array(
                'description' => t('Determine which attributes to display in cart.'),
                'fields' => array(
                        'aid' => array(
                                'description' => t('Primary identifier for attributes.'),
                                'type' => 'int',
                                'size' => 'tiny',
                                'unsigned' => TRUE,
                                'not null' => TRUE,
                        ),
    

    Database schema descriptions should not be passed to t(); see what done from Drupal core modules.
    Check also the indentation character used in the installation file because it's not the two spaces reported in the coding standards.

  2. function uc_attributes_in_cart_install() {
        drupal_install_schema('uc_attributes_in_cart');
    
        drupal_set_message(st("The <em>Attributes In Cart</em> module has been installed. You can change the settings of this module under !link.", array('!link' => l(st('Administer > Store administration > Configuration > Attribute settings > Attributes in Cart Settings'), 'admin/store/settings/attributes/in-cart'))));
    }
    

    The function t() is available to hook_install(), and hook_uninstall().

  3.             $form['items'][$i]['attributes_in_cart'] = _uc_attribute_alter_form(node_load($form['items'][$i]['nid']['#value']));
    

    The function is loading a node without to check if the currently logged in user has the permission of seeing any data from that node, depending on the case, that can be a security issue.

  4. 
                    // Do not show the attribute form.
                    else $form['items'][$i]['attributes_in_cart'][$option['aid']]['#access'] = FALSE;
                }
    

    See http://drupal.org/coding-standards to understand how a module should be written. In particular, see how the code must be formatted.

  5.     $items['admin/store/settings/attributes/in-cart'] = array(
                'title' => 'Attributes in Cart Settings',
                'description' => 'Administer the settings of attributes in cart.',
                'page callback' => 'drupal_get_form',
                'page arguments' => array('uc_attributes_in_cart_settings'),
                'access arguments' => array('administer attributes in cart settings')
        );
    

    Strings used in the user interface should be in sentence case.

  6.     for ($i = 0; $i < count($items); $i++) {
            // We set the value of the attributes for each item, based on the value of the selected option.
            foreach ($items[$i]->data['attributes'] as $aid => $option) {
                $items[$i]->data['attributes'][$aid] = $form_state['values']['items'][$i]['attributes_in_cart'][$aid];
    
                // We must add useless data to the data array of the cart item, because if we have multiple products that have the same nid and attributes, the module uc_products treats these items as on item if you try to change the quantity of one of the items.
                $items[$i]->data['uc_attributes_in_cart'] = $i;
            }
    

    When possible, the code lines should not be longer than 80 characters. That limit should be always respected for the comments.

avpaderno’s picture

Status: Needs review » Needs work

I forgot to change the status.

6lv1’s picture

Status: Needs work » Needs review
StatusFileSize
new3.06 KB

Hi kiamlaluno and thanks for your review,

I've made the changes you asked for. I hope it is better now.

I'm attaching the new version of the module and changing the status of the issue to needs review.

6lv1’s picture

StatusFileSize
new3.06 KB

Sorry, I forgot to correct some indentation.

avpaderno’s picture

Status: Needs review » Fixed

The indentation needs to be reduced in some cases, but the code is better now.

Thank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

6lv1’s picture

Ok, thank you very much kiamlaluno :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nerdacus’s picture

Title: Fanyalla [Fanyalla] » Small SQL error...

I just tested this out for a client of mine needing this functionality. It's a pretty good module. There is just a small syntax error on line 196 of the module file; the table field is in quotes (either show_form or show_title) and errors when I attempt to change the settings in admin/store/settings/attributes/in-cart. I removed the quotes and it worked as expect. Thanks for module!

-Marcus

avpaderno’s picture

Title: Small SQL error... » Fanyalla [Fanyalla]
avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
avpaderno’s picture

Status: Closed (fixed) » Fixed

I am giving credits to the users who participated in this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.