I have some attributes that I want to go above the "Add to Cart" button. How can I achieve this?

I followed this tutorial but that didn't work for me -> http://www.dckap.com/blog/display-custom-attribute-value-product-viewlist-page-magento-2/

I am using Magento version 2.1.8

1 Answer 1


Create attr.phtml file and call all your attributes inside that file.


add your attribute code

<?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getAttributeCode(), 'attribute_code'); ?>

Inside your xml file


<referenceBlock name="product.info.main">
    <block class="Magento\Catalog\Block\Product\View" name="attr" template="product/view/attr.phtml" />

after that move your attr block where ever you want.

for example,

<move element="attr" destination="product.info.main" before="product.info.price" />

let me know if you need any help.

  • 1
    Hi. Thanks for your help. It doesn't work for me... I did exactly what you said. Also, why is there $block->getProduct()->getShippingDelivery(), 'shipping_delivery') is that the attribute? I have created a attribute called bottle_size and added it to attribute set called liquid, now I need to bring this attribute in the product view.
    – Greg
    Nov 24, 2017 at 14:40
  • You have to call your attribute there... what ever your attribute code Nov 24, 2017 at 14:41
  • Could you guide me through it? Been looking for some tutorials but can't find anything :/
    – Greg
    Nov 24, 2017 at 14:43
  • what are your attribute codes? Nov 24, 2017 at 14:45
  • 1
    <?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getBottleSize(), 'bottle_size'); ?>.. please assign your attribute to product and add some value in it Nov 24, 2017 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.