The Store - Ubercart

Complete

The e-commerce part of the site is implemented using the Ubercart module. The subsections discuss various aspects of the system.

Other modules

Complete

The standard functionality of Ubercart is extended using the following modules: 

Module Function
role_delegation to enable the store manager role to explicitly set/unset the Subscriber and FiftyPercenter roles for any user
uc_abn to support the use of ABNs
uc_bank_transfer to support payment by bank transfer
uc_discounts_alt to support discounts - specifically the 50% discount given to those with the role FiftyPercenter. Note that the sub-modules Codeless Discount Field and Product Price Alterer Field do not need to be enabled.
uc_donations to support donations
uc_extra_fields_pane to support the use of a Subscription date
uc_who_bought_what to enable the reporting of who bought what
uc_free_order to support the $0 cost Subscription Key product used to generate and email a subscription key
   

 

Roles

Complete

The 'roles' facility is important to the complete Drupal system in that it is used to control who does what.

As far as the Ubercart module is concerned, three things are important:

  1. For a person to control the Store module, they need to be given the role 'shop manager'
  2. We use Ubercart's ability to assign a role to the user who purchases a product to assist in the administration of OpenVPMS Subscriptions
  3. We use the Ubercart Alt Discount module's ability to set a discount if the user has a specific role

Thus, we have created the role 'Subscriber' (via http://www.openvpms.org/admin/user/roles ) which is assigned to the user when they purchase their subscription, is set to expire in 1 year, and has an 'expiry warning' time of 1 month (set via http://www.openvpms.org/admin/store/settings/products/edit/features ).

We have also created the role 'Subscribed'. This is also assigned to subscription purchasers, but never expires. Hence we can find users whose subscriptions have lapsed by looking for users with the role Subscribed but not Subscriber. [This is done using the View and Update Users screen - http://www.openvpms.org/admin/userlist ]

There is also the role Subscriber-Ex. This is used to flag ex-subscribers. No user should have the roles Subscribed and Subscriber-Ex at the same time. There is no programmed block against this, it is just illogical to do so.  Any user who used to be a subscriber, but no longer is (either because they are no longer an OpenVPMS user, if their practice's subscription is held under another name) should have their role Subscribed removed and Subscriber-Ex added. This is done manually by editing the user.

We have also created the following roles:

'FiftyPercenter':  This is manually assigned by the shop manager to any users who were early supporters of OpenVPMS and who are entitled to a 50% discount on their $300 subscription but pay the $150 development levy via the 'Early OpenVPMS Supporter' discount of 33.3333%. The store manager assigns the role via http://www.openvpms.org/users/xxxx (where xxxx is the user's login name) to access the user's profile and then editing this to set the role FiftyPercenter.

'Not For Profit (with clinic)': This is manually assigned to any organisation that is a) not for profit; b) runs a vet clinic open to all. This role gets the 'Not for profit clinic' discount of 33.3333%

'Not For Profit (no clinic)': This is manually assigned to any organisation that is a) not for profit; b) does not run a vet clinic open to outsiders. This role gets the 'Zero Cost' 100% discount.

'Developer': This is manually assigned to any person who is doing development amed at improving/expanding OpenVPMS. This role also gets the 'Zero Cost' 100% discount.

Note that via the role_delegation module, the store manager is explicitly given permission to set/unset the Subscriber, Subscribed, Subscriber-Ex and FiftyPercenter roles for any user.

If you do need to manually set the Subscriber role for some reason, do NOT just tick the Subscriber role, but rather, down the bottom of the page in the Ubercart roles section, add the Subscriber role with the appropriate expiry date.

 

Subscription date

Complete

In order to support subscription automation we need to keep a 'subscription date' in the the system.  In fact we keep the Initial Subscription date.  This has been done by adding an 'Initial Subscription' field to the user's profile (via http://www.openvpms.org/admin/user/profile ). Note that this field is hidden from the user and ie either set manually by a 'store manager' or by the system when the user first buys a subscription. This field is declared as a date and is actually held by as an array containing the day, month and year. 

We need the Initial Subscription date so that we can correctly set the expiry date, not to 12 months after the user purchases the subscription renewal, but rather to the anniversary of their initial purchase.

This is implemented by the 'Run Keygen' condition action code which sets the Subscription Date to the current date if it has not been previously set.  Note that since this code is run when payment is received, the Subscription Date is set to the date on which payment was received for the first subscription - and not the date on which the order was placed.

The code can be found at http://www.openvpms.org/admin/store/ca/2/edit/actions

Tailoring

Complete

This section records the tailoring done - so that things can be adjusted in the future if necessary. [Note that not everything is noted here - just the parts that are more difficult to find - mostly those parts that are not accessible via the top menu.]

Order Templates

The standard Ubercart order templates are held in
  /home/admin/www/sites/all/modules/ubercart/uc_order/templates

These are overidden by having modified versions in
  /home/admin/www/sites/all/themes/openv

The three files are:
  uc_order-admin.tpl.php
  uc_order-customer.tpl.php
  uc_order.tpl.php

Checks to Cheques

In the cheque payment module, the phrase "Checks should be made out to" is hard coded in the file /home/admin/www/sites/all/modules/ubercart/payment/uc_payment_pack/uc_payment_pack.module

Although there are mechanisms in Drupal to translate this, it was considered far simpler to just edit the file to change this to "Cheques should ....".

Role Expiry Date Format

In the ubercart roles module, in the file /home/admin/www/sites/all/modules/ubercart/uc_roles/uc_roles.module, and extra date format has been added to provide a d MMM YYYY date format. The modification signature is "TG 28/05/2015".

This format is used in the role expiry emails. (The standard 'small' format includes the time and this is not wanted.)

Role Expiry Type

In the same file (uc_roles.module) a 'Subscription date' (code 'sub') has been added. The modification signature is "TG 25/6/2015".

Role Expiry Date

In the same module, the file uc_roles.ca.inc, has been modified to calculate the role expiry date from the Subscription Date - provided that the Role Exiry Type is 'sub'. The modification signature is "TG 25/6/2015".

The logic used is the same as that in the keygen utility.  This ensures that the the Subscriber role has the same expiry date as the generated key.

Collapse discounts pane

By default, the discounts pane in the checkout window is shown uncollapsed as follows:

Since we do not use discount codes, and since the above may confuse users, the code has been modified to initially display the pane in its collapsed state as follows:

Note that testing has shown that if this pane is totally suppressed, then if there is a FiftyPercenter discount applicable, the amount calculations are wrong.

The only way to set this pane as initially collapsed is to modify the file /home/admin/www/sites/all/modules/uc_discounts_alt/uc_discounts/uc_discounts.module to add the following at the end of the uc_discounts_form_uc_cart_checkout_form_alter function:

/**
 * The following added by Tim G to set the uc_discounts pane to initially collapsed
 * suppressing the pane completely screws the discount calculation
 */
  $form['panes']['uc_discounts']['#collapsed'] = TRUE;

 

 

Who bought what

Complete

This module enables you to list all the purchases of a given product. You can sort the results by clicking on the appropriate column heading.  You can also export the data to a CSV file, either page at a time, or (by clicking the 'Show all records' link at the bottom) all records.

It is accessed either via the top menu via Store administration|Reports|Who Bought What or directly via http://www.openvpms.org/admin/store/reports/uc_who_bought_what

Note that the CSV file contains more data than is displayed on the screen.  In particular it shows the 'billing_company' (in column Z) - this should contain the name of the practice.

 

Debugging

Complete

If you are debugging php code (either in the 'execute php code' of conditional actions, or in modified modules) then the devel module is invaluable.

Install using 'drush dl devel' then 'drush en devel' (you only need to enable this module and not the other two in the download).

Then set the Devel module permissions for the administrator user only (via http://test.openvpms.org/admin/by-module - you are working in the test system aren't you).

We do not have this module installed in production so it needs to be installed on the test system after test is cloned from production.

Where you want debug output, use the dpm() call - eg as follows:

and the output appears in the message portion of the screen as follows:

NOTE - the dpm() calls cause errors if the devel module is not installed.  Hence these have to be removed from the code before moving it to production.