It would be useful if we could load all coupon objects associated with an order.

CommentFileSizeAuthor
#1 uc_coupon_purchase_oid-1077554.patch3.55 KBezra-g
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ezra-g’s picture

I'd like to be able to list coupons purchased with a specific order, rather than all coupons purchased by a specific user across order.

Currently, we don't store the oid of the order where the coupon was purchased.

This patch adds an oid column to {uc_coupon_purchase_users} and stores the order id when the coupon is created, and an API function to load coupons associated with an order.

ezra-g’s picture

Status: Active » Needs review
ezra-g’s picture

Status: Needs review » Needs work

We need to add this to the initial schema for fresh installations.

wodenx’s picture

Sorry for long delay in responding to this.

At a quick glance, it looks like there needs to be a check on whether the order_id is null - or need to remove not_null from the schema.

Otherwise looks ok to me.

@longwave - what do you think?

longwave’s picture

I agree not_null might need to be removed - this would also allow it to cope with any rows that already exist in the table. The new API function needs better documentation as well. Otherwise it looks okay.

@ezra-g: isn't hook_schema() and hook_install() enough to do that?

longwave’s picture

Actually, setting 'not null' = TRUE and 'default' = 0 should be enough here.