Drupal Ubercart non shippable workflow changes

The default UberCart workflow for non shippable products, such as downloadable or non physical products (e.g. role or group access) is to mark the order "completed" only if it only contains these type of products. In most cases this is fine but a problem occurs when a customer purchases mixed physical and non shippable products. In this case access to non shippable products is not immediate. This workflow deviates from the common presumption that non physical transaction should occur instantly and be processed independantly from physical goods. Unfortunately modifying the Conditional action to trigger on a order status change to "Completed" instead of the more appropriate "Payment received" has negative repercusions. The proposed solution helps to alleviate this situation.

First three caveats:

  1. This problem only occurs if the customer is not logged in during the checkout.
  2. The solution may have problems with certain Payment processors, such as PayPal, where the "uc_cart_complete_sale" function may be eroneously called twice during checkout. This is another problem that should be addressed elsewhere.
  3. This solution may cause issues if File Grants have to be renewed because the customer could not complete a successful download within the specified configuration. e.g. 3 downloads from 2 IP addresses. 

File access grant on payment received<

Switching the "Renew purchased files" Conditional Action, to trigger on order status change to "Payment received" instead of "Completed," causes problems because it appears to trigger at the wrong time. Looking at customized store logs it is apparent that the trigger can execute before the "uc_checkout_complete," or "Customer completes checkout" predicate, which is the only action that changes the order status to "Complete." When this trigger executes, the customer information has not been created or loaded, which results in a UID (User ID) of 0 (annonymous), which in turn causes the file grants to fail. This is because file grants require a user account to track, and prepare the file for download, even though the customer may be under the assuption that they are using a truely anonymous checkout.

Switch to "Customer completes checkout" trigger<

If we recreate the file grant action we can set the trigger to use the "uc_checkout_complete" or "Customer completes checkout" predicate. We cannot edit the existing "Meta Data" if "Conditions" or "Actions" are already assigned (which by default they are). Adding the contditions Order status is "Completed" OR Order Status is "Payment received", we can safely execute the file grant function knowing that the customer account information is loaded and the file grant will succeed. The psuedo conditional action code is:

Trigger: Customer completes checkout
Conditions: Check the order status is "Completed" OR Check the order status is "Payment received"
Action:  Renewal - Renew the files on an order
Weight: Greater than "Update order status upon checkout completion with full payment" action <

Be sure to disable the default "Renew purchased files" Conditional Action so that it does not cause unexpected.

Instant File, Role, and Group access on purchase<

The new conditional action will execute after the customer information has been loaded for all three possible checkout scenarions if the weighting is correct:

  1. Anonymous checkout creating new account. With or without "Login user on checkout" option.
  2. Anonymous checkout matching email address of existing account but completing checkout without logging the user in.
  3. Logged in customer before checkout.

When a customer purchases physical and non physical products they will get instant access to the non physical product (file, role, group) and the standard shipping workflow can complete normally, with the order being marked "completed" only when access to all non physical products is granted and all shippable products have been sent. 

Add your comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  dSMS    H5@HEH88H8   .dESEEb.    .d5@EEb.    .d@M5Eb.  
dS85E dMHP dE@P Y9Hb d99P YH5b d98P Y8Hb
88S d@9P Y98b. dM8P 9M5 955 @@S
@H5 d@5P "YM@5@5" YH5b. dHMM 5S@dMS@b.
5@M E9H55SM8 .d@P""Y9b. "Y5M9P99H H98P "Y99b
E@M dE8P 85S M5H @88 85H 8ME
8HS dM5P Y5Eb dSHP YMSb d85P YSHb d8HP
5@ME@@E dH8P "Y9M5@P" "YSHMMP" "YHS98P"