New ingredients functions

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #69054
    Umut
    Participant

      Dear Olly,

      I need a feature that I often require but is currently unavailable in the WP-Pizza ingredients functions.

      For example:
      Usually, I create a group under the “Portion Size” section for pizzas that consists of two columns: 30 cm and 40 cm. When adding pizzas, I can set the prices separately for both the 30 cm and 40 cm pizzas. Additionally, when I add ingredients to this group, they appear for both the 30 cm and 40 cm options. However, some of my customers request gluten-free dough, which is only available for 30 cm pizzas. If I offer this as an option under ingredients, it appears for both 30 cm and 40 cm pizzas, but I only want it to show for those selecting the 30 cm option. Otherwise, I would have to create about 50-60 pizzas and the same number of ingredients in a separate group, which is very tedious. Do you have a suggestion for me?

      For instance, if there were an option to add “gluten-free dough” to the ingredient list and have it only appear when the 30 cm option is selected, it would solve the issue nicely.

      Thank you in advance!
      Umut

      #69068
      Olly
      Admin & Mod

        sounds like you need to setup/add an “exclude” ingredients custom group

        #69086
        Umut
        Participant

          Dear Olly

          Based on your feedback, I tested the “exclude” ingredients custom group. I can set it up so that the ingredients group only shows the normal ingredients for 40cm, while for 32cm pizzas, the dough selection is also displayed. However, when I choose “exclude,” the radio button does not appear, allowing users to choose between gluten-free dough or classic dough. Instead, it appears like normal ingredients, and people can select both at the same time. If the radio option could be included in the “exclude” group, my issue would be resolved.

          I also have a similar issue with delivery or pickup options. Some businesses are permitted to deliver alcoholic beverages but are not allowed to sell them on-site. In this case, I cannot disable alcoholic beverages for pickup. Therefore, I need a solution that allows product categories to be shown or hidden for pickup or delivery.

          #69099
          Olly
          Admin & Mod

            you would need to put your dough selection it into it’s own (custom) group . (with a “…choose one only…” setting I would think)
            Otherwise it’s just another ingredient.

            Regarding pickup / delivery :
            there’s a ‘wppizza_filter_loop_args’ filter that lets you set the arguments (i.e the posts returned). so in conjunction with

            
            if(wppizza_is_pickup()){
            /* do something if pickup selected*/
            }
            

            for example (https://docs.wp-pizza.com/developers/?section=global-wppizza-functions)
            I would think you could exclude posts (i.e post id’s ) as required . Probably simply getting all wppizza posts(ids) that belong to your beverages category and exclude/include as required

            alternatively, some conditional – again , based on wppizza_is_pickup() that simply removes the beverages shortcode of the page where you have it (or exclude that page entirely from your site when it’s pickup)

            Up to you which way you want to do this of course

            #69100
            Olly
            Admin & Mod

              PS: taking items off the page would not stop an item from being added to the cart first and then pickup being changed to delivery (or vice versa).
              If you want to prevent that too , it gets a lot more complicated although you could perhaps run/add the filter below as well and removing the non-permitted items in the cart as required

              
              $session = apply_filters('wppizza_fltr_session', $session);
              

              (though not tested in any shape or form – just an idea off the top of my head)

              Alternatively you of course have two sites (multisite setup perhaps) one for pickup, one for delivery

              #69102
              Umut
              Participant

                Dear Olly,

                Thank you for your responses.

                Unfortunately, despite spending hours trying, I couldn’t manage to hide the drinks page when the “Pickup” option is selected.

                I first created a child theme and added a functions.php file with the following code:

                <?php
                // Enqueue parent theme styles
                function spacious_pro_child_enqueue_styles() {
                wp_enqueue_style(‘parent-style’, get_template_directory_uri() . ‘/style.css’);
                }
                add_action(‘wp_enqueue_scripts’, ‘spacious_pro_child_enqueue_styles’);

                // Filter WPPizza query based on pickup selection
                add_filter(‘wppizza_filter_loop_args’, ‘exclude_bier_wein_if_pickup’);
                function exclude_bier_wein_if_pickup($args) {
                // Check if the customer selected pickup
                if (function_exists(‘wppizza_is_pickup’) && wppizza_is_pickup()) {
                // Exclude ‘bier-wein’ category (ID 16) from the query
                $args[‘category__not_in’] = array(16); // 16 is the ID of the ‘bier-wein’ category
                }
                return $args;
                }
                ?>

                I tried using category ID 16, which is for the alcoholic beverages, but it still didn’t work. I think such tasks are beyond my skill level.

                As you mentioned, it could be done on two separate sites, one for “Pickup” and another for “Delivery,” but I have no intention of creating two separate sites. A solution within the system would be more reasonable. I once saw a similar solution with WooCommerce; maybe I’ll try it out in the future.

                Thanks again for everything.

                Best regards
                Umut

                #69104
                Olly
                Admin & Mod

                  wppizza is a custom post type, category__not_in will not work there. you will need taxonomy queries

                  
                  $args['tax_query']['relation'] = 'AND' ;
                  $args['tax_query'][1]['taxonomy'] 			=  WPPIZZA_TAXONOMY ;
                  $args['tax_query'][1]['field'] 			=  'id' ;
                  $args['tax_query'][1]['terms'] 			=  array(16) ;/* 16 being your beer/wine cat */ 
                  $args['tax_query'][1]['include_children'] 			=  false ;
                  $args['tax_query'][1]['operator'] 			=  'NOT IN' ;
                  

                  that said, having thought about this a bit more, I think this is actually going down the wrong path as you would also have to find a way to reload the page when switching between pickup/delivery . Do-able but somewhat unnecessarily complicated altogether if you ask me.

                  perhaps a (somewhat) better approach is actually some js here .

                  every item has a title with an id , that is made up of blogid, catid, postid, sizes(tier)id, in tier id like

                  
                  <h2 id="wppizza-article-1-2-8-3-0" class="wppizza-article-h2">
                  

                  so you can select all ‘wppizza-article-h2’ on a page , get the id’s , split by ‘-‘ to then get all ‘cat ids’ so to speak
                  and show/hide depending on pickup/delivery value and when switching between the two (you’d still need to set the session in the cart accordingly with a php filter)

                  advantage being you do not have to reload any pages so much faster (still many pitfalls on the way to be encountered , but personally i think a better approach)

                  I might make this sort of thing into a plugin myself as i can see the possible need for this in certain circumstances, but at the moment we are where we are

                  #69173
                  Olly
                  Admin & Mod

                    While I was messing around with various things it occurred to me that this sort of thing already exists in the pickup prices plugin – https://www.wp-pizza.com/downloads/wppizza-pickup-prices/

                    you simply need to enter -0 into any pickup price for an item . If you apply the -0 to all pickup-prices (i.e variations) of an item, the whole item will become unavailable on pickup…

                    #69174
                    Umut
                    Participant

                      Dear Olly,
                      this solution (pickup price) turned out great, exactly as I wanted.
                      Thank you very much for it.

                      #69184
                      Umut
                      Participant

                        Dear Olly,
                        If I set the Pickup Price of an item that I don’t want to appear for delivery to “0,” the item disappears. This approach solved my issue.
                        But how would it work if I wanted to create the opposite effect for another item? For example, if the “Kebab Box” should only be available for pickup and not selectable or visible for customers when they choose delivery.
                        Following the same logic, I set the regular price to “0” and entered the actual price for pickup. However, this didn’t work. It seems that this function only applies to the Pickup Price.

                        Why am I asking all this?
                        For a client, I created two SNACKS menus: 1 – SNACKS and 2 – SNACKS FOR PICKUP.
                        The second SNACKS menu for pickup contains slightly different and cheaper items, which is why the seller doesn’t want to include it for delivery.
                        Therefore, I would prefer a functional solution instead of creating two menus with similar names.

                        Best regards
                        Umut

                      Viewing 10 posts - 1 through 10 (of 10 total)
                      • You must be logged in to reply to this topic.