Giftd_Cards - Version 2.0.0

Version Notes

Updated extension to use version 2 of Giftd JS endpoint

Download this release

Release Info

Developer Alexander Nevidimov
Extension Giftd_Cards
Version 2.0.0
Comparing to
See all releases


Code changes from version 1.0.0 to 2.0.0

app/code/community/Giftd/Cards/etc/system.xml CHANGED
@@ -143,198 +143,6 @@
143
  </sent_on_install>
144
  </fields>
145
  </api_settings>
146
- <panel_settings translate="label">
147
- <label>Giftd Panel Settings</label>
148
- <frontend_type>text</frontend_type>
149
- <sort_order>2</sort_order>
150
- <show_in_default>1</show_in_default>
151
- <show_in_website>1</show_in_website>
152
- <show_in_store>1</show_in_store>
153
- <comment></comment>
154
- <fields>
155
- <panel_is_active translate="label comment">
156
- <label>Отображать на сайте графический блок Giftd</label>
157
- <comment><![CDATA[
158
- <script type="text/javascript">
159
- function updatePanelSettings()
160
- {
161
- var is_active = giftd_cards_panel_settings_panel_is_active.value == 1;
162
- var display = is_active ? "table-row" : "none";
163
-
164
- giftd_cards_panel_settings.getElementsBySelector('tr').each(function(row){
165
- if(row != row_giftd_cards_panel_settings_panel_is_active)
166
- row.style.display = display;
167
-
168
- console.log(row);
169
- });
170
- }
171
-
172
- window.addEventListener('load',
173
- function() {
174
- giftd_cards_panel_settings_panel_is_active.onchange = updatePanelSettings;
175
- updatePanelSettings();
176
- }, false );
177
-
178
- </script>
179
- ]]></comment>
180
- <frontend_type>select</frontend_type>
181
- <source_model>adminhtml/system_config_source_yesno</source_model>
182
- <sort_order>1</sort_order>
183
- <show_in_default>1</show_in_default>
184
- <show_in_website>1</show_in_website>
185
- <show_in_store>1</show_in_store>
186
- </panel_is_active>
187
- <panel_position translate="label comment">
188
- <label>Местоположение вкладки Giftd</label>
189
- <comment><![CDATA[<img src="https://partner.giftd.ru/img/embedded_tab_screenshot.png" style="width: 267px;margin-top: 5px;">]]></comment>
190
- <frontend_type>select</frontend_type>
191
- <source_model>giftd_cards/system_config_source_tabposition</source_model>
192
- <sort_order>2</sort_order>
193
- <show_in_default>1</show_in_default>
194
- <show_in_website>1</show_in_website>
195
- <show_in_store>1</show_in_store>
196
- </panel_position>
197
- </fields>
198
- </panel_settings>
199
-
200
- <tab_settings translate="label">
201
- <label>Giftd Tab Settings</label>
202
- <frontend_type>text</frontend_type>
203
- <sort_order>3</sort_order>
204
- <show_in_default>1</show_in_default>
205
- <show_in_website>1</show_in_website>
206
- <show_in_store>1</show_in_store>
207
- <comment><![CDATA[]]></comment>
208
- <fields>
209
- <custom_code_is_active translate="label comment">
210
- <label>Настроить внешний вид графическиго блока Giftd</label>
211
- <comment><![CDATA[
212
- <script type="text/javascript">
213
- function updateTabSettings()
214
- {
215
- var is_active = giftd_cards_tab_settings_custom_code_is_active.value == 1;
216
- var display = is_active ? "table-row" : "none";
217
-
218
- giftd_cards_tab_settings.getElementsBySelector('tr').each(function(row){
219
- if(row != row_giftd_cards_tab_settings_custom_code_is_active)
220
- row.style.display = display;
221
- });
222
- }
223
-
224
- window.addEventListener('load',
225
- function() {
226
- giftd_cards_tab_settings_custom_code_is_active.onchange = updateTabSettings;
227
- updateTabSettings();
228
- }, false );
229
-
230
- </script>
231
- ]]></comment>
232
- <frontend_type>select</frontend_type>
233
- <source_model>adminhtml/system_config_source_yesno</source_model>
234
- <sort_order>1</sort_order>
235
- <show_in_default>1</show_in_default>
236
- <show_in_website>1</show_in_website>
237
- <show_in_store>1</show_in_store>
238
- </custom_code_is_active>
239
- <custom_code_info translate="label comment">
240
- <label></label>
241
- <comment><![CDATA[
242
- <p>
243
- Ниже вы можете отредактировать JS-код, который встраивается на ваш сайт.
244
- В этом коде есть ряд переменных, которые вы можете изменить — <b>цвета надписей, фоновые цвета и изображения</b>.
245
- </p>
246
- <p>
247
- Это образец кода, в котором всем возможным переменным заданы значения — эти значения приводят цвета и изобажения вкладки Giftd в состояние "по умолчанию":
248
- </p>
249
- <style>
250
- pre.giftd-code {
251
- background-color: ghostwhite;
252
- border: 1px solid silver;
253
- padding: 10px 20px;
254
- margin: 20px;
255
- max-width: 600px;
256
- overflow: scroll;;
257
-
258
- }
259
- .giftd-code .json-key {
260
- color: brown;
261
- }
262
- .giftd-code .json-value {
263
- color: navy;
264
- }
265
- .giftd-code .json-string {
266
- color: olive;
267
- }
268
- .giftd-code textarea {
269
- width: 600px;
270
- height: 365px;
271
- font-family: courier, monospace;
272
- font-size: 12px;
273
- line-height: 15px;
274
- white-space: nowrap;
275
- overflow: auto;
276
- }
277
-
278
- ul.bullets {
279
- list-style-type: disc;
280
- margin-left: 20px;
281
- }
282
- </style>
283
-
284
- <pre class="giftd-code"><code><span class="json-key">window.giftdOptions</span> = {
285
- <span class="json-key">pid</span>: <span class="json-string">"<?php echo GiftdHelper::GetOption('PARTNER_CODE') ?>"</span>,
286
- <span class="json-key">tab</span>: {
287
- <span class="json-key">enabled</span>: <span class="json-value">true</span>,
288
- <span class="json-key">position</span>: <span class="json-string">"left"</span>,
289
- <span class="json-key">panelBg</span>: {
290
- <span class="json-key">color</span>: <span class="json-string">"#008ede"</span>,
291
- <span class="json-key">image</span>: <span class="json-string">"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAwCAYAAADQMxCBAAAAVklEQVQIHW2OUQ6AMAhDCSfz2DvbhOJgDDSRr5aWF+gaMKY1rAClUiOGLXu7ylTfdopkMPWcocr7wgGhAOdRob69qEhRwu5dPdS7fjIrB9qVUPrD8+ABBOQ3zPy6HCkAAAAASUVORK5CYII="</span>
292
- },
293
- <span class="json-key">panelDecor</span>: {
294
- <span class="json-key">top</span>: <span class="json-string">"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADsAAAAxCAMAAABTYCHnAAAAwFBMVEUAAAAAAQEAAQEAAQEAAQEAAQEAAQEAAQEAAQEAAQEAAQEAAQHO3usAAQEAAQEAAQHkge3A1eaouca80N/D1+enusnZ5e+0w87V4+79/f3kge3O3uv5+vze6fLTfuj6+/y7ytbIcdC2z+LTd9vL3OrpmfHvt/T79Pz8+PzG2OjhgOzFddm9a8X67PvKfeTxvvW+0uP00Pfnje/lhe7spfLB1ubN3eu/1OWzxdSrwNHy9vn33fnzyvbZe+LtrfPWed+d0tzIAAAAGXRSTlMANSM5KRIDGgwHPDFmHxYvRGaqF0m22bXy9/6YcAAAAZxJREFUSMfl1l1XgjAcBnBQQEzASnsZYqkgmIn4Vim+9P2/Vftv1RyE4+yCm54bOJzzO3C2sT2KohjNpqk7Ddu2a3fbEU4vRT/x+k8uDsomve8oQA1Ka5p2uwMaICSwkMdfS2ib0FFayqZdbDE1HUzbLZVaj7dH3/fjQ5gsIx7fUKs7tqa1VHW3gPD2dTabHV3IOpzkLXyy1lbV+u4DkrXDqfudcfSXreHX1q+2b5CsJZRmc8G+QDL20z3LUmCfeUu/NhzTa7ENILydA0nw7YlgNlwWbwfM5uc3JjYutO+QAjsRvLcHKbAHuFkhGRut4CaUsiFZWpGMjdd0emXsBi4nJGP3ZKAiKUtW1R7J2ISOsZSFjCcXrU/inmU6x7Yg15wdkvwfKz9W4jmqeG2wNVn5v4A2bGuX/vcr3nPYXlflHiu/t4vPFGYlzzJmxWeo2ObPbrEVdwaL7yqcFXUVi+9InBV1JIvrZszmu1mS62YW3wkHAdhyndDrZrroAmy/lO1jynXgh0UA2BNYeN6hlmDdcRol4ui6aTYNA+AX7gz9bC873/cAAAAASUVORK5CYII="</span>,
295
- <span class="json-key">bottom</span>: <span class="json-string">"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKgAAAAwCAMAAACyoMGoAAAAe1BMVEUAAAA5s/sfou4sq/QQmOYZnusIk+MIk+MTmug4svo+tv0HkuIlpvAWnOk1sPgLlOQZnusJk+McoOwwrfUyrvcdoOwTmug3sfkBjt8doe0ZnusUm+gEkOERmOcLleQ1sPg6tPtAuP4Hk+IOl+Uyrvctq/QlpvA+tvwbn+w2IVSMAAAAGHRSTlMAH8bFWWRKxjYlVufFj1bnjy6PzO7yx1h3FiyaAAABl0lEQVRYw+2R21KDQBBENwYjq0bFaJVKvCfR//9CQ+h5sKlJF1CWS8KBl+6ZhVMQPPJYw/07iJMa7lU+B2qPCR5RiMIzJiv6BUyUe5VNVO0xPUVjuqJvwES5V9lE1R7TWvQVmCj3Kl8BtcccrujdqoZFV0BlE1V7DMaaxbRisfBeMAVB0FaMsoZF1qCtKJ9bE948AdHN7gJIPUQvgeUN8OYMn+PM8PzwRE+A5UfgzRk+x5nheQqim+adpmi3L3oKgsM9HcyB9+Bb4AmovrPoN2BRnrMo95a9nhm2aLZH9AmwqDe/AdxbFj3N+YsORjTbK1puL1eU53Ow7X71yGWjR8FX619fAhblOYtyb9nrGe/Xz5MTzUDoSQlUVudHUeMZqOyeF4yiyYp+ApXd84LjE30BKrvnBcHjDFieFBVxogSzWQ0/h/evQSCEoBaNRZHnW1MlOvtv0cqzMk1fNN/REP0ASpT3L0DjeURX0XwoooP5ogMQLSBKLIES5X1PdEmEv4HF9YtRS0bR5EUfAGfD2ZeMoqNo6qI/fvJUFNWbkq8AAAAASUVORK5CYII="</span>
296
- },
297
- <span class="json-key">panelTextColor</span>: <span class="json-string">"#fff"</span>,
298
- <span class="json-key">panelDescriptionColor</span>: <span class="json-string">"#B0FFA5"</span>,
299
- <span class="json-key">panelDescriptionIcon</span>: <span class="json-string">"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAATCAMAAACuuX39AAAAwFBMVEUAAACw/6Ww/6UAAQGn8pwAAQGT1ooFCAUAAQEAAQGv/aQAAQGw/6UAAQE0TTGq9qCw/6Ww/6UOFQ6Q0Ieu/KOw/6VfiVlwo2k2TzMAAQGV2Iyw/6Ww/6WR0oiw/6Wq96Ct+6Kd45Oi65ig6Jap9Z+Gwn6w/6UAAQGw/6Ww/6Wi6pew/6WIxYCFwHxKbEav/aSw/6Wm8Juw/6Wq9p9jj12w/6VMb0iq96Cw/6Ww/6Wm8Zyj7JmW2o2w/6Wu/KOw/6XJxdjGAAAAP3RSTlMAEFEKBi2vHyUQQzzWBUzo+wo5k6dcamsaAlZ9squq+n2apNLelzsbMZ23FomVX41zvmXXROJdw/Ul0ca3//4rIEY4AAAAmUlEQVQY003O5Q7DMAwE4BSTFLXimJmZ3fd/rNXT1vj+3SfrZEZS01ONdu0CcH8Q6EOZhMAQ4an6fIwQ/+tqAfGkV3R4ud1KUnMPy4Bz1xWMmR5enjLL/906gIlktdX8gqnG6yHCTr3YCOzRZnuAYyW+sLhh5aHnTLttvWIZrQGjhM1shBtTGSC8CJyLEnICxtV+Z5JREUKyD26+FQN53O4ZAAAAAElFTkSuQmCC"</span>,
300
- <span class="json-key">contentBgImage</span>: <span class="json-string">"https://static.giftd.ru/embedded/content_bg.png?1100409742"</span>,
301
- <span class="json-key">contentColor</span>: <span class="json-string">"#5d869e"</span>,
302
- <span class="json-key">contentTitleColor</span>: <span class="json-string">"#3496CE"</span>
303
- }
304
- }</code></pre>
305
- <p>
306
- На картинке показано соответствие между переменными и элементами встраиваемого решения:
307
- </p>
308
- <img style="width: 600px;" src="https://partner-static.giftd.ru/img/embedded_customization.png">
309
- <p>Нюансы кастомизации встраиваемого решения:</p>
310
- <ul class="bullets">
311
- <li>В образце кода все переменные заполнены значениями, равными значениям по умолчанию;</li>
312
- <li>Свойство <code>position</code> может принимать одно из трех значений: <code>left</code>, <code>right</code> или <code>bottom</code>.</li>
313
- <li>Не меняйте свойство <code>pid</code>;</li>
314
- <li>Мы советуем удалить из кода переменные, которые вы не будете кастомизировать — будут использованы значения по умолчанию;</li>
315
- <li>Не забудьте раскомментировать строчку с переменной, если меняете ее;</li>
316
- <li>Картинки можно вставлять как в виде Data URI, так и в виде обычного URL — в образце выше есть и тот, и другой вариант.</li>
317
- <li>Для задания фона панели вы можете использовать как свойство <code>panelBg.color</code>, так и <code>panelBg.image</code>. <br><small><i>Рекомендуем использовать обе переменных одновременно — на тот случай, если фоновая картинка не загрузится.</i></small></li>
318
-
319
- </ul>
320
- ]]></comment>
321
- <frontend_type>label</frontend_type>
322
- <sort_order>2</sort_order>
323
- <show_in_default>1</show_in_default>
324
- <show_in_website>1</show_in_website>
325
- <show_in_store>1</show_in_store>
326
- </custom_code_info>
327
- <tab_js_code translate="label comment">
328
- <label>JS-код с настройкаи графического блока Giftd</label>
329
- <comment></comment>
330
- <frontend_type>textarea</frontend_type>
331
- <sort_order>12</sort_order>
332
- <show_in_default>1</show_in_default>
333
- <show_in_website>1</show_in_website>
334
- <show_in_store>1</show_in_store>
335
- </tab_js_code>
336
- </fields>
337
- </tab_settings>
338
  </groups>
339
  </giftd_cards>
340
  </sections>
143
  </sent_on_install>
144
  </fields>
145
  </api_settings>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  </groups>
147
  </giftd_cards>
148
  </sections>
app/design/frontend/base/default/template/giftd/panel.phtml CHANGED
@@ -1,30 +1,16 @@
1
  <?php
2
- $show_panel = Mage::getStoreConfig('giftd_cards/panel_settings/panel_is_active',Mage::app()->getStore());
3
- $use_custom_js = Mage::getStoreConfig('giftd_cards/tab_settings/custom_code_is_active',Mage::app()->getStore());
4
- $custom_js = Mage::getStoreConfig('giftd_cards/tab_settings/tab_js_code',Mage::app()->getStore());
5
-
6
- $panel_options =
7
- 'window.giftdOptions = {'.
8
- 'pid: "'.Mage::getStoreConfig('giftd_cards/api_settings/partner_token',Mage::app()->getStore()).'",'.
9
- 'tab: {'.
10
- 'enabled: '.(Mage::getStoreConfig('giftd_cards/panel_settings/panel_is_active',Mage::app()->getStore()) ? 'true' : 'false').','.
11
- 'position: "'.(Mage::getStoreConfig('giftd_cards/panel_settings/panel_position',Mage::app()->getStore()) ?: 'left').'"'.
12
- '}'.
13
- '};';
14
-
15
- if ($show_panel && $use_custom_js && $custom_js)
16
- $panel_options = $custom_js . ';';
17
-
18
- ?>
19
 
 
 
20
  <script>
21
- <?=$panel_options?>
22
- (function(){
23
- var s = (window.giftdOptions.tab && window.giftdOptions.tab.enabled) ? "giftd.js" : "giftd_no_tab.js";
24
- var el = document.createElement("script");
25
- el.id = "giftd-script";
26
- el.async = true;
27
- el.src = "https://static.giftd.ru/embedded/" + s;
28
  document.getElementsByTagName("head")[0].appendChild(el);
29
- })();
30
- </script>';
 
 
 
 
1
  <?php
2
+ $pid = Mage::getStoreConfig('giftd_cards/api_settings/partner_token',Mage::app()->getStore());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ if ($pid) {
5
+ ?>
6
  <script>
7
+ setTimeout(function(){
8
+ var el = document.createElement("script"); el.id = "giftd-script"; el.async = true;
9
+ el.src = "https://giftd.ru/widgets/js/v2?pid=<?php echo $pid ?>";
 
 
 
 
10
  document.getElementsByTagName("head")[0].appendChild(el);
11
+ }, 0);
12
+
13
+ </script>
14
+ <?php
15
+ }
16
+ ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Giftd_Cards</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
@@ -18,11 +18,11 @@ The extension has three primary features: &#xD;
18
  &#x2014; Add Giftd tab to your website, allowing users to send gift cards;&#xD;
19
  &#xD;
20
  &#x2014; Accept gift cards using an existing discount code field.</description>
21
- <notes>First public release.</notes>
22
  <authors><author><name>Alexander Nevidimov</name><user>nevidimov</user><email>nevidimov@giftd.ru</email></author></authors>
23
- <date>2014-10-10</date>
24
- <time>19:23:02</time>
25
- <contents><target name="magecommunity"><dir><dir name="Giftd"><dir name="Cards"><dir name="Helper"><file name="Data.php" hash="a07c9c0bb8c274a37f245be65941df59"/></dir><dir name="Model"><file name="GiftdClient.php" hash="f32c25a85dd0efd8b60b5771f8320e99"/><file name="Observer.php" hash="c2c1de2ff722335c32e05ce2f7832365"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Tabposition.php" hash="cc645c33159bf2449acf58bba336075d"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="0d6bbce8bbf0f0c1e14920a00e953dde"/><file name="system.xml" hash="70e7e19dc34ff6e38a3ff8f79300c781"/></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="giftd_panel.xml" hash="3d9ad4a36cdeab1cfb4bd7cc5dea5080"/></dir><dir name="template"><dir name="giftd"><file name="panel.phtml" hash="a725ec457409fc71b19243f930c1eede"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="etc"><dir name="modules"><file name="Giftd_Cards.xml" hash=""/></dir></dir></dir></target></contents>
26
  <compatible/>
27
  <dependencies><required><php><min>5.0.0</min><max>5.9.9</max></php></required></dependencies>
28
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Giftd_Cards</name>
4
+ <version>2.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
18
  &#x2014; Add Giftd tab to your website, allowing users to send gift cards;&#xD;
19
  &#xD;
20
  &#x2014; Accept gift cards using an existing discount code field.</description>
21
+ <notes>Updated extension to use version 2 of Giftd JS endpoint</notes>
22
  <authors><author><name>Alexander Nevidimov</name><user>nevidimov</user><email>nevidimov@giftd.ru</email></author></authors>
23
+ <date>2015-02-22</date>
24
+ <time>17:02:47</time>
25
+ <contents><target name="magecommunity"><dir><dir name="Giftd"><dir name="Cards"><dir name="Helper"><file name="Data.php" hash="a07c9c0bb8c274a37f245be65941df59"/></dir><dir name="Model"><file name="GiftdClient.php" hash="f32c25a85dd0efd8b60b5771f8320e99"/><file name="Observer.php" hash="c2c1de2ff722335c32e05ce2f7832365"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Tabposition.php" hash="cc645c33159bf2449acf58bba336075d"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="0d6bbce8bbf0f0c1e14920a00e953dde"/><file name="system.xml" hash="deea000c2260668f6c9eabf6e4d745da"/></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="giftd_panel.xml" hash="3d9ad4a36cdeab1cfb4bd7cc5dea5080"/></dir><dir name="template"><dir name="giftd"><file name="panel.phtml" hash="4f19a251f7dd7b017aba274356bc7655"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="etc"><dir name="modules"><file name="Giftd_Cards.xml" hash=""/></dir></dir></dir></target></contents>
26
  <compatible/>
27
  <dependencies><required><php><min>5.0.0</min><max>5.9.9</max></php></required></dependencies>
28
  </package>