17 <?php
$block->getConfigJson() ?>
18 <fieldset
class=
"admin__fieldset downloadable-form" data-
ui-
id=
"downloadable-links">
19 <legend
class=
"admin__legend"><span><?=
__(
'Links') ?></span></legend><br>
20 <p
class=
"note"><?=
__(
'Add links to your product files here.') ?></p>
21 <div
class=
"admin__field" <?= !
$block->isSingleStoreMode() ?
' data-config-scope="' .
__(
'[STORE VIEW]') .
'"' :
'' ?>>
22 <label
class=
"admin__field-label" for=
"downloadable_links_title"><span><?=
__(
'Title') ?></span></label>
23 <div
class=
"admin__field-control">
24 <input type=
"text" class=
"admin__control-text" id=
"downloadable_links_title" name=
"product[links_title]" value=
"<?= $block->escapeHtml($block->getLinksTitle()) ?>" <?= (
$_product->getStoreId() &&
$block->getUsedDefault()) ?
'disabled="disabled"' :
'' ?>>
26 <div
class=
"admin__field admin__field-option">
27 <input
id=
"link_title_default" class=
"admin__control-checkbox" type=
"checkbox" name=
"use_default[]" value=
"links_title" onclick=
"toggleValueElements(this, this.parentNode.parentNode)" <?=
$block->getUsedDefault() ?
'checked="checked"' :
'' ?> />
28 <label
class=
"admin__field-label" for=
"link_title_default"><span><?=
__(
'Use Default Value') ?></span></label>
34 <div
class=
"admin__field" <?= !
$block->isSingleStoreMode() ?
' data-config-scope="' .
__(
'[GLOBAL]') .
'"' :
'' ?>>
35 <label
class=
"admin__field-label" for=
"downloadable_link_purchase_type"><span><?=
__(
'Links can be purchased separately') ?></span></label>
36 <div
class=
"admin__field-control">
37 <div
class=
"admin__field-control link-switcher" data-role=
"link-switcher">
38 <div
class=
"admin__field-control-group">
39 <div
class=
"admin__field admin__field-option">
40 <input type=
"radio" name=
"product[links_purchased_separately]" value=
"1" 41 class=
"admin__control-radio" 43 <?php
if(
$block->isProductLinksCanBePurchasedSeparately()): ?>
47 <label
class=
"admin__field-label" for=
"link-switcher1">
51 <div
class=
"admin__field admin__field-option">
52 <input type=
"radio" name=
"product[links_purchased_separately]" value=
"0" 53 class=
"admin__control-radio" 55 <?php
if(!
$block->isProductLinksCanBePurchasedSeparately()): ?>
59 <label
class=
"admin__field-label" for=
"link-switcher0">
67 <div
class=
"admin__field admin__field-wide">
68 <div
class=
"admin__field-control">
69 <div
class=
"admin__control-table-wrapper">
70 <table
class=
"admin__control-table">
73 <th
class=
"col-sort"><span><?=
__(
'Sort Order') ?></span></th>
74 <th
class=
"col-title _required"><span><?=
__(
'Title') ?></span></th>
75 <?php
if (
$block->getCanReadPrice() !==
false) : ?>
76 <th
class=
"col-price"><span><?=
__(
'Price') ?></span></th>
78 <th
class=
"col-file"><span><?=
__(
'Attach File or Enter Link') ?></span></th>
79 <th
class=
"col-sample"><span><?=
__(
'Sample') ?></span></th>
80 <th
class=
"col-share"><span><?=
__(
'Shareable') ?></span></th>
81 <th
class=
"col-limit"><span><?=
__(
'Max. Downloads') ?></span></th>
82 <th
class=
"col-actions">&
nbsp;</th>
87 <td
class=
"col-actions-add" colspan=
"8"><?=
$block->getAddButtonHtml() ?></td>
90 <tbody
id=
"link_items_body">
94 <div
class=
"admin__field-note">
95 <span><?=
__(
'Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.') ?></span>
105 'jquery/file-uploader',
109 ],
function(
jQuery, registry, mageTemplate){
110 registry.get(
'downloadable',
function (Downloadable) {
111 var linkTemplate =
'<tr>'+
112 '<td class="col-sort" data-role="draggable-handle"><input data-container="link-order" type="hidden" ' +
113 'name="downloadable[link][<%- ' +
115 ' %>][sort_order]" ' +
116 'value="<%- data.sort_order %>" class="input-text admin__control-text sort" />' +
117 '<span class="draggable-handle" title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Sort Variations
')) ?>"></span>' +
119 '<td class="col-title">'+
120 '<input type="hidden" class="__delete__" name="downloadable[link][<%- data.id %>][is_delete]" value="" />'+
121 '<input type="hidden" name="downloadable[link][<%- data.id %>][link_id]" value="<%- data.link_id %>" />'+
122 '<input type="text" class="required-entry input-text admin__control-text" name="downloadable[link][<%- data.id %>][title]" value="<%- data.title %>" />'+
124 '<div class="admin__field admin__field-option">'+
125 '<input type="checkbox" id="downloadable_link_<%- data.id %>_title" name="downloadable[link][<%- data.id %>][use_default_title]" value="1" class="admin__control-checkbox" />'+
126 '<label for="downloadable_link_<%- data.id %>_title" class="admin__field-label"><span><?= /* @escapeNotVerified */ __('Use Default Value
') ?></span></label>'+
129 <?php
if (
$block->getCanReadPrice() ==
false) : ?>
130 '<input type="hidden" id="downloadable_link_<%- data.id %>_price_value" class="link-prices" name="downloadable[link][<%- data.id %>][price]" value="0" />' +
131 <?php
if (
$_product->getStoreId() &&
$block->getIsPriceWebsiteScope()) : ?>
132 '<input type="hidden" id="downloadable_link_<%- data.id %>_price" name="downloadable[link][<%- data.id %>][use_default_price]" value="1" />' +
136 <?php
if (
$block->getCanReadPrice() !==
false) : ?>
137 '<td class="col-price">'+
138 '<div class="admin__control-addon">' +
139 '<input type="text" id="downloadable_link_<%- data.id %>_price_value" class="input-text admin__control-text validate-number link-prices<?php if ($block->getCanEditPrice() === false) : ?> disabled<?php endif; ?>" name="downloadable[link][<%- data.id %>][price]" value="<%- data.price %>"<?php if ($block->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> /> ' +
140 '<label class="admin__addon-prefix"><span><?= $block->escapeHtml($block->getBaseCurrencySymbol($_product->getStoreId())) ?></span></label>' +
142 <?php
if (
$_product->getStoreId() &&
$block->getIsPriceWebsiteScope()) : ?>
143 '<div class="admin__field admin__field-option">'+
144 '<input type="checkbox" id="downloadable_link_<%- data.id %>_price" name="downloadable[link][<%- data.id %>][use_default_price]" value="1"<?php if ($block->getCanEditPrice() === false) : ?> disabled="disabled"<?php endif; ?> class="admin__control-checkbox" />'+
145 '<label for="downloadable_link_<%- data.id %>_price" class="admin__field-label"><span><?= /* @escapeNotVerified */ __('Use Default Value
') ?></span></label>' +
150 '<td class="col-file">'+
151 '<div class="admin__field admin__field-option">'+
152 '<input type="radio" class="admin__control-radio validate-one-required-by-name" id="downloadable_link_<%- data.id %>_file_type" name="downloadable[link][<%- data.id %>][type]" value="file"<%- data.file_checked %> />' +
153 '<label for="downloadable_link_<%- data.id %>_file_type" class="admin__field-label"><span><?= /* @escapeNotVerified */ __('File
') ?></span></label>'+
154 '<input type="hidden" class="validate-downloadable-file" id="downloadable_link_<%- data.id %>_file_save" name="downloadable[link][<%- data.id %>][file]" value="<%- data.file_save %>" />'+
156 '<div id="downloadable_link_<%- data.id %>_file" class="admin__field-uploader">'+
157 '<div id="downloadable_link_<%- data.id %>_file-old" class="file-row-info"></div>'+
158 '<div id="downloadable_link_<%- data.id %>_file-new" class="file-row-info new-file"></div>'+
159 '<div class="fileinput-button form-buttons">'+
160 '<span><?= /* @escapeNotVerified */ __('Browse Files...
') ?></span>' +
161 '<input id="downloadable_link_<%- data.id %>_file" type="file" name="<?= $block->escapeHtml($block->getFileFieldName('links
')) ?>">' +
163 'linksUploader("#downloadable_link_<%- data.id %>_file", "<?= $block->escapeUrl($block->getUploadUrl('links
')) ?>"); ' +
168 '<div class="admin__field admin__field-option admin__field-file-url">'+
169 '<input type="radio" class="admin__control-radio validate-one-required-by-name" id="downloadable_link_<%- data.id %>_url_type" name="downloadable[link][<%- data.id %>][type]" value="url"<%- data.url_checked %> />' +
170 '<label for="downloadable_link_<%- data.id %>_url_type" class="admin__field-label"><span><?= /* @escapeNotVerified */ __('URL
') ?></span></label>' +
171 '<input type="text" class="validate-downloadable-url validate-url admin__control-text" name="downloadable[link][<%- data.id %>][link_url]" value="<%- data.link_url %>" placeholder="<?= /* @escapeNotVerified */ __('URL
') ?>" />'+
174 '<span id="downloadable_link_<%- data.id %>_link_container"></span>'+
177 '<td class="col-sample">'+
178 '<div class="admin__field admin__field-option">'+
179 '<input type="radio" class="admin__control-radio" id="downloadable_link_<%- data.id %>_sample_file_type" name="downloadable[link][<%- data.id %>][sample][type]" value="file"<%- data.sample_file_checked %> />' +
180 '<label for="downloadable_link_<%- data.id %>_sample_file_type" class="admin__field-label"><span><?= /* @escapeNotVerified */ __('File
') ?>:</span></label>'+
181 '<input type="hidden" id="downloadable_link_<%- data.id %>_sample_file_save" name="downloadable[link][<%- data.id %>][sample][file]" value="<%- data.sample_file_save %>" class="validate-downloadable-file"/>'+
182 '<div id="downloadable_link_<%- data.id %>_sample_file" class="admin__field-uploader">'+
183 '<div id="downloadable_link_<%- data.id %>_sample_file-old" class="file-row-info"></div>'+
184 '<div id="downloadable_link_<%- data.id %>_sample_file-new" class="file-row-info new-file"></div>'+
185 '<div class="fileinput-button form-buttons">'+
186 '<span><?= /* @escapeNotVerified */ __('Browse Files...
') ?></span>' +
187 '<input id="downloadable_link_<%- data.id %>_sample_file" type="file" name="<?= $block->escapeHtml($block->getFileFieldName('link_samples
'), '"') ?>">
' + 189 'linksUploader(
"#downloadable_link_<%- data.id %>_sample_file",
"<?= $block->escapeUrl($block->getUploadUrl('link_samples')) ?>");
' + 195 '<div
class=
"admin__field admin__field-option admin__field-file-url">
'+ 196 '<input type=
"radio" class=
"admin__control-radio validate-one-required-by-name" id=
"downloadable_link_<%- data.id %>_sample_url_type" name=
"downloadable[link][<%- data.id %>][sample][type]" value=
"url"<%- data.sample_url_checked %> />
' + 197 '<label
for=
"downloadable_link_<%- data.id %>_sample_url_type" class=
"admin__field-label"><span><?=
__(
'URL') ?></span></label>
'+ 198 '<input type=
"text" class=
"validate-downloadable-url validate-url admin__control-text" name=
"downloadable[link][<%- data.id %>][sample][url]" value=
"<%- data.sample_url %>" placeholder=
"<?= /* @escapeNotVerified */ __('URL') ?>" />
'+ 201 '<span
id=
"downloadable_link_<%- data.id %>_sample_container"></span>
'+ 204 '<td
class=
"col-share">
'+ 205 '<select
id=
"downloadable_link _<%- data.id %>_shareable" class=
"admin__control-select" name=
"downloadable[link][<%- data.id %>][is_shareable]">
'+ 206 '<option
value=
"1"><?=
__(
'Yes') ?></option>
'+ 207 '<option
value=
"0"><?=
__(
'No') ?></option>
'+ 208 '<option
value=
"2" selected=
"selected"><?=
__(
'Use config') ?></option>
'+ 211 '<td
class=
"col-limit">
' + 212 '<input type=
"text" id=
"downloadable_link_<%- data.id %>_downloads" name=
"downloadable[link][<%- data.id %>][number_of_downloads]" class=
"input-text validate-zero-or-greater admin__control-text downloads" value=
"<%- data.number_of_downloads %>" />
'+ 213 '<div
class=
"admin__field admin__field-option">
' + 214 '<input type=
"checkbox" class=
"admin__control-checkbox" id=
"downloadable_link_<%- data.id %>_is_unlimited" name=
"downloadable[link][<%- data.id %>][is_unlimited]" value=
"1" <%- data.is_unlimited %> />
' + 215 '<label
for=
"downloadable_link_<%- data.id %>_is_unlimited" class=
"admin__field-label"><span><?=
__(
'Unlimited') ?></span></label>
' + 218 '<td
class=
"col-action">
'+ 219 '<button
id=
"downloadable_link_<%- data.id %>_delete_button" type=
"button" class=
"action-delete" title=
"<?= /* @escapeNotVerified */ $block->escapeHtml(__('Delete')) ?>"><span><?=
__(
'Delete') ?></span></button>
'+ 224 tbody : $('link_items_body
'), 225 templateText : linkTemplate, 227 add : function(data) { 228 alertAlreadyDisplayed = false; 229 this.template = mageTemplate(this.templateText); 234 data.link_type = 'file
'; 235 data.sample_type = 'none
'; 236 data.number_of_downloads = '<?=
$block->getConfigMaxDownloads() ?>
'; 237 data.sort_order = this.itemCount + 1; 240 data.id = this.itemCount; 242 if (data.link_type == 'url
') { 243 data.url_checked = ' checked=
"checked"'; 244 } else if (data.link_type == 'file
') { 245 data.file_checked = ' checked=
"checked"'; 247 if (data.sample_type == 'url
') { 248 data.sample_url_checked = ' checked=
"checked"'; 249 } else if (data.sample_type == 'file
') { 250 data.sample_file_checked = ' checked=
"checked"'; 253 var rowElement = Element.insert(this.tbody, { 254 'bottom
': this.template({data: data}) 257 scopeTitle = $('downloadable_link_
'+data.id+'_title
'); 259 Event.observe(scopeTitle, 'click
', function(event){ 260 scopeElm = $(Event.findElement(event, 'input
')); 261 titleField = scopeElm.up(0).down('input[type=
"text"]
'); 262 if (scopeElm.checked == true) { 263 titleField.disabled = true; 265 titleField.disabled = false; 269 if (!data.store_title && scopeTitle) { 270 scopeTitle.up(0).down('input[type=
"text"]
').disabled = true; 271 scopeTitle.checked = true; 274 scopePrice = $('downloadable_link_
'+data.id+'_price
'); 276 Event.observe(scopePrice, 'click
', function(event){ 277 scopeElm = $(Event.findElement(event, 'input
')); 278 priceField = scopeElm.up(0).down('input[type=
"text"]
'); 279 if (scopeElm.checked == true) { 280 priceField.disabled = true; 282 priceField.disabled = false; 286 if (!data.website_price && scopePrice) { 287 scopePrice.up(0).down('input[type=
"text"]
').disabled = true; 288 scopePrice.checked = true; 290 downloadsElm = $('downloadable_link_
'+data.id+'_downloads
'); 291 isUnlimitedElm = $('downloadable_link_
'+data.id+'_is_unlimited
'); 292 if (data.is_unlimited) { 293 downloadsElm.disabled = true; 295 Event.observe(isUnlimitedElm, 'click
', function(event){ 296 elm = Event.element(event); 297 elm.up('td
').down('input[type=
"text"].downloads
').disabled = elm.checked; 300 if (data.is_shareable) { 301 options = $('downloadable_link _
'+data.id+'_shareable
').options; 302 for (var i=0; i < options.length; i++) { 303 if (options[i].value == data.is_shareable) { 304 options[i].selected = true; 309 sampleUrl = $('downloadable_link_
'+data.id+'_sample_url_type
'); 310 linkUrl = $('downloadable_link_
'+data.id+'_url_type
'); 312 if (!data.file_save) { 315 if (!data.sample_file_save) { 316 data.sample_file_save = []; 320 new Downloadable.FileUploader( 322 'linkssample_
'+data.id, 324 'downloadable[link][
'+data.id+'][sample]
', 325 data.sample_file_save, 326 'downloadable_link_
'+data.id+'_sample_file
', 327 <?= /* @escapeNotVerified */ $block->getConfigJson('link_samples
') ?> 330 new Downloadable.FileUploader( 334 'downloadable[link][
'+data.id+']
', 336 'downloadable_link_
'+data.id+'_file
', 337 <?= /* @escapeNotVerified */ $block->getConfigJson() ?> 340 linkFile = $('downloadable_link_
'+data.id+'_file_type
'); 341 linkFile.advaiceContainer = 'downloadable_link_
'+data.id+'_link_container
'; 342 linkUrl.advaiceContainer = 'downloadable_link_
'+data.id+'_link_container
'; 343 $('downloadable_link_
'+data.id+'_file_save
').advaiceContainer = 'downloadable_link_
'+data.id+'_link_container
'; 345 sampleFile = $('downloadable_link_
'+data.id+'_sample_file_type
'); 348 this.togglePriceFields(); 349 this.bindRemoveButtons(); 351 sorting: function () { 352 var list = jQuery(this.tbody); 355 handle: '[data-role=draggable-handle]
', 357 update: function (event, data) { 358 list.find('[data-container=link-order]
').each(function (i, el) { 359 jQuery(el).val(i + 1); 365 remove : function(event){ 366 var element = $(Event.findElement(event, 'tr
')); 367 alertAlreadyDisplayed = false; 369 element.down('input[type=
"hidden"].__delete__
').value = '1
'; 370 Element.select(element, 'div.flex
').each(function(elm){ 373 element.addClassName('no-display
'); 374 element.addClassName('ignore-validate
'); 378 bindRemoveButtons : function(){ 379 var buttons = $$('tbody#link_items_body .action-
delete'); 380 for(var i=0;i<buttons.length;i++){ 381 if(!$(buttons[i]).binded && !$(buttons[i]).hasClassName('disabled
')){ 382 $(buttons[i]).binded = true; 383 Event.observe(buttons[i], 'click
', this.remove.bind(this)); 387 togglePriceFields : function(){ 388 var toogleTo = jQuery('#link-switcher1
').is(':checked
'); 389 var disableFlag = true; 393 $$('.link-prices[type=
"text"]
').each(function(elm){ 394 var flag = disableFlag; 395 if (elm.hasClassName('disabled
')) { 404 linkItems.bindRemoveButtons(); 406 linksUploader = function (id, url) { 411 sequentialUploads: true, 412 maxFileSize: 2000000, 413 add: function (e, data) { 414 var progressTmpl = mageTemplate(id + '-
template'), 418 $.each(data.files, function (index, file) { 419 if ($(id + ' .progressbar-container
').length) { 420 $(id + ' .progressbar-container
').parent().remove(); 423 fileSize = typeof file.size == "undefined" ? 424 $.mage.__('We could not detect a size.
') : 425 byteConvert(file.size); 427 data.fileId = Math.random().toString(36).substr(2, 9); 429 tmpl = progressTmpl({ 437 $(tmpl).appendTo(id); 440 $(this).fileupload('process
', data).done(function () { 444 done: function (e, data) { 445 var progressSelector = '#
' + data.fileId + ' .progressbar-container .progressbar
'; 446 $(progressSelector).css('width
', '100%
'); 447 if (data.result && !data.result.hasOwnProperty('errorcode
')) { 448 $(progressSelector).removeClass('upload-progress
').addClass('upload-success
'); 449 new Downloadable.FileList(id.substr(1), null).handleUploadComplete(data.result); 451 $(progressSelector).removeClass('upload-progress
').addClass('upload-failure
'); 452 var errorMsg = '<span
class=
"file-info-error">
' + data.result.error + '</span>
'; 453 $('#
' + data.fileId + ' .file-info
').append(errorMsg); 456 progress: function (e, data) { 457 var progress = parseInt(data.loaded / data.total * 100, 10); 458 var progressSelector = '#
' + data.fileId + ' .progressbar-container .progressbar
'; 459 $(progressSelector).css('width
', progress + '%
'); 461 fail: function (e, data) { 462 var progressSelector = '#
' + data.fileId + ' .progressbar-container .progressbar
'; 463 $(progressSelector).removeClass('upload-progress
').addClass('upload-failure
'); 464 if (data.result && data.result.hasOwnProperty('errorcode
')) { 465 var errorMsg = '<span
class=
"file-info-error">
' + data.result.error + '</span>
'; 466 $('#
' + data.fileId + ' .file-info
').append(errorMsg); 473 if (jQuery('input[
name=
"product[links_purchased_separately]"]
')) { 474 jQuery('input[
name=
"product[links_purchased_separately]"]
').on('change
', linkItems.togglePriceFields.bind()); 477 if($('add_link_item
')) { 478 Event.observe('add_link_item
', 'click
', linkItems.add.bind(linkItems)); 481 <?php foreach ($block->getLinkData() as $item): ?> 482 linkItems.add(<?= /* @escapeNotVerified */ $item->toJson() ?>); $block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
$_product $block getConfigJson() ?>< fieldset classif( $_product->getStoreId())(this, this.parentNode.parentNode)" <? endif
$_count $_index $_prevOptionId if($block->getOrderOptions()|| $_item->getDescription()) foreach( $items as $_item)( $_item) ?><?php $attributes if( $_item->getOrderItem() ->getParentItem())($_prevOptionId !=$attributes['option_id'])</td >< td > & nbsp
jQuery('.store-switcher .dropdown-menu li a').each(function()