Merge branch 'feature/ecommerce-gtag' into 'master'

Feature/ecommerce gtag

See merge request lilschool/site!408
remotes/origin/feature/new-certs-1-10-19
Danil 6 years ago
commit 2b7a3a8dde
  1. 5
      apps/course/models.py
  2. 15
      apps/course/templates/course/course.html
  3. 12
      apps/course/templatetags/lil_utils.py
  4. 2
      apps/payment/models.py
  5. 12
      apps/payment/templates/payment/course_payment_success.html
  6. 1
      apps/payment/templates/payment/gift_certificate_item.html
  7. 13
      apps/payment/templates/payment/gift_certificate_payment_success.html
  8. 68
      apps/payment/templates/payment/pay.html
  9. 68
      apps/payment/templates/payment/payment_success.html
  10. 72
      apps/payment/views.py
  11. 17
      project/templates/blocks/lil_store_js.html
  12. 5
      project/templates/lilcity/layer.html
  13. 1
      project/templates/lilcity/packages.html
  14. 6
      project/urls.py
  15. 38
      web/package.json
  16. 1
      web/src/js/app.js
  17. 96
      web/src/js/modules/gtag.js

@ -144,6 +144,11 @@ class Course(BaseModel, DeactivatedMixin):
return super().save() return super().save()
@property
def age_str(self):
ages = dict(self.AGE_CHOICES)
return ages.get(self.age)
@property @property
def url(self): def url(self):
return self.get_absolute_url() return self.get_absolute_url()

@ -394,5 +394,18 @@
{% block foot %} {% block foot %}
{% include "templates/blocks/popup_course_buy.html" %} {% include "templates/blocks/popup_course_buy.html" %}
<script type="text/javascript" src="{% static 'course.js' %}"></script>
{% endblock foot %} {% endblock foot %}
{% block foot_js %}
<script type="text/javascript" src="{% static 'course.js' %}"></script>
<script>
window.LIL_STORE.data.gtagProduct = {
id: +'{{ course.id }}',
name: '{{ course.title }}',
category: '{{ course.category.title }}/{{ course.age_str }}',
brand: 'Lil.School/{{ course.author.get_full_name }}',
quantity: 1,
price: +'{{ course.price|default:0|floatformat:"0" }}',
};
</script>
{% endblock foot_js %}

@ -0,0 +1,12 @@
from django import template
register = template.Library()
@register.simple_tag(takes_context=True)
def same_url(context, **kwargs):
request = context.get('request')
args = request.GET.copy()
args.update(kwargs)
return '%s?%s' % (request.path, args.urlencode())

@ -301,7 +301,7 @@ class Payment(PolymorphicModel):
payment=self) payment=self)
if created: if created:
from apps.notification.tasks import send_gift_certificate from apps.notification.tasks import send_gift_certificate
send_gift_certificate(ugs.id) send_gift_certificate.delay(ugs.id)
# Если это не первая покупка, - отправляем бонусы юзеру # Если это не первая покупка, - отправляем бонусы юзеру
if self.user.paid_one_more and not self.user.bonuses.filter( if self.user.paid_one_more and not self.user.bonuses.filter(
is_service=True, action_name=UserBonus.ACTION_PAID_ONE_MORE).count(): is_service=True, action_name=UserBonus.ACTION_PAID_ONE_MORE).count():

@ -1,12 +0,0 @@
{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %}
<div class="section">
<div class="section__center center center_xs">
<div class="done">
<div class="done__title title">Вы успешно приобрели курс!</div>
<div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{{ course.url }}">ПЕРЕЙТИ К КУРСУ</a>
</div>
</div>
</div>
</div>
{% endblock content %}

@ -28,6 +28,7 @@
<a class="gift-certificates__buy-btn btn" <a class="gift-certificates__buy-btn btn"
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
href="{% url 'gift-certificate-checkout' gift_certificate.id %}" href="{% url 'gift-certificate-checkout' gift_certificate.id %}"
data-gift-certificate="{{ gift_certificate.id }}" data-price="{{ gift_certificate.price|floatformat:'0' }}"
{% else %} {% else %}
href="#" data-popup=".js-popup-auth" href="#" data-popup=".js-popup-auth"
{% endif %}>Купить сертификат</a> {% endif %}>Купить сертификат</a>

@ -1,13 +0,0 @@
{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %}
<div class="section">
<div class="section__center center center_xs">
<div class="done">
<div class="done__title title">Вы успешно приобрели подарочный сертификат!</div>
<div>Мы отправили письмо с сертификатом на вашу почту.</div>
<div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{% url 'index' %}">СПАСИБО</a>
</div>
</div>
</div>
</div>
{% endblock content %}

@ -1,21 +1,24 @@
{% extends "templates/lilcity/index.html" %} {% extends "templates/lilcity/index.html" %}
{% load static %} {% load static %}
{% load rupluralize from plural %} {% load rupluralize from plural %}
{% load same_url from lil_utils %}
{% block content %} {% block content %}
<div class="section"> <div class="section">
<div class="section__center center"> <div class="section__center center">
{% if school and request.user.bonus and not payment.bonus %} {% if school or gift_certificate %}
{% if request.user.bonus >= payment.amount %} {% if request.user.bonus and not payment.bonus %}
<a class="btn" href="{{ request.get_full_path }}&use_bonuses=1" style="margin-bottom: 20px">Оплатить бонусами</a> {% if request.user.bonus >= payment.amount %}
<div class="text2"><p>или купить онлайн</p></div> <a id="pay-with-bonuses" class="btn" href="{% same_url use_bonuses=1 %}" style="margin-bottom: 20px">Оплатить бонусами</a>
{% else %} <div class="text2"><p>или купить онлайн</p></div>
<div class="text2"><p>Для оплаты части стоимости вы можете использовать бонусы</p></div> {% else %}
<label id="use-bonuses-checkbox" class="switch" style="margin-bottom: 20px"> <div class="text2"><p>Для оплаты части стоимости вы можете использовать бонусы</p></div>
<input class="switch__input" data-url="{{ request.get_full_path }}" value="true" type="checkbox"> <label id="use-bonuses-checkbox" class="switch" style="margin-bottom: 20px">
<span class="switch__content">Использовать {{ request.user.bonus|rupluralize:'бонус,бонуса,бонусов' }}</span> <input class="switch__input" data-url="{{ request.get_full_path }}" value="true" type="checkbox">
</label> <span class="switch__content">Использовать {{ request.user.bonus|rupluralize:'бонус,бонуса,бонусов' }}</span>
{% endif %} </label>
{% endif %}
{% endif %}
{% endif %} {% endif %}
<div id="pw-widget" class="pw-widget"> <div id="pw-widget" class="pw-widget">
{% include "./paymentwall_widget.html" %} {% include "./paymentwall_widget.html" %}
@ -24,6 +27,45 @@
</div> </div>
{% endblock content %} {% endblock content %}
{% block foot %} {% block foot_js %}
<script>
window.LIL_STORE.data.gtagProduct = {
{% if course %}
id: +'{{ course.id }}',
name: '{{ course.title }}',
category: '{{ course.category.title }}/{{ course.age_str }}',
brand: 'Lil.School/{{ course.author.get_full_name }}',
quantity: 1,
price: +'{{ course.price|default:0|floatformat:"0" }}',
{% endif %}
{% if school %}
id: +'{{ payment.package.id }}',
name: 'Подписка с {{ payment.date_start|date:"j-m-Y" }} до {{ payment.date_end|date:"j-m-Y" }}',
category: 'Подписка',
brand: 'Lil.School',
quantity: 1,
price: +'{{ payment.amount|default:0|floatformat:"0" }}',
{% endif %}
{% if camp %}
id: +'{{ payment.package.id }}',
name: 'Подписка с {{ payment.date_start|date:"j-m-Y" }} до {{ payment.date_end|date:"j-m-Y" }}',
category: 'Подписка',
brand: 'Lil.School',
quantity: 1,
price: +'{{ payment.amount|default:0|floatformat:"0" }}',
{% endif %}
{% if gift_certificate %}
id: +'{{ gift_certificate.id }}',
name: 'Сертификат {{ gift_certificate.price }}',
category: 'Подарочный сертификат',
brand: 'Lil.School',
quantity: 1,
price: +'{{ gift_certificate.price|default:0|floatformat:"0" }}',
{% endif %}
};
</script>
<script type="text/javascript" src="{% static 'pay.js' %}"></script> <script type="text/javascript" src="{% static 'pay.js' %}"></script>
{% endblock foot %} {% endblock foot_js %}

@ -1,8 +1,17 @@
{% extends "templates/lilcity/index.html" %} {% load static %}{% load plural %} {% extends "templates/lilcity/index.html" %}
{% load static %}
{% load rupluralize from plural %}
{% block content %} {% block content %}
<div class="section"> <div class="section">
<div class="section__center center center_xs"> <div class="section__center center center_xs">
<div class="done"> <div class="done">
{% if course %}
<div class="done__title title">Вы успешно приобрели курс!</div>
<div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{{ course.url }}">ПЕРЕЙТИ К КУРСУ</a>
</div>
{% endif %}
{% if school %} {% if school %}
<div class="done__title title">Вы успешно приобрели доступ на {{ duration|rupluralize:"месяц,месяца,месяцев" }}!</div> <div class="done__title title">Вы успешно приобрели доступ на {{ duration|rupluralize:"месяц,месяца,месяцев" }}!</div>
<div class="done__foot"> <div class="done__foot">
@ -15,19 +24,62 @@
<a class="done__btn btn btn_md btn_stroke" href="{% url 'school:drawing-camp' %}">ПЕРЕЙТИ В ЛАГЕРЬ</a> <a class="done__btn btn btn_md btn_stroke" href="{% url 'school:drawing-camp' %}">ПЕРЕЙТИ В ЛАГЕРЬ</a>
</div> </div>
{% endif %} {% endif %}
{% if course %}
<div class="done__title title">Вы успешно приобрели курс!</div>
<div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{{ course.url }}">ПЕРЕЙТИ К КУРСУ</a>
</div>
{% endif %}
{% if gift_certificate %} {% if gift_certificate %}
<div class="done__title title">Вы успешно приобрели подарочный сертификат!</div> <div class="done__title title">Вы успешно приобрели подарочный сертификат!</div>
<div>Мы отправили письмо с сертификатом на вашу почту.</div>
<div class="done__foot"> <div class="done__foot">
<a class="done__btn btn btn_md btn_stroke" href="{% url 'index' %}">ПЕРЕЙТИ НА ГЛАВНУЮ</a> <a class="done__btn btn btn_md btn_stroke" href="{% url 'index' %}">СПАСИБО</a>
</div> </div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div> </div>
{% endblock content %} {% endblock content %}
{% block foot_js %}
<script>
window.LIL_STORE.data.gtagProduct = {
{% if course %}
id: +'{{ course.id }}',
name: '{{ course.title }}',
category: '{{ course.category.title }}/{{ course.age_str }}',
brand: 'Lil.School/{{ course.author.get_full_name }}',
quantity: 1,
price: +'{{ course.price|default:0|floatformat:"0" }}',
{% endif %}
{% if school %}
id: +'{{ payment.package.id }}',
name: 'Подписка с {{ payment.date_start|date:"j-m-Y" }} до {{ payment.date_end|date:"j-m-Y" }}',
category: 'Подписка',
brand: 'Lil.School',
quantity: 1,
price: +'{{ payment.amount|default:0|floatformat:"0" }}',
{% endif %}
{% if camp %}
id: +'{{ payment.package.id }}',
name: 'Подписка с {{ payment.date_start|date:"j-m-Y" }} до {{ payment.date_end|date:"j-m-Y" }}',
category: 'Подписка',
brand: 'Lil.School',
quantity: 1,
price: +'{{ payment.amount|default:0|floatformat:"0" }}',
{% endif %}
{% if gift_certificate %}
id: +'{{ gift_certificate.id }}',
name: 'Сертификат {{ gift_certificate.price }}',
category: 'Подарочный сертификат',
brand: 'Lil.School',
quantity: 1,
price: +'{{ gift_certificate.price|default:0|floatformat:"0" }}',
{% endif %}
};
window.LIL_STORE.data.gtagTransaction = {
transaction_id: +'{{ payment.id }}',
value: +'{{ payment.amount|floatformat:"0" }}',
checkout_step: 1,
items: [window.LIL_STORE.data.gtagProduct],
};
</script>
{% endblock foot_js %}

@ -4,7 +4,7 @@ import json
import logging import logging
from datetime import timedelta from datetime import timedelta
from urllib.parse import urlsplit from urllib.parse import urlsplit, urlencode
import datetime import datetime
@ -37,22 +37,28 @@ class DisallowedPingbackHost(Exception):
@method_decorator(login_required, name='dispatch') @method_decorator(login_required, name='dispatch')
class CourseBuySuccessView(TemplateView): class CourseBuySuccessView(TemplateView):
template_name = 'payment/course_payment_success.html' template_name = 'payment/payment_success.html'
def get(self, request, pk=None, *args, **kwargs): def get(self, request, payment_id, *args, **kwargs):
course = get_object_or_404(Course, pk=pk) payment = CoursePayment.objects.get(pk=payment_id)
return self.render_to_response(context={'course': course}) course = payment.course
return self.render_to_response(context={'course': course, 'payment': payment})
@method_decorator(login_required, name='dispatch') @method_decorator(login_required, name='dispatch')
class SchoolBuySuccessView(TemplateView): class SchoolBuySuccessView(TemplateView):
template_name = 'payment/payment_success.html' template_name = 'payment/payment_success.html'
def get(self, request, pk=None, is_camp=False, *args, **kwargs): def get(self, request, payment_id, is_camp=False, *args, **kwargs):
if is_camp:
payment = DrawingCampPayment.objects.get(pk=payment_id)
else:
payment = SchoolPayment.objects.get(pk=payment_id)
context = { context = {
'duration': request.GET.get('duration'), 'duration': request.GET.get('duration'),
'camp': is_camp, 'camp': is_camp,
'school': not is_camp 'school': not is_camp,
'payment': payment,
} }
return self.render_to_response(context=context) return self.render_to_response(context=context)
@ -93,7 +99,7 @@ class CourseBuyView(TemplateView):
course_payment.bonus = bonus course_payment.bonus = bonus
course_payment.save() course_payment.save()
if course_payment.is_paid(): if course_payment.is_paid():
return redirect(reverse_lazy('course_payment_success', args=[course.id])) return redirect(reverse_lazy('course_payment_success', args=[course_payment.id]))
product = Product( product = Product(
f'course_{course_payment.id}', f'course_{course_payment.id}',
course_payment.amount, course_payment.amount,
@ -110,7 +116,7 @@ class CourseBuyView(TemplateView):
'evaluation': 1, 'evaluation': 1,
'demo': 1, 'demo': 1,
'test_mode': 1, 'test_mode': 1,
'success_url': host + str(reverse_lazy('course_payment_success', args=[course.id])), 'success_url': host + str(reverse_lazy('course_payment_success', args=[course_payment.id])),
'failure_url': host + str(reverse_lazy('payment-error')), 'failure_url': host + str(reverse_lazy('payment-error')),
} }
) )
@ -118,7 +124,11 @@ class CourseBuyView(TemplateView):
if request.user_agent.is_mobile: if request.user_agent.is_mobile:
attrs['width'] = '100%' attrs['width'] = '100%'
attrs['height'] = '600' attrs['height'] = '600'
return self.render_to_response(context={'widget': widget.get_html_code(attrs)}) return self.render_to_response(context={
'widget': widget.get_html_code(attrs),
'payment': course_payment,
'course': course,
})
@method_decorator(login_required, name='dispatch') @method_decorator(login_required, name='dispatch')
@ -164,7 +174,7 @@ class SchoolBuyView(TemplateView):
school_payment.bonus = bonus school_payment.bonus = bonus
school_payment.save() school_payment.save()
if school_payment.is_paid(): if school_payment.is_paid():
return redirect('%s?duration=%s' % (str(reverse_lazy('payment-success')), duration)) return redirect('%s?duration=%s' % (str(reverse_lazy('payment-success', args=[school_payment.id])), duration))
if payment_id and school_payment.bonus and not use_bonuses: if payment_id and school_payment.bonus and not use_bonuses:
bonus = school_payment.bonus bonus = school_payment.bonus
school_payment.amount += school_payment.bonus school_payment.amount += school_payment.bonus
@ -186,7 +196,7 @@ class SchoolBuyView(TemplateView):
'evaluation': 1, 'evaluation': 1,
'demo': 1, 'demo': 1,
'test_mode': 1, 'test_mode': 1,
'success_url': host + str(reverse_lazy('payment-success')) + '?duration=%s' % duration, 'success_url': host + str(reverse_lazy('payment-success', args=[school_payment.id])) + '?duration=%s' % duration,
'failure_url': host + str(reverse_lazy('payment-error')), 'failure_url': host + str(reverse_lazy('payment-error')),
} }
) )
@ -246,7 +256,7 @@ class DrawingCampBuyView(TemplateView):
camp_payment.bonus = bonus camp_payment.bonus = bonus
camp_payment.save() camp_payment.save()
if camp_payment.is_paid(): if camp_payment.is_paid():
return redirect(reverse_lazy('camp-payment-success')) return redirect(reverse_lazy('camp-payment-success', args=[camp_payment.id]))
product = Product( product = Product(
f'drawing_camp_{camp_payment.id}', f'drawing_camp_{camp_payment.id}',
camp_payment.amount, camp_payment.amount,
@ -263,7 +273,7 @@ class DrawingCampBuyView(TemplateView):
'evaluation': 1, 'evaluation': 1,
'demo': 1, 'demo': 1,
'test_mode': 1, 'test_mode': 1,
'success_url': host + str(reverse_lazy('camp-payment-success')), 'success_url': host + str(reverse_lazy('camp-payment-success', args=[camp_payment.id])),
'failure_url': host + str(reverse_lazy('payment-error')), 'failure_url': host + str(reverse_lazy('payment-error')),
} }
) )
@ -271,7 +281,11 @@ class DrawingCampBuyView(TemplateView):
if request.user_agent.is_mobile: if request.user_agent.is_mobile:
attrs['width'] = '100%' attrs['width'] = '100%'
attrs['height'] = '600' attrs['height'] = '600'
return self.render_to_response(context={'widget': widget.get_html_code(attrs)}) return self.render_to_response(context={
'widget': widget.get_html_code(attrs),
'payment': camp_payment,
'camp': True,
})
@method_decorator(csrf_exempt, name='dispatch') @method_decorator(csrf_exempt, name='dispatch')
@ -432,10 +446,25 @@ class GiftCertificateBuyView(TemplateView):
def get(self, request, pk, *args, **kwargs): def get(self, request, pk, *args, **kwargs):
gift_certificate = get_object_or_404(GiftCertificate, pk=pk) gift_certificate = get_object_or_404(GiftCertificate, pk=pk)
roistat_visit = request.COOKIES.get('roistat_visit', None) roistat_visit = request.COOKIES.get('roistat_visit', None)
use_bonuses = request.GET.get('use_bonuses')
gift_certificate_payment = GiftCertificatePayment.objects.create( gift_certificate_payment = GiftCertificatePayment.objects.create(
user=request.user, user=request.user,
gift_certificate=gift_certificate, gift_certificate=gift_certificate,
roistat_visit=roistat_visit,) roistat_visit=roistat_visit,)
if use_bonuses and request.user.bonus:
if request.user.bonus >= gift_certificate_payment.amount:
bonus = UserBonus.objects.create(amount=-gift_certificate_payment.amount, user=request.user,
payment=gift_certificate_payment)
gift_certificate_payment.amount = 0
gift_certificate_payment.status = Pingback.PINGBACK_TYPE_REGULAR
else:
bonus = UserBonus.objects.create(amount=-request.user.bonus, user=request.user,
payment=gift_certificate_payment)
gift_certificate_payment.amount -= request.user.bonus
gift_certificate_payment.bonus = bonus
gift_certificate_payment.save()
if gift_certificate_payment.is_paid():
return redirect(reverse_lazy('gift-certificate-payment-success', args=[gift_certificate_payment.id]))
context = self.get_context_data(**kwargs) context = self.get_context_data(**kwargs)
product = Product( product = Product(
f'gift_certificate_{gift_certificate_payment.id}', f'gift_certificate_{gift_certificate_payment.id}',
@ -463,19 +492,24 @@ class GiftCertificateBuyView(TemplateView):
attrs['width'] = '100%' attrs['width'] = '100%'
attrs['height'] = '600' attrs['height'] = '600'
context['widget'] = widget.get_html_code(attrs) context['widget'] = widget.get_html_code(attrs)
context['payment'] = gift_certificate_payment
context['gift_certificate'] = gift_certificate
return self.render_to_response(context) return self.render_to_response(context)
@method_decorator(login_required, name='dispatch') @method_decorator(login_required, name='dispatch')
class GiftCertificateBuySuccessView(TemplateView): class GiftCertificateBuySuccessView(TemplateView):
template_name = 'payment/gift_certificate_payment_success.html' template_name = 'payment/payment_success.html'
def get(self, request, payment_id=None, *args, **kwargs): def get(self, request, payment_id, *args, **kwargs):
try: try:
GiftCertificatePayment.objects.get(id=payment_id) payment = GiftCertificatePayment.objects.get(id=payment_id)
except: except:
raise Http404() raise Http404()
return self.render_to_response(context={'gift_certificate': True}) return self.render_to_response(context={
'gift_certificate': payment.gift_certificate,
'payment': payment,
})
@method_decorator(login_required, name='dispatch') @method_decorator(login_required, name='dispatch')

@ -22,8 +22,11 @@
}, },
components: {}, components: {},
urls: { urls: {
course: /course\/\w+\/?$/,
courseBuy: /course\/\d+\/checkout/,
courseBuySuccess: /payments\/course\/\d+\/success/,
courses: "{% url 'courses' %}", courses: "{% url 'courses' %}",
courseEdit: /\/course\/\d+\/edit/, courseEdit: /course\/\d+\/edit/,
courseCreate: "{% url 'course_create' %}", courseCreate: "{% url 'course_create' %}",
userProfileEdit: "{% url 'user-edit-profile' %}", userProfileEdit: "{% url 'user-edit-profile' %}",
userProfile: "{% url 'user-profile' %}", userProfile: "{% url 'user-profile' %}",
@ -31,6 +34,16 @@
faq: "{% url 'faq' %}", faq: "{% url 'faq' %}",
contestEdit: /contest\/\w+\/edit/, contestEdit: /contest\/\w+\/edit/,
userGalleryEdit: "{% url 'user-gallery-edit' %}", userGalleryEdit: "{% url 'user-gallery-edit' %}",
school: "{% url 'school:school' %}",
schoolBuy: "{% url 'school-checkout' %}",
schoolBuySuccess: /payments\/school\/\d+\/success/,
camp: "{% url 'school:drawing-camp' %}",
campBuy: "{% url 'camp-checkout' %}",
campBuySuccess: /payments\/camp\/\d+\/success/,
giftCertificates: "{% url 'gift-certificates' %}",
giftCertificateBuy: /gift-certificate\/\d+\/checkout/,
giftCertificateBuySuccess: /payments\/gift-certificate\/\d+\/success/,
prices: "{% url 'packages' %}",
}, },
flags: { flags: {
referrer: '{{ referrer.id|default:'' }}', referrer: '{{ referrer.id|default:'' }}',
@ -44,7 +57,7 @@
urlPatternNames = [urlPatternNames]; urlPatternNames = [urlPatternNames];
} }
return urlPatternNames.filter(function(urlPatternName){ return urlPatternNames.filter(function(urlPatternName){
return window.location.pathname.search(window.LIL_STORE.urls[urlPatternName]) > -1; return window.LIL_STORE.urls[urlPatternName] && window.location.pathname.search(window.LIL_STORE.urls[urlPatternName]) > -1;
}).length > 0; }).length > 0;
}, },
isIndexPage: window.location.pathname == '/', isIndexPage: window.location.pathname == '/',

@ -68,8 +68,6 @@
{% block layer_head %}{% endblock layer_head %} {% block layer_head %}{% endblock layer_head %}
</head> </head>
<body {% block body_attr %}{% endblock body_attr %}> <body {% block body_attr %}{% endblock body_attr %}>
{% block layer_body %}
{% endblock layer_body %}
{% if settings.DEV_SERVER or settings.DEBUG %} {% if settings.DEV_SERVER or settings.DEBUG %}
<!-- Google Tag Manager (noscript) --> <!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WGMCNS7&gtm_auth=vlrscZ1PfuTiK5kaBcQ-Ag&gtm_preview=env-5&gtm_cookies_win=x" <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WGMCNS7&gtm_auth=vlrscZ1PfuTiK5kaBcQ-Ag&gtm_preview=env-5&gtm_cookies_win=x"
@ -81,5 +79,8 @@
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) --> <!-- End Google Tag Manager (noscript) -->
{% endif %} {% endif %}
{% block layer_body %}
{% endblock layer_body %}
</body> </body>
</html> </html>

@ -38,6 +38,7 @@
{% if user.is_authenticated %} {% if user.is_authenticated %}
href="{% url 'school-checkout' %}?duration={{ package.duration }}" href="{% url 'school-checkout' %}?duration={{ package.duration }}"
data-package="{{ package.id }}" data-duration="{{ package.duration }}" data-price="{{ package.price|floatformat:'0' }}"
{% else %} {% else %}
href="#" data-popup=".js-popup-auth" href="#" data-popup=".js-popup-auth"
{% endif %} {% endif %}

@ -66,9 +66,9 @@ urlpatterns = [
path('lesson/<int:lesson_id>/comment', lessoncomment, name='lessoncomment'), path('lesson/<int:lesson_id>/comment', lessoncomment, name='lessoncomment'),
path('payments/ping', PaymentwallCallbackView.as_view(), name='payment-ping'), path('payments/ping', PaymentwallCallbackView.as_view(), name='payment-ping'),
path('paymentwall/pingback', PaymentwallCallbackView.as_view(), name='payment-ping-second'), path('paymentwall/pingback', PaymentwallCallbackView.as_view(), name='payment-ping-second'),
path('payments/course/<int:pk>/success', CourseBuySuccessView.as_view(), name='course_payment_success'), path('payments/course/<int:payment_id>/success', CourseBuySuccessView.as_view(), name='course_payment_success'),
path('payments/school/success', SchoolBuySuccessView.as_view(), name='payment-success'), path('payments/school/<int:payment_id>/success', SchoolBuySuccessView.as_view(), name='payment-success'),
path('payments/school/camp/success', SchoolBuySuccessView.as_view(), name='camp-payment-success', path('payments/school/camp/<int:payment_id>/success', SchoolBuySuccessView.as_view(), name='camp-payment-success',
kwargs={'is_camp': True}), kwargs={'is_camp': True}),
path('payments/error', TemplateView.as_view(template_name='payment/payment_error.html'), name='payment-error'), path('payments/error', TemplateView.as_view(template_name='payment/payment_error.html'), name='payment-error'),
path('school/checkout', SchoolBuyView.as_view(), name='school-checkout'), path('school/checkout', SchoolBuyView.as_view(), name='school-checkout'),

@ -10,7 +10,7 @@
"devDependencies": { "devDependencies": {
"autoprefixer": "^6.3.3", "autoprefixer": "^6.3.3",
"babel-core": "^6.26.0", "babel-core": "^6.26.0",
"babel-loader": "^7.1.2", "babel-loader": "^7.1.5",
"babel-plugin-transform-runtime": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
@ -24,13 +24,13 @@
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"require-dir": "^0.3.0", "require-dir": "^0.3.0",
"run-sequence": "^1.1.5", "run-sequence": "^1.1.5",
"sass-loader": "^7.0.1", "sass-loader": "^7.3.1",
"style-loader": "^0.20.1", "style-loader": "^0.20.1",
"through2": "^2.0.1", "through2": "^2.0.5",
"url-loader": "^0.6.2", "url-loader": "^0.6.2",
"vue-loader": "^14.1.1", "vue-loader": "^14.2.4",
"vue-style-loader": "^3.1.2", "vue-style-loader": "^3.1.2",
"vue-template-compiler": "^2.5.13", "vue-template-compiler": "^2.6.10",
"webpack": "^3.10.0" "webpack": "^3.10.0"
}, },
"dependencies": { "dependencies": {
@ -38,32 +38,32 @@
"autosize-input": "^1.0.2", "autosize-input": "^1.0.2",
"axios": "^0.19.0", "axios": "^0.19.0",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"baguettebox.js": "^1.10.0", "baguettebox.js": "^1.11.0",
"bowser": "^2.1.2", "bowser": "^2.6.0",
"clipboard": "^2.0.1", "clipboard": "^2.0.4",
"downscale": "^1.0.4", "downscale": "^1.0.6",
"extract-loader": "^3.1.0", "extract-loader": "^3.1.0",
"glob": "^7.1.2", "glob": "^7.1.4",
"history": "^4.7.2", "history": "^4.9.0",
"ilyabirman-likely": "^2.3.0", "ilyabirman-likely": "^2.3.0",
"inputmask": "^3.3.11", "inputmask": "^3.3.11",
"jquery": "^3.4.1", "jquery": "^3.4.1",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.1",
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"modal-video": "git+https://github.com/gzbender/modal-video.git", "modal-video": "git+https://github.com/gzbender/modal-video.git",
"moment": "^2.20.1", "moment": "^2.24.0",
"owl.carousel": "^2.2.0", "owl.carousel": "^2.2.0",
"slugify": "^1.2.9", "slugify": "^1.3.5",
"smooth-scroll": "^12.1.5", "smooth-scroll": "^12.1.5",
"sortablejs": "^1.7.0", "sortablejs": "^1.9.0",
"svg-sprite-loader": "^3.7.3", "svg-sprite-loader": "^3.9.2",
"uuid": "^3.2.1", "uuid": "^3.3.3",
"validator": "^9.2.0", "validator": "^9.2.0",
"vue": "^2.5.13", "vue": "^2.6.10",
"vue-autosize": "^1.0.2", "vue-autosize": "^1.0.2",
"vue-awesome-swiper": "^3.1.3", "vue-awesome-swiper": "^3.1.3",
"vue-tags-component": "^1.3.0", "vue-tags-component": "^1.3.0",
"vuedraggable": "^2.16.0", "vuedraggable": "^2.23.0",
"vuejs-datepicker": "^0.9.25", "vuejs-datepicker": "^0.9.25",
"vuelidate": "^0.6.1" "vuelidate": "^0.6.1"
} }

@ -17,6 +17,7 @@ import "./modules/comments";
import "./modules/password-show"; import "./modules/password-show";
import "./modules/notification"; import "./modules/notification";
import "./modules/mixpanel"; import "./modules/mixpanel";
import "./modules/gtag";
import "../sass/app.sass"; import "../sass/app.sass";

@ -0,0 +1,96 @@
import $ from 'jquery';
$(document).ready(function () {
if(! window.LIL_STORE.user.id){
return;
}
if(window.LIL_STORE.urlIs(['courseBuy', 'schoolBuy', 'campBuy', 'giftCertificateBuy'])){
if(window.LIL_STORE.urlIs(['schoolBuy', 'giftCertificateBuy'])){
const $useBonuses = $('#use-bonuses-checkbox');
$useBonuses.find('.switch__content').click(() => {
window.gtag('event', 'set_checkout_option', {
"checkout_step": 1,
"checkout_option": "use_bonuses",
"value": +!$useBonuses.find('input').prop('checked'),
});
});
$('#pay-with-bonuses').click(() => {
window.gtag('event', 'set_checkout_option', {
"checkout_step": 1,
"checkout_option": "use_bonuses",
"value": 1,
});
})
}
window.gtag('event', 'checkout_progress', {
"items": [window.LIL_STORE.data.gtagProduct],
});
}
if(window.LIL_STORE.urlIs(['courseBuySuccess', 'schoolBuySuccess', 'campBuySuccess', 'giftCertificateBuySuccess'])){
window.gtag('event', 'checkout_progress', {
"items": [window.LIL_STORE.data.gtagProduct],
});
window.gtag('event', 'purchase', window.LIL_STORE.data.gtagTransaction);
}
if(window.LIL_STORE.urlIs('course')){
const $btn = $('[data-popup=".js-popup-course-buy"]');
$btn.click(() => {
window.gtag('event', 'begin_checkout', {
"items": [window.LIL_STORE.data.gtagProduct],
});
});
const $popup = $('.js-popup-course-buy');
const $useBonusesSwitch = $popup.find('.buy__bonuses .switch__content');
const $useBonusesInput = $popup.find('.buy__bonuses input');
$useBonusesSwitch.click(() => {
window.gtag('event', 'set_checkout_option', {
"checkout_step": 1,
"checkout_option": "use_bonuses",
"value": +!$useBonusesInput.prop('checked'),
});
});
const $buyBtn = $popup.find('.buy__btn');
$buyBtn.click(() => {
window.gtag('event', 'checkout_progress', {
"items": [window.LIL_STORE.data.gtagProduct],
});
});
}
if(window.LIL_STORE.urlIs('prices')){
const $btns = $('.package__btn');
$btns.click(function () {
const $this = $(this);
window.gtag('event', 'begin_checkout', {
"items": [{
id: $this.data('package'),
name: 'Подписка на ' + +$this.data('duration') + ' месяцев',
category: 'Подписка',
brand: 'Lil.School',
quantity: 1,
price: +$this.data('price'),
}],
});
})
}
if(window.LIL_STORE.urlIs('giftCertificates')){
const $btns = $('.gift-certificates__buy-btn');
$btns.click(function () {
const $this = $(this);
window.gtag('event', 'begin_checkout', {
"items": [{
id: $this.data('gift-certificate'),
name: 'Подарочный сертификат на ' + +$this.data('price') + ' руб',
category: 'Подарочный сертификат',
brand: 'Lil.School',
quantity: 1,
price: +$this.data('price'),
}],
});
});
}
});
Loading…
Cancel
Save