Skip to content

Commit 8b089df

Browse files
committed
downloadable product view layout fix (issue #20187)
1) This fixes only catalog product view layout of of downloadables. The layout now is similar to simple or other types 2) Now the links are shown on frontend only if they sell separately or have samples. (Previously meaningless names of links also appeared) 3) Duplicate links title "Links" was removed as well. The layout on wishlist and maybe somewhere else still pending
1 parent 619f2db commit 8b089df

File tree

2 files changed

+64
-63
lines changed

2 files changed

+64
-63
lines changed

app/code/Magento/Downloadable/view/frontend/layout/catalog_product_view_type_downloadable.xml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
10-
<attribute name="class" value="page-product-downloadable"/>
1110
<referenceContainer name="product.info.main">
1211
<block class="Magento\Downloadable\Block\Catalog\Product\Samples" name="product.info.downloadable.samples" as="samples" template="Magento_Downloadable::catalog/product/samples.phtml" after="product.price.tier" />
1312
</referenceContainer>
@@ -26,21 +25,8 @@
2625
</block>
2726
</block>
2827
</referenceBlock>
29-
<referenceContainer name="product.info.options.wrapper.bottom">
30-
<block class="Magento\Catalog\Pricing\Render" name="product.price.final.copy" before="-">
31-
<arguments>
32-
<argument name="price_render" xsi:type="string">product.price.render.default</argument>
33-
<argument name="price_type_code" xsi:type="string">final_price</argument>
34-
<argument name="display_msrp_help_message" xsi:type="string">1</argument>
35-
<argument name="zone" xsi:type="string">item_view</argument>
36-
<argument name="id_suffix" xsi:type="string">copy-</argument>
37-
</arguments>
38-
</block>
39-
</referenceContainer>
4028
<referenceBlock name="head.components">
4129
<block class="Magento\Framework\View\Element\Js\Components" name="downloadable_page_head_components" template="Magento_Downloadable::js/components.phtml"/>
42-
</referenceBlock>
43-
<move element="product.info" destination="content" after="product.info.media" />
44-
<move element="product.info.social" destination="product.info.options.wrapper.bottom" after="-" />
30+
</referenceBlock>
4531
</body>
4632
</page>

app/code/Magento/Downloadable/view/frontend/templates/catalog/product/links.phtml

Lines changed: 63 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,67 @@
1313
<?php $_links = $block->getLinks(); ?>
1414
<?php $_linksLength = 0; ?>
1515
<?php $_isRequired = $block->getLinkSelectionRequired(); ?>
16-
<legend class="legend links-title"><span><?= $block->escapeHtml($block->getLinksTitle()) ?></span></legend><br>
17-
<div class="field downloads<?php if ($_isRequired) echo ' required' ?><?php if (!$_linksPurchasedSeparately) echo ' downloads-no-separately' ?>">
18-
<label class="label"><span><?= $block->escapeHtml($block->getLinksTitle()) ?></span></label>
19-
<div class="control" id="downloadable-links-list"
20-
data-mage-init='{"downloadable":{
21-
"linkElement":"input:checkbox[value]",
22-
"allElements":"#links_all",
23-
"config":<?= /* @escapeNotVerified */ $block->getJsonConfig() ?>}
24-
}'
25-
data-container-for="downloadable-links">
26-
<?php foreach ($_links as $_link): ?>
27-
<?php $_linksLength++;?>
28-
<div class="field choice" data-role="link">
29-
<?php if ($_linksPurchasedSeparately): ?>
30-
<input type="checkbox"
31-
<?php if ($_isRequired): ?>data-validate="{'validate-one-checkbox-required-by-name':'downloadable-links-list'}" <?php endif; ?>
32-
name="links[]"
33-
id="links_<?= /* @escapeNotVerified */ $_link->getId() ?>"
34-
value="<?= /* @escapeNotVerified */ $_link->getId() ?>" <?= /* @escapeNotVerified */ $block->getLinkCheckedValue($_link) ?> />
35-
<?php endif; ?>
36-
<label class="label" for="links_<?= /* @escapeNotVerified */ $_link->getId() ?>">
37-
<span><?= $block->escapeHtml($_link->getTitle()) ?></span>
38-
<?php if ($_link->getSampleFile() || $_link->getSampleUrl()): ?>
39-
<a class="sample link"
40-
href="<?= $block->escapeUrl($block->getLinkSampleUrl($_link)) ?>" <?= $block->getIsOpenInNewWindow() ? 'target="_blank"' : '' ?>>
41-
<?= /* @escapeNotVerified */ __('sample') ?>
42-
</a>
43-
<?php endif; ?>
44-
<?php if ($_linksPurchasedSeparately): ?>
45-
<?= /* @escapeNotVerified */ $block->getLinkPrice($_link) ?>
46-
<?php endif; ?>
47-
</label>
48-
</div>
49-
<?php endforeach; ?>
50-
<?php if ($_linksPurchasedSeparately && $_linksLength > 1): ?>
51-
<div class="field choice downloads-all">
52-
<input type="checkbox"
53-
data-notchecked="<?= /* @escapeNotVerified */ __('Select all') ?>"
54-
data-checked="<?= /* @escapeNotVerified */ __('Unselect all') ?>"
55-
id="links_all" />
56-
<label class="label" for="links_all"><span><?= /* @escapeNotVerified */ __('Select all') ?></span></label>
57-
</div>
58-
<?php endif; ?>
59-
</div>
60-
<?php if ($_isRequired): ?>
61-
<span id="links-advice-container"></span>
62-
<?php endif;?>
63-
</div>
16+
<?php
17+
// Show links on frontend only if links are purchased separately
18+
// or only those links with samples. Otherwise there is no point to show link names
19+
$samples = false;
20+
foreach ($_links as $_link){
21+
if ($_link->getSampleFile() || $_link->getSampleUrl()) {
22+
$samples = true;
23+
break;
24+
}
25+
}
26+
?>
27+
<?php if ($samples === true || $_linksPurchasedSeparately): ?>
28+
<?php /* <legend class="legend links-title"><span><?= $block->escapeHtml($block->getLinksTitle()) ?></span></legend><br> */ ?>
29+
<div class="field downloads<?php if ($_isRequired) echo ' required' ?><?php if (!$_linksPurchasedSeparately) echo ' downloads-no-separately' ?>">
30+
<label class="label"><span><?= $block->escapeHtml($block->getLinksTitle()) ?></span></label>
31+
<div class="control" id="downloadable-links-list"
32+
data-mage-init='{"downloadable":{
33+
"linkElement":"input:checkbox[value]",
34+
"allElements":"#links_all",
35+
"config":<?= /* @escapeNotVerified */ $block->getJsonConfig() ?>}
36+
}'
37+
data-container-for="downloadable-links">
38+
<?php foreach ($_links as $_link): ?>
39+
<?php if (($_link->getSampleFile() || $_link->getSampleUrl()) || $_linksPurchasedSeparately): ?>
40+
<?php $_linksLength++;?>
41+
<div class="field choice" data-role="link">
42+
<?php if ($_linksPurchasedSeparately): ?>
43+
<input type="checkbox"
44+
<?php if ($_isRequired): ?>data-validate="{'validate-one-checkbox-required-by-name':'downloadable-links-list'}" <?php endif; ?>
45+
name="links[]"
46+
id="links_<?= /* @escapeNotVerified */ $_link->getId() ?>"
47+
value="<?= /* @escapeNotVerified */ $_link->getId() ?>" <?= /* @escapeNotVerified */ $block->getLinkCheckedValue($_link) ?> />
48+
<?php endif; ?>
49+
<label class="label" for="links_<?= /* @escapeNotVerified */ $_link->getId() ?>">
50+
<span><?= $block->escapeHtml($_link->getTitle()) ?></span>
51+
<?php if ($_link->getSampleFile() || $_link->getSampleUrl()): ?>
52+
<a class="sample link"
53+
href="<?= $block->escapeUrl($block->getLinkSampleUrl($_link)) ?>" <?= $block->getIsOpenInNewWindow() ? 'target="_blank"' : '' ?>>
54+
<?= /* @escapeNotVerified */ __('sample') ?>
55+
</a>
56+
<?php endif; ?>
57+
<?php if ($_linksPurchasedSeparately): ?>
58+
<?= /* @escapeNotVerified */ $block->getLinkPrice($_link) ?>
59+
<?php endif; ?>
60+
</label>
61+
</div>
62+
<?php endif; ?>
63+
<?php endforeach; ?>
64+
<?php if ($_linksPurchasedSeparately && $_linksLength > 1): ?>
65+
<div class="field choice downloads-all">
66+
<input type="checkbox"
67+
data-notchecked="<?= /* @escapeNotVerified */ __('Select all') ?>"
68+
data-checked="<?= /* @escapeNotVerified */ __('Unselect all') ?>"
69+
id="links_all" />
70+
<label class="label" for="links_all"><span><?= /* @escapeNotVerified */ __('Select all') ?></span></label>
71+
</div>
72+
<?php endif; ?>
73+
</div>
74+
<?php if ($_isRequired): ?>
75+
<span id="links-advice-container"></span>
76+
<?php endif;?>
77+
</div>
78+
<?php endif; ?>
6479
<?php endif; ?>

0 commit comments

Comments
 (0)