SHOW:
|
|
- or go back to the newest paste.
1 | https://redmine.oml.ru/issues/47081 | |
2 | http://3444844.pre2.test.m/ | |
3 | ||
4 | ||
5 | Шаблоны: | |
6 | shop2-kind-available-customer-email-subject.tpl | |
7 | shop2-kind-available-customer-email-message.tpl | |
8 | ||
9 | ||
10 | Шаблон: shop2-kind-available-customer-email-message.tpl | |
11 | Название шаблона: Настройка уведомлений. KIND_AVAILABLE. Покупатель. email. message | |
12 | ||
13 | Содержимое шаблона: (( | |
14 | Уважаемый покупатель, | |
15 | Вы интересовались данным товаром ранее и мы рады сообщить Вам о его поступлении в продажу. | |
16 | {assign var="kind_currency_id" value=$kind.currency_id} | |
17 | {assign var="kind_currency" value=$shop2.currency.$kind_currency_id.currency_shortname} | |
18 | {if !$shop2.my.hide_article && $order_form_settings.article}({if $kind.article}{$kind.article}{else}артикул не задан{/if}) {/if}{$kind.name} -- {$kind.price|price_convert|regex_replace:"/ /":" "} {$kind_currency} {"\n"} | |
19 | Страница товара: {$site.protocol}://{$site.domain_mask}{get_seo_url uri_prefix=$shop2.uri mode="product" alias=$kind.alias}{"\n"} | |
20 | )) | |
21 | ||
22 | ||
23 | ||
24 | Шаблоны: shop2.v2-amount-btn.tpl -- Магазин 2.v2. Количество (кнопки) | |
25 | Добавил в условие это {if $pr.buy_mode == 1 || $pr.buy_mode == 5} | |
26 | ||
27 | shop2.v2-buy-btn.tpl Магазин 2.v2. Купить (кнопка) | |
28 | Добавил кнопку https://prnt.sc/4EKzsFotBpFH при условии $pr.buy_mode == 5} | |
29 | ||
30 | CSS к кнопка и форме https://pastebin.com/VTApRmgB | |
31 | ||
32 | В Js | |
33 | shop2.queue.addToCart = function() { | |
34 | $(document).on('click', '.shop2-product-btn:not(.preorder-btn-js)' | |
35 | добавил :not(.preorder-btn-js) | |
36 | ||
37 | И | |
38 | ||
39 | shop2.queue.preOrder = function() { | |
40 | ||
41 | var sentAjax_preorder = function(data, callback){ | |
42 | $.ajax({ | |
43 | url: '/my/s3/xapi/public/?method=shop2/addKindEmailNotification', | |
44 | method: 'post', | |
45 | xhrFields: { | |
46 | withCredentials: true | |
47 | }, | |
48 | data: data, | |
49 | success: function(result) { | |
50 | callback(result); | |
51 | } | |
52 | }); | |
53 | }; | |
54 | ||
55 | var object_preorder = {}; | |
56 | $(document).on('click', '.preorder-btn-js', function(e) { | |
57 | e.preventDefault(); | |
58 | object_preorder.data = {}; | |
59 | ||
60 | object_preorder.jQbtn = $(this); | |
61 | object_preorder.data.kind_id = object_preorder.jQbtn.data('product-kind_id'); | |
62 | object_preorder.data.email = object_preorder.jQbtn.data('user-email') || 0; | |
63 | ||
64 | if( object_preorder.data.email ){ | |
65 | var temp_email = ` | |
66 | <div class="preorder-field preorder-email"> | |
67 | <span class="preorder-email_text"> | |
68 | ${shop2.my.preorder_email_text||'Данный email указан при регистрации.'} | |
69 | </span> | |
70 | <div class="preorder-email-input"> | |
71 | <div class="preorder-field-title">E-mail: <span class="preorder-mark">*</span></div> | |
72 | <div class="preorder-field-value"> | |
73 | <input type="text" name="email" required value="${object_preorder.data.email}"> | |
74 | </div> | |
75 | </div> | |
76 | </div> | |
77 | `; | |
78 | ||
79 | }else { | |
80 | var temp_email = ` | |
81 | <div class="preorder-field preorder-email"> | |
82 | <div class="preorder-email-input"> | |
83 | <div class="preorder-field-title">E-mail: <span class="preorder-mark">*</span></div> | |
84 | <div class="preorder-field-value"> | |
85 | <input type="text" name="email" required value=""> | |
86 | </div> | |
87 | </div> | |
88 | </div> | |
89 | `; | |
90 | } | |
91 | ||
92 | var temp_html = ` | |
93 | <div class="preorder-form-wrap preorder-block"> | |
94 | <form class="preorder_body" action="/my/s3/xapi/public/?method=shop2/addKindEmailNotification" method="get"> | |
95 | <div class="preorder-title preorder-title"> | |
96 | ${shop2.my.preorder_form_title||'Узнать о поступлении'} | |
97 | </div> | |
98 | <div class="preorder_text preorder-field type-html"> | |
99 | ${shop2.my.preorder_form_text||'Оставьте почту и мы напишем вам, когда товар появится в наличии.'} | |
100 | </div> | |
101 | ${temp_email} | |
102 | <input type="hidden" name="kind_id" value="${object_preorder.data.kind_id}"> | |
103 | ||
104 | <div class="preorder-field preorder-field-button preorder_send"> | |
105 | <button type="submit" class="tpl-form-button">${shop2.my.preorder_form_submitt||'Отправить'}</button> | |
106 | </div> | |
107 | ||
108 | </form> | |
109 | <div class="block-recaptcha"></div> | |
110 | </div> | |
111 | `; | |
112 | ||
113 | shop2.alert( temp_html, 'close', 'preorder-alert' ); | |
114 | }); | |
115 | ||
116 | $(document).on('submit', '.block-recaptcha form', function(e) { | |
117 | e.preventDefault(); | |
118 | ||
119 | var serializeArray = $(this).serializeArray(); | |
120 | ||
121 | for(let i = 0; i < serializeArray.length; i++){ | |
122 | if( serializeArray[i]['name'] == '_sitekey' ){ object_preorder.data['_sitekey'] = serializeArray[i]['value'];} | |
123 | if( serializeArray[i]['name'] == 'g-recaptcha-response' ){ object_preorder.data['g-recaptcha-response'] = serializeArray[i]['value'];} | |
124 | } | |
125 | ||
126 | sentAjax_preorder( object_preorder.data, (data)=>{ | |
127 | console.log(data); | |
128 | object_preorder.jQbtn.get(0).setAttribute('disabled', 'disabled'); | |
129 | ||
130 | $('.preorder-form-wrap').html(` | |
131 | <div class="preorder_success"> | |
132 | ${shop2.my.preorder_form_success||'Спасибо!'} | |
133 | </div> | |
134 | `); | |
135 | }) | |
136 | ||
137 | }); | |
138 | ||
139 | $(document).on('submit', '.preorder_body', function(e) { | |
140 | e.preventDefault(); | |
141 | var $form = $(this); | |
142 | ||
143 | object_preorder.data.email = this.email.value; | |
144 | const _regexEmeil = /^[\w-\.]+@[\w-]+\.[a-z]{2,4}$/i; | |
145 | ||
146 | let valid = _regexEmeil.test(object_preorder.data.email); | |
147 | ||
148 | if (valid){ | |
149 | $.get( '/my/s3/xapi/public/?method=shop2/addKindEmailNotification', function( data ) { | |
150 | ||
151 | const _regexBody = new RegExp(/<body[^>]*>(.*?)<\/body>/ig); | |
152 | ||
153 | let body = data.result.html.match( _regexBody ); | |
154 | ||
155 | ||
156 | $form.parent('.preorder-block').find('.block-recaptcha').html( body ); | |
157 | }); | |
158 | }else { | |
159 | ||
160 | if( !$form.find('.preorder-email').hasClass('field-error') ) | |
161 | $form | |
162 | .find('.preorder-email') | |
163 | .addClass('field-error') | |
164 | .find('.preorder-email-input .preorder-field-value') | |
165 | .before(`<div class="error-message">Неверный формат адреса электронной почты</div>`); | |
166 | } | |
167 | ||
168 | }); | |
169 | }; |