CVS edit link for Alex Lawrence

My company is currently working on a webshop with Ubercart 2. During the development I wrote 2 modules.

uc_preferred_payment:

Introduces a new payment method where a profile field (profile.module) can be specified of which users can choose their preferred payment method which will be used as default for every order. Additionally extra profile data can be send together with the preferred payment method. The payment option will be displayed on the order, the checkout and the invoice. The module provides a token (e.g. for invoice e-mails)
We are building a webshop for a german b2b (business to business, instead of business to customer) webshop and our customer does not want to provide real gateways and payments but instead only wants to recevie an e-mail with the preferred payment as message. I think this could be useful for some others.

uc_customer_discount:

Another important thing of the webshop is that each customer has an individual discount and all prices should be discounted already when customers are browsing through the webshop. Similar to the preferred payment you can choose a profile field for the customer discount (in our case this field is not available to customers and can only be changed through the admins). Prices are then displayed discounted everywhere in the shop. Additionally this discount will also be displayed on the order, checkout and invoice and the module provides a token.

Both modules have settings, are documented and conform to the coding standards.

Our company (artecho, www.artecho.de) is realising a lot of projects with Drupal and we like it very much. We are also trying to help by creating issues and providing suggestions for patches. I developed myself small scaled cms solutions but since I looked deeper into Drupal I´d like to become a module developer.

Best

P.S.: Forgive me if I english is not too good, I am not a native speaker.

Comments

Alex Lawrence’s picture

StatusFileSize
new2.66 KB

uc_customer_discount

Alex Lawrence’s picture

StatusFileSize
new3.02 KB

uc_preferred_payment

NOTE: The settings dialog needs some ajax to be better in usability. Currently working on it.

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Needs review
Alex Lawrence’s picture

Forgive me but I don´t quite understand. What would you like to know?

Alex Lawrence’s picture

If you want to know more about my person you might want to take look at this page http://alex-lawrence.com/about

avpaderno’s picture

@Alex Lawrence: The status is changed to "needs review" when there is new code to be reviewed, and it is changed to "needs work" when you need to change the code as it is. After you change the code, you change the status to "needs review".

avpaderno’s picture

Status: Needs review » Needs work
  1.   $options = explode( "\n", $field->options );
      // Trim then in order to compare
      foreach ( $options as &$option ) {
        $option = trim( $option );
      }
    

    See the Drupal coding standards to understand how a module code should be written.

  2. /**
     * Implementation of hook_token_values().
     */
    function uc_preferred_payment_token_values($type, $object = NULL) {
      $values = array();
      switch ($type) {
        case 'order':
          $order = $object;
    
          $values['order-preferred-payment'] = $order->preferred_payment;
          $values['order-preferred-payment-additional-data'] = str_replace( "\n", "<br />", $order->preferred_payment_additional_data );
      }
      return $values;
    }
    

    The code misses another hook implementation; without it, this hook is useless.

  3. 	'primary key' => array('order_id'),
        'indexes' => array(
          'order_id' => array('order_id'),
        ),
    

    The index defined is already the primary key.

  4. function uc_preferred_payment_enable() {
      if (!db_table_exists("uc_preferred_payment")){
        drupal_install_schema('uc_preferred_payment');
      }
    }
    

    Module tables are created only in hook_install().

  5. function uc_preferred_payment_install() {
      if (!db_table_exists("uc_preferred_payment")){
        drupal_install_schema('uc_preferred_payment');
      }
    }
    
    function uc_preferred_payment_uninstall() {
      if (db_table_exists("uc_preferred_payment")){
        drupal_uninstall_schema('uc_preferred_payment');
      }
    }
    

    The code should be simpler.

Alex Lawrence’s picture

StatusFileSize
new2.67 KB

Oh okay, Sorry. Thanks for the explanation.
I corrected everything you mentioned. But I am not sure about the first issue. Is this only a matter of style or am I doing something which I shouldn´t be doing (like trim(), altough I did not find anything about it on drupal.org)? If it is about the style I now have it the right way I think.

Alex Lawrence’s picture

Status: Needs work » Needs review
StatusFileSize
new3.06 KB
Alex Lawrence’s picture

Status: Needs review » Needs work

Damn it, forgot point 3.

Alex Lawrence’s picture

Status: Needs work » Patch (to be ported)
StatusFileSize
new2.66 KB
new3.05 KB

Okay, now I´m good. Sorry for the mass of posts.

avpaderno’s picture

Status: Patch (to be ported) » Needs review

Functions should be called with no spaces between the function name, the opening parenthesis, and the first parameter; spaces between commas and each parameter, and no space between the last parameter, the closing parenthesis, and the semicolon.

That means you don't make a call like trim( $string ).

avpaderno’s picture

Status: Needs review » Needs work

The code must be changed to follow the Drupal coding standards.

There are few points that we insist on, when reviewing the code:

  1. The code must be secure.
  2. The code must follow the Drupal coding standards.
  3. The code must follow the Drupal way to do a task.

Read well the coding standards, and correct the code where it doesn't follow the indications given there.

For the second module (uc_customer_discount.module), I notice there are already 3 modules for Ubercart that do the same task. I am not sure if another one is really needed.

Alex Lawrence’s picture

Alright, Thanks. I will read them carefully and make the changes.
Concerning the uc_customer_discount I found no module which was suitable for our customer needs. If there are however similar modules in general it won´t make sense to upload the customer discount module, you are right.

avpaderno’s picture

Drupal philosophy is "join forces"; when a module doesn't do what you expect it to do, you can propose patches, or ask to become co-maintainer.

Alex Lawrence’s picture

Yes that´s one reason why I use Drupal. But to be honest I found no module which I thought would be the right one for the functional requirements. However if you have some modules in mind I would be glad if you gave me the links.

Thank you

avpaderno’s picture

The one that caught my attention is UC Discount Framework; you can find some more modules by searching for uc discount.

Alex Lawrence’s picture

Status: Needs work » Postponed

Hi,

Sorry that I didn´t give you an update on the module development. Right now I am very busy and I don´t know when I will have the time to work on the modules. Hope you understand.

Cheers

avpaderno’s picture

That fine, Alex. Take in mind that we don't normally take open an application for more than 2 weeks, when we don't get back any feedback; in such cases, we decline the CVS account, but you can always apply again.

avpaderno’s picture

Issue tags: +Module review
avpaderno’s picture

Status: Postponed » Closed (won't fix)

There have not been replies from the OP in the past 7 days. I am marking this report as won't fix.