add_ingredients_filter

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #29233
    Michael Maccar
    Participant

      Hi Oliver

      I was wondering if the below filter still works with the latest version of the add ingredient as when clicked it doesn’t do anything on my site at the moment, not sure this happened after updating to the latest version or it been like this for a while

      
      add_filter('wppizza_add_ingredients_filter_after_groups', 'my_custom_filter',10,2);
      function my_custom_filter($str,$lbl){
      $str.='<div style="margin:0 0 30px 0;padding:3px 3px 0 0;"><input id="wppizza-diy-to-cart" class="btn btn-primary" type="button" value="'.$lbl['add_to_cart'].'"></div>';   
      return $str;
      }
      

      Many thanks

      [Edited by admin: please wrap code in code tags, thanks]

      #29235
      Olly
      Admin & Mod

        as of 5.0.7 (see changelog here : https://www.wp-pizza.com/downloads/wppizza-add-ingredients/) you must use a class selector instead of id for exactly that reason that you cannot have two elements with the same id if you append/add/double up this button .

        i know the changelog example is about the css, but it applies anywhere this button is used

        therefore you should change your

        
        $str.='<div style=”margin:0 0 30px 0;padding:3px 3px 0 0;”><input id=”wppizza-diy-to-cart” class=”btn btn-primary” type=”button” value=”‘.$lbl[‘add_to_cart’].'”></div>’;
        

        to

        
        $str.='<div style=”margin:0 0 30px 0;padding:3px 3px 0 0;”><input class=”wppizza-diy-to-cart btn btn-primary” type=”button” value=”‘.$lbl[‘add_to_cart’].'”></div>’;
        

        and this should work again (let me know if it does not)

        #29236
        Michael Maccar
        Participant

          Still the same, it adds another button but nothing happens when clicked.

          #29237
          Olly
          Admin & Mod

            I need a link please

            #29238
            Michael Maccar
            Participant
              This reply has been marked as private.
              #29241
              Olly
              Admin & Mod

                you are right. that script/codesnippet as is won’t work anymore with v5.0.8

                i will need to update that plugin (and add a couple of things). When done – later today or tomorrow – I’ll post an update to that code here (one might need to use another filter entirely, not sure yet )

                #29242
                Michael Maccar
                Participant

                  Take your time. Thank you very much!

                  #29243
                  Olly
                  Admin & Mod

                    I updated the plugin (5.0.9 now)
                    update it from your admin plugins page and then you should be able to use the (second – for v5.0.9) codesnippet i added here

                    https://www.wp-pizza.com/topic/addingfiltering-the-output/

                    instead.

                    as ever, if you have any issues, let me know

                    #29247
                    Michael Maccar
                    Participant

                      Works now. Thank you.

                    Viewing 9 posts - 1 through 9 (of 9 total)
                    • The topic ‘add_ingredients_filter’ is closed to new replies.