custom button on product page/product listing in magento












2















I want to show a custom button on product detail page as well as on product listing.



this button will be visible based on an attribute.(if I select an attribute to yes while creating product, only then this button should be visible.)
and I want to show a block on hover on button.
i am very new to magento so detailed instruction will be better.



enter image description here










share|improve this question
















bumped to the homepage by Community 13 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    2















    I want to show a custom button on product detail page as well as on product listing.



    this button will be visible based on an attribute.(if I select an attribute to yes while creating product, only then this button should be visible.)
    and I want to show a block on hover on button.
    i am very new to magento so detailed instruction will be better.



    enter image description here










    share|improve this question
















    bumped to the homepage by Community 13 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      2












      2








      2


      0






      I want to show a custom button on product detail page as well as on product listing.



      this button will be visible based on an attribute.(if I select an attribute to yes while creating product, only then this button should be visible.)
      and I want to show a block on hover on button.
      i am very new to magento so detailed instruction will be better.



      enter image description here










      share|improve this question
















      I want to show a custom button on product detail page as well as on product listing.



      this button will be visible based on an attribute.(if I select an attribute to yes while creating product, only then this button should be visible.)
      and I want to show a block on hover on button.
      i am very new to magento so detailed instruction will be better.



      enter image description here







      magento-1.9 product products product-list






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 22 '17 at 7:16









      Teja Bhagavan Kollepara

      2,97341847




      2,97341847










      asked Feb 29 '16 at 16:04









      AnuragAnurag

      111




      111





      bumped to the homepage by Community 13 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 13 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          3 Answers
          3






          active

          oldest

          votes


















          0














          Creating a custom attribute eg.(mybutton) and it's Input Type will be yes or no now finally write below code in {theme}/template/catalog/product/view/addtocart.phtml near Add to Cart button.



          <?php 
          if($_product->getMybutton()){

          ?>
          <button type="button">Special order </button>
          <?php } ?>


          Hope it will help you.






          share|improve this answer































            0














            What Arunendra said is right for the button but for the hover you need some more code.



            This can go in your .css file and can be styled any way you want, our you can put it this way in your .phtml depends on your needs



             <style>
            .tooltip{display: inline;position: relative;}
            .tooltip:hover:after{background: #333;background: rgba(0,0,0,.8);border-radius: 5px;bottom: 10px;color: #fff;content: attr(title);
            left: 20%;padding: 5px 15px;position: absolute;z-index: 98;width: 220px;}
            .tooltip:hover:before{border: solid;border-color: #333 transparent;border-width: 6px 6px 0 6px;bottom: 6px;content: "";left: 50%;position: absolute;z-index: 99;}
            .tip{display:inline-block;padding-left:12px;}
            </style>


            Then the button as mentioned in {theme}/template/catalog/product/view/addtocart.phtml



            <?php 
            if($_product->getMybutton()){ //yes or no button
            ?>
            <div class="tip">
            <p class="tooltip">This can be anything you want and your text goes in ehre</p></div>
            <?php } ?>





            share|improve this answer































              0














              first of all thank you all for you replies.
              but
              i asked for detailed instruction but it's ok, i fix this by using this code. in addtocart and list template.



                  <?php $attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('attribute name'); ?>
              <?php if ($attributeValue == 'check with attributed value'){ ?>
              <!--html code-->
              <img src="img/special.png" onMouseOver="show_sidebar()" onMouseOut="hide_sidebar()" alt="Special Order" />
              <div id="sidebar">text goes here</div>
              <!--js for hide show-->
              <script type="text/javascript">
              function show_sidebar()
              {
              document.getElementById('sidebar').style.visibility="visible";
              }

              function hide_sidebar()
              {
              document.getElementById('sidebar').style.visibility="hidden";
              }
              </script>
              <?php } ?>





              share|improve this answer
























              • You could at least accept the answer

                – Haim
                Oct 26 '18 at 0:43











              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "479"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103968%2fcustom-button-on-product-page-product-listing-in-magento%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              Creating a custom attribute eg.(mybutton) and it's Input Type will be yes or no now finally write below code in {theme}/template/catalog/product/view/addtocart.phtml near Add to Cart button.



              <?php 
              if($_product->getMybutton()){

              ?>
              <button type="button">Special order </button>
              <?php } ?>


              Hope it will help you.






              share|improve this answer




























                0














                Creating a custom attribute eg.(mybutton) and it's Input Type will be yes or no now finally write below code in {theme}/template/catalog/product/view/addtocart.phtml near Add to Cart button.



                <?php 
                if($_product->getMybutton()){

                ?>
                <button type="button">Special order </button>
                <?php } ?>


                Hope it will help you.






                share|improve this answer


























                  0












                  0








                  0







                  Creating a custom attribute eg.(mybutton) and it's Input Type will be yes or no now finally write below code in {theme}/template/catalog/product/view/addtocart.phtml near Add to Cart button.



                  <?php 
                  if($_product->getMybutton()){

                  ?>
                  <button type="button">Special order </button>
                  <?php } ?>


                  Hope it will help you.






                  share|improve this answer













                  Creating a custom attribute eg.(mybutton) and it's Input Type will be yes or no now finally write below code in {theme}/template/catalog/product/view/addtocart.phtml near Add to Cart button.



                  <?php 
                  if($_product->getMybutton()){

                  ?>
                  <button type="button">Special order </button>
                  <?php } ?>


                  Hope it will help you.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 1 '16 at 5:21









                  ArunendraArunendra

                  6,20831842




                  6,20831842

























                      0














                      What Arunendra said is right for the button but for the hover you need some more code.



                      This can go in your .css file and can be styled any way you want, our you can put it this way in your .phtml depends on your needs



                       <style>
                      .tooltip{display: inline;position: relative;}
                      .tooltip:hover:after{background: #333;background: rgba(0,0,0,.8);border-radius: 5px;bottom: 10px;color: #fff;content: attr(title);
                      left: 20%;padding: 5px 15px;position: absolute;z-index: 98;width: 220px;}
                      .tooltip:hover:before{border: solid;border-color: #333 transparent;border-width: 6px 6px 0 6px;bottom: 6px;content: "";left: 50%;position: absolute;z-index: 99;}
                      .tip{display:inline-block;padding-left:12px;}
                      </style>


                      Then the button as mentioned in {theme}/template/catalog/product/view/addtocart.phtml



                      <?php 
                      if($_product->getMybutton()){ //yes or no button
                      ?>
                      <div class="tip">
                      <p class="tooltip">This can be anything you want and your text goes in ehre</p></div>
                      <?php } ?>





                      share|improve this answer




























                        0














                        What Arunendra said is right for the button but for the hover you need some more code.



                        This can go in your .css file and can be styled any way you want, our you can put it this way in your .phtml depends on your needs



                         <style>
                        .tooltip{display: inline;position: relative;}
                        .tooltip:hover:after{background: #333;background: rgba(0,0,0,.8);border-radius: 5px;bottom: 10px;color: #fff;content: attr(title);
                        left: 20%;padding: 5px 15px;position: absolute;z-index: 98;width: 220px;}
                        .tooltip:hover:before{border: solid;border-color: #333 transparent;border-width: 6px 6px 0 6px;bottom: 6px;content: "";left: 50%;position: absolute;z-index: 99;}
                        .tip{display:inline-block;padding-left:12px;}
                        </style>


                        Then the button as mentioned in {theme}/template/catalog/product/view/addtocart.phtml



                        <?php 
                        if($_product->getMybutton()){ //yes or no button
                        ?>
                        <div class="tip">
                        <p class="tooltip">This can be anything you want and your text goes in ehre</p></div>
                        <?php } ?>





                        share|improve this answer


























                          0












                          0








                          0







                          What Arunendra said is right for the button but for the hover you need some more code.



                          This can go in your .css file and can be styled any way you want, our you can put it this way in your .phtml depends on your needs



                           <style>
                          .tooltip{display: inline;position: relative;}
                          .tooltip:hover:after{background: #333;background: rgba(0,0,0,.8);border-radius: 5px;bottom: 10px;color: #fff;content: attr(title);
                          left: 20%;padding: 5px 15px;position: absolute;z-index: 98;width: 220px;}
                          .tooltip:hover:before{border: solid;border-color: #333 transparent;border-width: 6px 6px 0 6px;bottom: 6px;content: "";left: 50%;position: absolute;z-index: 99;}
                          .tip{display:inline-block;padding-left:12px;}
                          </style>


                          Then the button as mentioned in {theme}/template/catalog/product/view/addtocart.phtml



                          <?php 
                          if($_product->getMybutton()){ //yes or no button
                          ?>
                          <div class="tip">
                          <p class="tooltip">This can be anything you want and your text goes in ehre</p></div>
                          <?php } ?>





                          share|improve this answer













                          What Arunendra said is right for the button but for the hover you need some more code.



                          This can go in your .css file and can be styled any way you want, our you can put it this way in your .phtml depends on your needs



                           <style>
                          .tooltip{display: inline;position: relative;}
                          .tooltip:hover:after{background: #333;background: rgba(0,0,0,.8);border-radius: 5px;bottom: 10px;color: #fff;content: attr(title);
                          left: 20%;padding: 5px 15px;position: absolute;z-index: 98;width: 220px;}
                          .tooltip:hover:before{border: solid;border-color: #333 transparent;border-width: 6px 6px 0 6px;bottom: 6px;content: "";left: 50%;position: absolute;z-index: 99;}
                          .tip{display:inline-block;padding-left:12px;}
                          </style>


                          Then the button as mentioned in {theme}/template/catalog/product/view/addtocart.phtml



                          <?php 
                          if($_product->getMybutton()){ //yes or no button
                          ?>
                          <div class="tip">
                          <p class="tooltip">This can be anything you want and your text goes in ehre</p></div>
                          <?php } ?>






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 1 '16 at 8:44









                          KlettsebKlettseb

                          3,05031751




                          3,05031751























                              0














                              first of all thank you all for you replies.
                              but
                              i asked for detailed instruction but it's ok, i fix this by using this code. in addtocart and list template.



                                  <?php $attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('attribute name'); ?>
                              <?php if ($attributeValue == 'check with attributed value'){ ?>
                              <!--html code-->
                              <img src="img/special.png" onMouseOver="show_sidebar()" onMouseOut="hide_sidebar()" alt="Special Order" />
                              <div id="sidebar">text goes here</div>
                              <!--js for hide show-->
                              <script type="text/javascript">
                              function show_sidebar()
                              {
                              document.getElementById('sidebar').style.visibility="visible";
                              }

                              function hide_sidebar()
                              {
                              document.getElementById('sidebar').style.visibility="hidden";
                              }
                              </script>
                              <?php } ?>





                              share|improve this answer
























                              • You could at least accept the answer

                                – Haim
                                Oct 26 '18 at 0:43
















                              0














                              first of all thank you all for you replies.
                              but
                              i asked for detailed instruction but it's ok, i fix this by using this code. in addtocart and list template.



                                  <?php $attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('attribute name'); ?>
                              <?php if ($attributeValue == 'check with attributed value'){ ?>
                              <!--html code-->
                              <img src="img/special.png" onMouseOver="show_sidebar()" onMouseOut="hide_sidebar()" alt="Special Order" />
                              <div id="sidebar">text goes here</div>
                              <!--js for hide show-->
                              <script type="text/javascript">
                              function show_sidebar()
                              {
                              document.getElementById('sidebar').style.visibility="visible";
                              }

                              function hide_sidebar()
                              {
                              document.getElementById('sidebar').style.visibility="hidden";
                              }
                              </script>
                              <?php } ?>





                              share|improve this answer
























                              • You could at least accept the answer

                                – Haim
                                Oct 26 '18 at 0:43














                              0












                              0








                              0







                              first of all thank you all for you replies.
                              but
                              i asked for detailed instruction but it's ok, i fix this by using this code. in addtocart and list template.



                                  <?php $attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('attribute name'); ?>
                              <?php if ($attributeValue == 'check with attributed value'){ ?>
                              <!--html code-->
                              <img src="img/special.png" onMouseOver="show_sidebar()" onMouseOut="hide_sidebar()" alt="Special Order" />
                              <div id="sidebar">text goes here</div>
                              <!--js for hide show-->
                              <script type="text/javascript">
                              function show_sidebar()
                              {
                              document.getElementById('sidebar').style.visibility="visible";
                              }

                              function hide_sidebar()
                              {
                              document.getElementById('sidebar').style.visibility="hidden";
                              }
                              </script>
                              <?php } ?>





                              share|improve this answer













                              first of all thank you all for you replies.
                              but
                              i asked for detailed instruction but it's ok, i fix this by using this code. in addtocart and list template.



                                  <?php $attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('attribute name'); ?>
                              <?php if ($attributeValue == 'check with attributed value'){ ?>
                              <!--html code-->
                              <img src="img/special.png" onMouseOver="show_sidebar()" onMouseOut="hide_sidebar()" alt="Special Order" />
                              <div id="sidebar">text goes here</div>
                              <!--js for hide show-->
                              <script type="text/javascript">
                              function show_sidebar()
                              {
                              document.getElementById('sidebar').style.visibility="visible";
                              }

                              function hide_sidebar()
                              {
                              document.getElementById('sidebar').style.visibility="hidden";
                              }
                              </script>
                              <?php } ?>






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Mar 5 '16 at 21:40









                              AnuragAnurag

                              111




                              111













                              • You could at least accept the answer

                                – Haim
                                Oct 26 '18 at 0:43



















                              • You could at least accept the answer

                                – Haim
                                Oct 26 '18 at 0:43

















                              You could at least accept the answer

                              – Haim
                              Oct 26 '18 at 0:43





                              You could at least accept the answer

                              – Haim
                              Oct 26 '18 at 0:43


















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103968%2fcustom-button-on-product-page-product-listing-in-magento%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              What other Star Trek series did the main TNG cast show up in?

                              Berlina muro

                              Berlina aerponto