Commit 43d9981e by Saleem Latif

track enrollment code purchases on ecommerce basket page.

parent 4ed4b74d
......@@ -27,22 +27,10 @@ def track_completed_order(sender, order=None, **kwargs): # pylint: disable=unus
if order.total_excl_tax <= 0:
return
for line in order.lines.all():
if line.product.is_coupon_product or line.product.is_enrollment_code_product:
return
voucher = order.basket_discounts.filter(voucher_id__isnull=False).first()
coupon = voucher.voucher_code if voucher else None
try:
bundle_id = BasketAttribute.objects.get(basket=order.basket, attribute_type__name=BUNDLE).value_text
except BasketAttribute.DoesNotExist:
bundle_id = None
properties = {
'orderId': order.number,
'total': str(order.total_excl_tax),
'currency': order.currency,
'coupon': coupon,
'discount': str(order.total_discount_incl_tax),
'products': [
{
......@@ -60,6 +48,23 @@ def track_completed_order(sender, order=None, **kwargs): # pylint: disable=unus
],
}
for line in order.lines.all():
if line.product.is_enrollment_code_product:
track_segment_event(order.site, order.user, 'Bulk Enrollment Codes Purchase Completed', properties)
if line.product.is_coupon_product or line.product.is_enrollment_code_product:
return
voucher = order.basket_discounts.filter(voucher_id__isnull=False).first()
coupon = voucher.voucher_code if voucher else None
try:
bundle_id = BasketAttribute.objects.get(basket=order.basket, attribute_type__name=BUNDLE).value_text
except BasketAttribute.DoesNotExist:
bundle_id = None
properties['coupon'] = coupon
try:
bundle_id = BasketAttribute.objects.get(basket=order.basket, attribute_type__name=BUNDLE).value_text
program = get_program(bundle_id, order.basket.site.siteconfiguration)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment