Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
msrp.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
14 ?>
15 <?php
16 
18 $priceType = $block->getPrice();
19 
21 $product = $block->getSaleableItem();
22 $productId = $product->getId();
23 $msrpPrice = $block->renderAmount(
24  $priceType->getCustomAmount($product->getMsrp() ?: $product->getTypeInstance()->getChildrenMsrp($product)),
25  [
26  'price_id' => $block->getPriceId() ? $block->getPriceId() : 'old-price-' . $productId,
27  'include_container' => false,
28  'skip_adjustments' => true
29  ]
30 );
31 $priceElementIdPrefix = $block->getPriceElementIdPrefix() ? $block->getPriceElementIdPrefix() : 'product-price-';
32 
34 if ($product->isSaleable()) {
36  $addToCartUrlGenerator = $block->getLayout()->getBlockSingleton('Magento\Catalog\Block\Product\AbstractProduct');
37  $addToCartUrl = $addToCartUrlGenerator->getAddToCartUrl(
38  $product,
39  ['_query' => [
40  \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED =>
41  $this->helper('Magento\Framework\Url\Helper\Data')->getEncodedUrl(
42  $addToCartUrlGenerator->getAddToCartUrl($product)
43  ),
44  ]]
45  );
46 }
47 ?>
48 <?php if ($product->getMsrp()): ?>
49  <span class="old-price map-old-price"><?= /* @escapeNotVerified */ $msrpPrice ?></span>
50 <?php endif; ?>
51 
52 <?php if ($priceType->isShowPriceOnGesture()): ?>
53  <?php
54  $priceElementId = $priceElementIdPrefix . $productId . $block->getIdSuffix();
55  $popupId = 'msrp-popup-' . $productId . $block->getRandomString(20);
56  $data = ['addToCart' => [
57  'origin'=> 'msrp',
58  'popupId' => '#' . $popupId,
59  'productName' => $block->escapeJs($block->escapeHtml($product->getName())),
60  'productId' => $productId,
61  'productIdInput' => 'input[type="hidden"][name="product"]',
62  'realPrice' => $block->getRealPriceHtml(),
63  'isSaleable' => $product->isSaleable(),
64  'msrpPrice' => $msrpPrice,
65  'priceElementId' => $priceElementId,
66  'closeButtonId' => '#map-popup-close',
67  'addToCartUrl' => $addToCartUrl,
68  'paymentButtons' => '[data-label=or]'
69  ]];
70  if ($block->getRequest()->getFullActionName() === 'catalog_product_view') {
71  $data['addToCart']['addToCartButton'] = '#product_addtocart_form [type=submit]';
72  } else {
73  $data['addToCart']['addToCartButton'] = sprintf(
74  'form:has(input[type="hidden"][name="product"][value="%s"]) button[type="submit"]',
75  (int) $productId
76  );
77  }
78  ?>
79  <span id="<?= /* @escapeNotVerified */ $block->getPriceId() ? $block->getPriceId() : $priceElementId ?>" style="display:none"></span>
80  <a href="javascript:void(0);"
81  id="<?= /* @escapeNotVerified */ ($popupId) ?>"
82  class="action map-show-info"
83  data-mage-init='<?= /* @noEscape */ $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($data) ?>'><?= /* @escapeNotVerified */ __('Click for price') ?>
84  </a>
85 <?php else: ?>
86  <span class="msrp-message">
87  <?= /* @escapeNotVerified */ $priceType->getMsrpPriceMessage() ?>
88  </span>
89 <?php endif; ?>
90 
92  <?php $helpLinkId = 'msrp-help-' . $productId . $block->getRandomString(20); ?>
93  <a href="javascript:void(0);"
94  id="<?= /* @escapeNotVerified */ $helpLinkId ?>"
95  class="action map-show-info"
96  data-mage-init='{"addToCart":{"origin": "info",
97  "helpLinkId": "#<?= /* @escapeNotVerified */ $helpLinkId ?>",
98  "productName": "<?= $block->escapeJs($block->escapeHtml($product->getName())) ?>",
99  "closeButtonId": "#map-popup-close"}}'><span><?= /* @escapeNotVerified */ __("What's this?") ?></span>
100  </a>
101 <?php endif; ?>
$productId
Definition: msrp.phtml:22
if( $form)() ?>< script > require(['jquery' mage mage
Definition: save.phtml:15
__()
Definition: __.php:13
$block
Definition: block.php:8
$priceType
Definition: msrp.phtml:18
$msrpPrice
Definition: msrp.phtml:23
endif
Definition: 404.phtml:116
$popupId
Definition: msrp.phtml:55
$product
Definition: msrp.phtml:21
if( $canApplyMsrp)(__( 'Price')) ?>"> <span class $helpLinkId
Definition: default.phtml:74
$priceElementIdPrefix
Definition: msrp.phtml:31
$addToCartUrl
Definition: msrp.phtml:33