0

I want to display text between the product price and the availability.

When a product is in stock i want it to display: "Ships today is ordered before 17:00".

EDIT: I created the attribute 'ships_today' and i have asigned it but it wont show on the product page. This is my code of view.phtml:

<?php if ($_product->isAvailable()): ?>
                        <p "class="availability in-stock"><span style="font-weight: bold; color: green;">(<?php echo $this->__('In stock') ?>)</span></p><br>
                    <?php echo $_product->getShipsToday(); ?>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span>(<?php echo $this->__('Out of stock') ?>)</span></p>
                    <?php endif; ?>
  • check my updated answer – Pradeep Sanku Aug 3 '16 at 12:52
  • have you reindexed ? – Pradeep Sanku Aug 3 '16 at 12:55
  • Still wont show up, have reindexed and deleted the cache – Pieter Aug 3 '16 at 13:03
  • and check your attribute ships_today has been set to Yes for Visible on Product View Page on Front-end and Used in Product Listing ? – Pradeep Sanku Aug 3 '16 at 13:04
  • Yes, all frontend options are set to 'yes' – Pieter Aug 3 '16 at 13:05
0

create a product attribute called ships_today of type text and assign to attribute set.Now you can set value to "Ships today is ordered before 17:00" to those products which can be shipped today if they order before 17:00

and call this attribute using code <?php echo $_product->getShipsToday(); ?> in template/catalog/product/view.phtml whereever you need to call

if you want this thing between price and availability then call <?php echo $_product->getShipsToday(); ?> after <div class="price-info"></div> and before <div class="extra-info"></div>

and check your attribute ships_today has been set to Yes for Visible on Product View Page on Front-end and Used in Product Listing

0

You need to load attribute on product page. To do it just need to ensure that you checked field 'Visible on product page' when editing setting of attribute. (Catalog -> Attributes -> Manage Attributes and in first Tab from left, check penultimate option - second horizontall tab)

To show attribute you can do alternative method:

echo $_product->getData('ships_today');  

Refresh index and cache on the end to be sure. Check if product is set to 'In stock' because your attribute is in 'if' statement.

You can debug all possible attributes by:

Zend_Debug::dump($_product->getData());

This will show you all attributes with your custom one. If is there then problem is in you echo and php code. If it isn't, then you can load your product by load() method.

Source of debug hint: https://www.atwix.com/magento/debugging-hints/

  • The product is in stock and the text 'availability: in stock' appears on the frontend. I set the attribute by adding it to the attributeset 'Default' and dragged it under 'General'. – Pieter Aug 3 '16 at 13:20
  • Can you say what Zend_Debug::dump($_product->getData()); show you? Maybe it even not show because it is on other type of template because there exist more than one type of product. – Patryk Padus Aug 3 '16 at 13:23
  • Where would i paste this code to test it? – Pieter Aug 3 '16 at 13:27
  • <?php if ($_product->isAvailable()): ?> <p "class="availability in-stock"><span style="font-weight: bold; color: green;">(<?php echo $this->__('In stock') ?>)</span></p><br> <?php echo $_product->getShipsToday(); ?> <?php else: ?> <p class="availability out-of-stock"><span>(<?php echo $this->__('Out of stock') ?>)</span></p> <?php endif; ?> – Patryk Padus Aug 3 '16 at 13:30
  • I'm getting nothing. – Pieter Aug 3 '16 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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